diff options
author | Mikhail Galanin <mgalanin@mimecast.com> | 2018-08-24 14:46:30 +0100 |
---|---|---|
committer | Mikhail Galanin <mgalanin@mimecast.com> | 2018-08-24 14:46:30 +0100 |
commit | ab7cf308916afebabcb27425ba2e8b4e605d1898 (patch) | |
tree | 1bff497afa4f60156bab531fb39b5b709c0d189b | |
parent | 8de04f432d2b5bb56a3c278adc7ad007f6474e7d (diff) | |
download | rspamd-ab7cf308916afebabcb27425ba2e8b4e605d1898.tar.gz rspamd-ab7cf308916afebabcb27425ba2e8b4e605d1898.zip |
[Minor] check if required parameters are set when calling tcp:request()
-rw-r--r-- | src/lua/lua_tcp.c | 11 |
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); |