aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/librdns/util.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2019-02-22 17:03:16 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2019-02-22 17:03:16 +0000
commitbbf92ed57bb0a83fb62f26f50e1f508c743a713f (patch)
treef2f804d890024a4c3c709582d7a083db7e057303 /contrib/librdns/util.c
parent43c67de7e23f2018a6cc51a9d187aec9ad928387 (diff)
downloadrspamd-bbf92ed57bb0a83fb62f26f50e1f508c743a713f.tar.gz
rspamd-bbf92ed57bb0a83fb62f26f50e1f508c743a713f.zip
[Minor] Rdns: Fix parsing of nameserver lines
Issue: #2762 Closes: #2762
Diffstat (limited to 'contrib/librdns/util.c')
-rw-r--r--contrib/librdns/util.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/contrib/librdns/util.c b/contrib/librdns/util.c
index b793b9077..9f1bc6018 100644
--- a/contrib/librdns/util.c
+++ b/contrib/librdns/util.c
@@ -537,8 +537,9 @@ rdns_resolver_conf_process_line (struct rdns_resolver *resolver,
const char *line, rdns_resolv_conf_cb cb, void *ud)
{
const char *p, *c, *end;
- bool has_obrace = false;
+ bool has_obrace = false, ret;
unsigned int port = dns_port;
+ char *cpy_buf;
end = line + strlen (line);
@@ -546,7 +547,7 @@ rdns_resolver_conf_process_line (struct rdns_resolver *resolver,
strncmp (line, "nameserver", sizeof ("nameserver") - 1) == 0) {
p = line + sizeof ("nameserver") - 1;
/* Skip spaces */
- while (*p == ' ' || *p == '\t') {
+ while (isspace (*p)) {
p ++;
}
@@ -578,14 +579,23 @@ rdns_resolver_conf_process_line (struct rdns_resolver *resolver,
}
}
+ cpy_buf = malloc (p - c + 1);
+ assert (cpy_buf != NULL);
+ memcpy (cpy_buf, c, p - c);
+ cpy_buf[p - c] = '\0';
+
if (cb == NULL) {
- return rdns_resolver_add_server (resolver, c, port, 0,
+ ret = rdns_resolver_add_server (resolver, cpy_buf, port, 0,
default_io_cnt) != NULL;
}
else {
- return cb (resolver, c, port, 0,
+ ret = cb (resolver, cpy_buf, port, 0,
default_io_cnt, ud);
}
+
+ free (cpy_buf);
+
+ return ret;
}
else {
return false;