]> source.dussan.org Git - rspamd.git/commitdiff
[Fix] Fix sending string method
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 17 Jul 2018 14:27:06 +0000 (15:27 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 17 Jul 2018 14:27:06 +0000 (15:27 +0100)
Issue: #2346

src/controller.c
src/libserver/worker_util.c

index 27e1bd6e701336657e1dc3392a62c124d696a8cc..c786c138e331c530620fe3f2826af0abcf7611d4 100644 (file)
@@ -3463,7 +3463,7 @@ static int
 lua_csession_send_string (lua_State *L)
 {
        struct rspamd_http_connection_entry *c = lua_check_controller_entry (L, 1);
-       const gchar *str = lua_tostring (L, 3);
+       const gchar *str = lua_tostring (L, 2);
 
        if (c) {
                rspamd_controller_send_string (c, str);
index 7380a1ffd921bd741d948e25b082f747931ff352..cf51eff62edb0035ca7d9fa4c5c769d48f3e8662 100644 (file)
@@ -449,7 +449,14 @@ rspamd_controller_send_string (struct rspamd_http_connection_entry *entry,
        msg->date = time (NULL);
        msg->code = 200;
        msg->status = rspamd_fstring_new_init ("OK", 2);
-       reply = rspamd_fstring_new_init (str, strlen (str));
+
+       if (str) {
+               reply = rspamd_fstring_new_init (str, strlen (str));
+       }
+       else {
+               reply = rspamd_fstring_new_init ("null", 4);
+       }
+
        rspamd_http_message_set_body_from_fstring_steal (msg,
                        rspamd_controller_maybe_compress (entry, reply, msg));
        rspamd_http_connection_reset (entry->conn);