]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] check if required parameters are set when calling tcp:request() 2442/head
authorMikhail Galanin <mgalanin@mimecast.com>
Fri, 24 Aug 2018 13:46:30 +0000 (14:46 +0100)
committerMikhail Galanin <mgalanin@mimecast.com>
Fri, 24 Aug 2018 13:46:30 +0000 (14:46 +0100)
src/lua/lua_tcp.c

index 8d948c6d55ecd2eb5b134451a1b5a0a445ef208f..61a73acf856d62bfd2a45d70cabd40bed81ba5d9 100644 (file)
@@ -990,10 +990,10 @@ lua_tcp_request (lua_State *L)
        gsize plen = 0;
        struct event_base *ev_base;
        struct lua_tcp_cbdata *cbd;
-       struct rspamd_dns_resolver *resolver;
+       struct rspamd_dns_resolver *resolver = NULL;
        struct rspamd_async_session *session = NULL;
        struct rspamd_task *task = NULL;
-       struct rspamd_config *cfg;
+       struct rspamd_config *cfg = NULL;
        struct iovec *iov = NULL;
        guint niov = 0, total_out;
        guint64 h;
@@ -1194,6 +1194,13 @@ lua_tcp_request (lua_State *L)
                return 1;
        }
 
+       if (resolver == NULL && cfg == NULL && task == NULL) {
+               msg_err ("tcp request has bad params: one of {resolver,task,config} should be set");
+               lua_pushboolean (L, FALSE);
+
+               return 1;
+       }
+
        cbd->task = task;
        h = rspamd_random_uint64_fast ();
        rspamd_snprintf (cbd->tag, sizeof (cbd->tag), "%uxL", h);