diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-09-26 12:07:29 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-09-26 12:07:29 +0100 |
commit | 66d8b6e43447eeebe1ca1c2f79fa4b52173a1b6b (patch) | |
tree | 45dc9e90027450559bebecfe74c6e6b74d5d6524 /src/lua | |
parent | f648223e11b724cb485fabd8d344fec3b3e382c5 (diff) | |
download | rspamd-66d8b6e43447eeebe1ca1c2f79fa4b52173a1b6b.tar.gz rspamd-66d8b6e43447eeebe1ca1c2f79fa4b52173a1b6b.zip |
[Fix] Do not call implicit strlen to avoid issues
Diffstat (limited to 'src/lua')
-rw-r--r-- | src/lua/lua_ip.c | 9 | ||||
-rw-r--r-- | src/lua/lua_task.c | 5 | ||||
-rw-r--r-- | src/lua/lua_tcp.c | 4 | ||||
-rw-r--r-- | src/lua/lua_udp.c | 2 |
4 files changed, 11 insertions, 9 deletions
diff --git a/src/lua/lua_ip.c b/src/lua/lua_ip.c index 942817b5c..8318125ba 100644 --- a/src/lua/lua_ip.c +++ b/src/lua/lua_ip.c @@ -369,13 +369,14 @@ lua_ip_from_string (lua_State *L) LUA_TRACE_POINT; struct rspamd_lua_ip *ip; const gchar *ip_str; + gsize len; - ip_str = luaL_checkstring (L, 1); + ip_str = luaL_checklstring (L, 1, &len); if (ip_str) { ip = lua_ip_new (L, NULL); - if (!rspamd_parse_inet_address (&ip->addr, ip_str, 0)) { - msg_warn ("cannot parse ip: %s", ip_str); + if (!rspamd_parse_inet_address (&ip->addr, ip_str, len)) { + msg_warn ("cannot parse ip: %*s", (gint) len, ip_str); ip->addr = NULL; } } @@ -559,7 +560,7 @@ rspamd_lua_ip_push_fromstring (lua_State *L, const gchar *ip_str) else { ip = g_malloc0 (sizeof (struct rspamd_lua_ip)); - if (rspamd_parse_inet_address (&ip->addr, ip_str, 0)) { + if (rspamd_parse_inet_address (&ip->addr, ip_str, strlen (ip_str))) { pip = lua_newuserdata (L, sizeof (struct rspamd_lua_ip *)); rspamd_lua_setclass (L, "rspamd{ip}", -1); diff --git a/src/lua/lua_task.c b/src/lua/lua_task.c index d2d0c872a..af1a12fae 100644 --- a/src/lua/lua_task.c +++ b/src/lua/lua_task.c @@ -3856,7 +3856,8 @@ lua_task_set_from_ip (lua_State *L) { LUA_TRACE_POINT; struct rspamd_task *task = lua_check_task (L, 1); - const gchar *ip_str = luaL_checkstring (L, 2); + gsize len; + const gchar *ip_str = luaL_checklstring (L, 2, &len); rspamd_inet_addr_t *addr = NULL; if (!task || !ip_str) { @@ -3866,7 +3867,7 @@ lua_task_set_from_ip (lua_State *L) else { if (!rspamd_parse_inet_address (&addr, ip_str, - 0)) { + len)) { msg_warn_task ("cannot get IP from received header: '%s'", ip_str); } diff --git a/src/lua/lua_tcp.c b/src/lua/lua_tcp.c index 10c57cea4..18c022c38 100644 --- a/src/lua/lua_tcp.c +++ b/src/lua/lua_tcp.c @@ -1760,7 +1760,7 @@ lua_tcp_request (lua_State *L) } } - if (rspamd_parse_inet_address (&cbd->addr, host, 0)) { + if (rspamd_parse_inet_address (&cbd->addr, host, strlen (host))) { rspamd_inet_address_set_port (cbd->addr, port); /* Host is numeric IP, no need to resolve */ lua_tcp_register_watcher (cbd); @@ -1942,7 +1942,7 @@ lua_tcp_connect_sync (lua_State *L) } } - if (rspamd_parse_inet_address (&cbd->addr, host, 0)) { + if (rspamd_parse_inet_address (&cbd->addr, host, strlen (host))) { rspamd_inet_address_set_port (cbd->addr, (guint16)port); /* Host is numeric IP, no need to resolve */ if (!lua_tcp_make_connection (cbd)) { diff --git a/src/lua/lua_udp.c b/src/lua/lua_udp.c index 94d27bf63..966ce9788 100644 --- a/src/lua/lua_udp.c +++ b/src/lua/lua_udp.c @@ -373,7 +373,7 @@ lua_udp_sendto (lua_State *L) { if (lua_type (L, -1) == LUA_TSTRING) { host = luaL_checkstring (L, -1); - if (rspamd_parse_inet_address (&addr, host, 0)) { + if (rspamd_parse_inet_address (&addr, host, strlen (host))) { if (port != 0) { rspamd_inet_address_set_port (addr, port); } |