mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-01-13 17:20:52 +00:00
BUG/MINOR: nameservers: fix error handling in parsing of resolv.conf
In issue #657, Coverity found a bug in the "nameserver" parser for the
resolv.conf when "parse-resolv-conf" is set. What happens is that if an
unparsable address appears on a "nameserver" line, it will destroy the
previously allocated pointer before reporting the warning, then the next
"nameserver" line will dereference it again and wlil cause a crash. If
the faulty nameserver is the last one, it will only be a memory leak.
Let's just make sure we preserve the pointer when handling the error.
The patch also fixes a typo in the warning.
The bug was introduced in 1.9 with commit 44e609bfa
("MINOR: dns:
Implement `parse-resolv-conf` directive") so the fix needs to be backported
up to 1.9 or 2.0.
This commit is contained in:
parent
143f4ce051
commit
78675252fb
@ -1130,9 +1130,8 @@ int cfg_parse_resolvers(const char *file, int linenum, char **args, int kwm)
|
||||
continue;
|
||||
|
||||
memset(sk, 0, sizeof(*sk));
|
||||
sk = str2ip2(address, sk, 1);
|
||||
if (!sk) {
|
||||
ha_warning("parsing [/etc/resolv.conf:%d] : address '%s' could not be recognized, namerserver will be excluded.\n",
|
||||
if (!str2ip2(address, sk, 1)) {
|
||||
ha_warning("parsing [/etc/resolv.conf:%d] : address '%s' could not be recognized, nameserver will be excluded.\n",
|
||||
resolv_linenum, address);
|
||||
err_code |= ERR_WARN;
|
||||
continue;
|
||||
|
Loading…
Reference in New Issue
Block a user