commit bbf92ed: [Minor] Rdns: Fix parsing of nameserver lines
Vsevolod Stakhov
vsevolod at highsecure.ru
Fri Feb 22 17:07:03 UTC 2019
Author: Vsevolod Stakhov
Date: 2019-02-22 17:03:16 +0000
URL: https://github.com/rspamd/rspamd/commit/bbf92ed57bb0a83fb62f26f50e1f508c743a713f (HEAD -> master)
[Minor] Rdns: Fix parsing of nameserver lines
Issue: #2762
Closes: #2762
---
contrib/librdns/util.c | 18 ++++++++++++++----
1 file 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;
More information about the Commits
mailing list