summaryrefslogtreecommitdiffstats
path: root/src/lua/lua_ip.c
diff options
context:
space:
mode:
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);