From 144c31c63ccf06036cbddc5b34f8f57e2e77ae2e Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Tue, 17 Jul 2018 15:27:06 +0100 Subject: [PATCH] [Fix] Fix sending string method Issue: #2346 --- src/controller.c | 2 +- src/libserver/worker_util.c | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) 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); -- 2.39.5