]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUG: dns: Fix off-by-one write in dns_validate_dns_response()
authorRemi Gacogne <remi.gacogne@powerdns.com>
Wed, 5 Dec 2018 16:59:56 +0000 (17:59 +0100)
committerWilly Tarreau <w@1wt.eu>
Wed, 12 Dec 2018 13:44:52 +0000 (14:44 +0100)
commit00488ddef5497026465b65b1cafcc1b37b753b83
treec29d1d66fcde06463d6c9212d799ffa451999711
parentbc552102ad0ba14eaf83a93a5119f316fa6481f5
BUG: dns: Fix off-by-one write in dns_validate_dns_response()

The maximum number of bytes in a DNS name is indeed 255, but we
need to allocate one more byte for the NULL-terminating byte.
Otherwise dns_read_name() might return 255 for a very long name,
causing dns_validate_dns_response() to write a NULL value one
byte after the end of the buffer:

dns_answer_record->name[len] = 0;

The next fields in the struct being filled from the content of the
query, it might have been possible to fill them with non-0 values,
causing for example a strlen() of the name to read past the end of
the struct and access unintended parts of the memory, possibly
leading to a crash.

To be backported to 1.8, probably also 1.7.
include/types/dns.h