if (recv->real_ip) {
if (!rspamd_parse_inet_address (&task->from_addr,
recv->real_ip,
- 0)) {
+ strlen (recv->real_ip))) {
msg_warn_task ("cannot get IP from received header: '%s'",
recv->real_ip);
task->from_addr = NULL;
if (ucl_object_type (obj) == UCL_STRING) {
val = ucl_object_tostring (obj);
- if (!rspamd_parse_inet_address (target, val, 0)) {
+ if (!rspamd_parse_inet_address (target, val, strlen (val))) {
g_set_error (err,
CFG_RCL_ERROR,
EINVAL,
guint iplen;
gulong portnum;
- g_assert (src != NULL);
- g_assert (target != NULL);
-
if (srclen == 0) {
- srclen = strlen (src);
+ return FALSE;
}
+ g_assert (src != NULL);
+ g_assert (target != NULL);
+
rspamd_ip_check_ipv6 ();
if (src[0] == '/' || src[0] == '.') {
}
}
- if (!rspamd_parse_inet_address (&cur_addr, str, 0)) {
+ if (!rspamd_parse_inet_address (&cur_addr, str, strlen (str))) {
msg_err_pool_check ("cannot parse unix socket definition %s: %s",
str,
strerror (errno));
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;
}
}
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);
{
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) {
else {
if (!rspamd_parse_inet_address (&addr,
ip_str,
- 0)) {
+ len)) {
msg_warn_task ("cannot get IP from received header: '%s'",
ip_str);
}
}
}
- 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);
}
}
- 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)) {
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);
}
exit (1);
}
- if (!rspamd_parse_inet_address (&addr, control_path, 0)) {
+ if (!rspamd_parse_inet_address (&addr, control_path, strlen (control_path))) {
rspamd_fprintf (stderr, "bad control path: %s\n", control_path);
exit (1);
}
if (rspamd_main->cfg->control_socket_path) {
if (!rspamd_parse_inet_address (&control_addr,
rspamd_main->cfg->control_socket_path,
- 0)) {
+ strlen (rspamd_main->cfg->control_socket_path))) {
msg_err_main ("cannot parse inet address %s",
rspamd_main->cfg->control_socket_path);
}
RSPAMD_UPSTREAM_PARSE_DEFAULT,
NULL));
up = rspamd_upstream_get (nls, RSPAMD_UPSTREAM_RANDOM, NULL, 0);
- rspamd_parse_inet_address (&paddr, "127.0.0.2", 0);
+ rspamd_parse_inet_address (&paddr, "127.0.0.2", strlen ("127.0.0.2"));
g_assert (rspamd_upstream_add_addr (up, paddr));
- rspamd_parse_inet_address (&paddr, "::1", 0);
+ rspamd_parse_inet_address (&paddr, "::1", strlen ("::1"));
g_assert (rspamd_upstream_add_addr (up, paddr));
/* Rewind to start */
addr = rspamd_upstream_addr_next (up);