]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Minor] Allow to edit empty maps
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 13 Oct 2018 13:23:00 +0000 (14:23 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 13 Oct 2018 13:23:00 +0000 (14:23 +0100)
src/controller.c

index 6cb5eaa623582f9b39b887915b783d5e65f5e529..88d1d0ed6f94c95edf01be7a3e5b438e11ff3623 100644 (file)
@@ -1047,12 +1047,18 @@ rspamd_controller_handle_get_map (struct rspamd_http_connection_entry *conn_ent,
                reply->date = time (NULL);
                reply->code = 200;
 
-               if (!rspamd_http_message_set_body_from_fd (reply, fd)) {
-                       close (fd);
-                       rspamd_http_message_unref (reply);
-                       msg_err_session ("cannot read map %s: %s", bk->uri, strerror (errno));
-                       rspamd_controller_send_error (conn_ent, 500, "Map read error");
-                       return 0;
+               if (st.st_size > 0) {
+                       if (!rspamd_http_message_set_body_from_fd (reply, fd)) {
+                               close (fd);
+                               rspamd_http_message_unref (reply);
+                               msg_err_session ("cannot read map %s: %s", bk->uri, strerror (errno));
+                               rspamd_controller_send_error (conn_ent, 500, "Map read error");
+                               return 0;
+                       }
+               }
+               else {
+                       rspamd_fstring_t *empty_body = rspamd_fstring_new_init ("", 0);
+                       rspamd_http_message_set_body_from_fstring_steal (reply, empty_body);
                }
 
                close (fd);