]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUG/MINOR: nameservers: fix error handling in parsing of resolv.conf
authorWilly Tarreau <w@1wt.eu>
Thu, 28 May 2020 16:07:10 +0000 (18:07 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 28 May 2020 16:12:22 +0000 (18:12 +0200)
commit78675252fb6ce195c145afd2862fa53087bf585f
treec5aa4cc4571aa35544b94ccff8da0c528e8b04e8
parent143f4ce05181aa853dc8049fdbb2a49c7a91b720
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.
src/cfgparse.c