aboutsummaryrefslogtreecommitdiffstats
path: root/src/libutil
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2017-12-14 08:04:15 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2017-12-14 08:04:15 +0000
commitba48159c222d01adb2152f336b301d32cf3772a9 (patch)
treec269a7ef309ca4881c15b44e915b75ce1f77a662 /src/libutil
parent413ecb9bde4067f916592d69d43314bd9ad136cc (diff)
downloadrspamd-ba48159c222d01adb2152f336b301d32cf3772a9.tar.gz
rspamd-ba48159c222d01adb2152f336b301d32cf3772a9.zip
[Fix] Handle proxy copy errors
Diffstat (limited to 'src/libutil')
-rw-r--r--src/libutil/http.c18
-rw-r--r--src/libutil/http.h2
2 files changed, 18 insertions, 2 deletions
diff --git a/src/libutil/http.c b/src/libutil/http.c
index 60378f8a1..9e3e2f2a1 100644
--- a/src/libutil/http.c
+++ b/src/libutil/http.c
@@ -1398,7 +1398,7 @@ rspamd_http_connection_steal_msg (struct rspamd_http_connection *conn)
}
struct rspamd_http_message *
-rspamd_http_connection_copy_msg (struct rspamd_http_message *msg)
+rspamd_http_connection_copy_msg (struct rspamd_http_message *msg, GError **err)
{
struct rspamd_http_message *new_msg;
struct rspamd_http_header *hdr, *nhdr, *nhdrs, *thdr, *hcur;
@@ -1421,11 +1421,19 @@ rspamd_http_connection_copy_msg (struct rspamd_http_message *msg)
if (storage->shared.shm_fd == -1) {
rspamd_http_message_unref (new_msg);
+ g_set_error (err, http_error_quark (), errno,
+ "cannot dup shmem fd: %d: %s",
+ msg->body_buf.c.shared.shm_fd, strerror (errno));
+
return NULL;
}
if (fstat (storage->shared.shm_fd, &st) == -1) {
+ g_set_error (err, http_error_quark (), errno,
+ "cannot stat shmem fd: %d: %s",
+ storage->shared.shm_fd, strerror (errno));
rspamd_http_message_unref (new_msg);
+
return NULL;
}
@@ -1441,7 +1449,11 @@ rspamd_http_connection_copy_msg (struct rspamd_http_message *msg)
storage->shared.shm_fd, 0);
if (new_msg->body_buf.str == MAP_FAILED) {
+ g_set_error (err, http_error_quark (), errno,
+ "cannot mmap shmem fd: %d: %s",
+ storage->shared.shm_fd, strerror (errno));
rspamd_http_message_unref (new_msg);
+
return NULL;
}
@@ -1454,7 +1466,11 @@ rspamd_http_connection_copy_msg (struct rspamd_http_message *msg)
old_body = rspamd_http_message_get_body (msg, &old_len);
if (!rspamd_http_message_set_body (new_msg, old_body, old_len)) {
+ g_set_error (err, http_error_quark (), errno,
+ "cannot set body for message, length: %zd",
+ old_len);
rspamd_http_message_unref (new_msg);
+
return NULL;
}
}
diff --git a/src/libutil/http.h b/src/libutil/http.h
index 3696c4e18..1c418ebb8 100644
--- a/src/libutil/http.h
+++ b/src/libutil/http.h
@@ -280,7 +280,7 @@ struct rspamd_http_message * rspamd_http_connection_steal_msg (
* @return
*/
struct rspamd_http_message * rspamd_http_connection_copy_msg (
- struct rspamd_http_message *msg);
+ struct rspamd_http_message *msg, GError **err);
/**
* Create new HTTP message