From: Vsevolod Stakhov Date: Tue, 17 Jul 2018 14:27:06 +0000 (+0100) Subject: [Fix] Fix sending string method X-Git-Tag: 1.7.9~104 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=144c31c63ccf06036cbddc5b34f8f57e2e77ae2e;p=rspamd.git [Fix] Fix sending string method Issue: #2346 --- diff --git a/src/controller.c b/src/controller.c index 27e1bd6e7..c786c138e 100644 --- a/src/controller.c +++ b/src/controller.c @@ -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); diff --git a/src/libserver/worker_util.c b/src/libserver/worker_util.c index 7380a1ffd..cf51eff62 100644 --- a/src/libserver/worker_util.c +++ b/src/libserver/worker_util.c @@ -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);