summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2018-08-26 13:30:41 +0100
committerGitHub <noreply@github.com>2018-08-26 13:30:41 +0100
commit99f067d9baf9c5141de5d24204d82008363cc78d (patch)
tree29f8feb78c6b807693d3c0df4417f81b483a4fbd
parentf600955b95d522119558b5da7d1f614bea99f3b6 (diff)
parentab7cf308916afebabcb27425ba2e8b4e605d1898 (diff)
downloadrspamd-99f067d9baf9c5141de5d24204d82008363cc78d.tar.gz
rspamd-99f067d9baf9c5141de5d24204d82008363cc78d.zip
Merge pull request #2442 from negram/more-check-parameters
[Minor] check if required parameters are set when calling tcp:request()
-rw-r--r--src/lua/lua_tcp.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/lua/lua_tcp.c b/src/lua/lua_tcp.c
index 8d948c6d5..61a73acf8 100644
--- a/src/lua/lua_tcp.c
+++ b/src/lua/lua_tcp.c
@@ -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);