]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Allow to proxy empty files
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 6 Mar 2018 08:43:04 +0000 (08:43 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 6 Mar 2018 09:29:01 +0000 (09:29 +0000)
src/libutil/util.c
src/rspamd_proxy.c

index c8de9a6512e93a6bfe91b49845097cf1bd418619..d025730ac4c302c99392e2f744f5a721bba84373 100644 (file)
@@ -2483,8 +2483,16 @@ rspamd_file_xmap (const char *fname, guint mode, gsize *size,
                return NULL;
        }
 
-       if (fstat (fd, &sb) == -1 || !S_ISREG (sb.st_mode) || sb.st_size == 0) {
+       if (fstat (fd, &sb) == -1 || !S_ISREG (sb.st_mode)) {
                close (fd);
+               *size = (gsize)-1;
+
+               return NULL;
+       }
+
+       if (sb.st_size == 0) {
+               close (fd);
+               *size = (gsize)0;
 
                return NULL;
        }
index a7c20e34b63b2d8fdefacdc1c5d3b324b8977e75..53e954a5836616da3159b807fe05f63b59f90125 100644 (file)
@@ -1193,9 +1193,12 @@ proxy_check_file (struct rspamd_http_message *msg,
                                TRUE);
 
                if (session->map == NULL) {
-                       msg_err_session ("cannot map %s: %s", file_str, strerror (errno));
+                       if (session->map_len != 0) {
+                               msg_err_session ("cannot map %s: %s", file_str,
+                                               strerror (errno));
 
-                       return FALSE;
+                               return FALSE;
+                       }
                }
                /* Remove header after processing */
                rspamd_http_message_remove_header (msg, "File");
@@ -1222,10 +1225,13 @@ proxy_check_file (struct rspamd_http_message *msg,
                                                &session->map_len, TRUE);
 
                                if (session->map == NULL) {
-                                       msg_err_session ("cannot map %s: %s", file_str, strerror (errno));
-                                       g_hash_table_unref (query_args);
+                                       if (session->map_len != 0) {
+                                               msg_err_session ("cannot map %s: %s", file_str,
+                                                               strerror (errno));
+                                               g_hash_table_unref (query_args);
 
-                                       return FALSE;
+                                               return FALSE;
+                                       }
                                }
 
                                /* We need to create a new URL with file attribute removed */