summaryrefslogtreecommitdiffstats
path: root/src/lua/lua_ip.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2019-09-26 12:07:29 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2019-09-26 12:07:29 +0100
commit66d8b6e43447eeebe1ca1c2f79fa4b52173a1b6b (patch)
tree45dc9e90027450559bebecfe74c6e6b74d5d6524 /src/lua/lua_ip.c
parentf648223e11b724cb485fabd8d344fec3b3e382c5 (diff)
downloadrspamd-66d8b6e43447eeebe1ca1c2f79fa4b52173a1b6b.tar.gz
rspamd-66d8b6e43447eeebe1ca1c2f79fa4b52173a1b6b.zip
[Fix] Do not call implicit strlen to avoid issues
Diffstat (limited to 'src/lua/lua_ip.c')
-rw-r--r--src/lua/lua_ip.c9
1 files changed, 5 insertions, 4 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);