diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-12-14 08:04:15 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-12-14 08:04:15 +0000 |
commit | ba48159c222d01adb2152f336b301d32cf3772a9 (patch) | |
tree | c269a7ef309ca4881c15b44e915b75ce1f77a662 /src/libutil/http.c | |
parent | 413ecb9bde4067f916592d69d43314bd9ad136cc (diff) | |
download | rspamd-ba48159c222d01adb2152f336b301d32cf3772a9.tar.gz rspamd-ba48159c222d01adb2152f336b301d32cf3772a9.zip |
[Fix] Handle proxy copy errors
Diffstat (limited to 'src/libutil/http.c')
-rw-r--r-- | src/libutil/http.c | 18 |
1 files changed, 17 insertions, 1 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; } } |