]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUG/MEDIUM: resolvers: use correct storage for the target address
authorWilly Tarreau <w@1wt.eu>
Thu, 14 Oct 2021 20:30:38 +0000 (22:30 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 14 Oct 2021 20:44:51 +0000 (22:44 +0200)
commitb4ca0195a9591614bfcebe9b7fe80c1ce9f94d8d
tree4abb0ff3d1dc8eb81561a46031fcdc74de035818
parent6dfbef4145845a421e5d9301e26cbc7136d20965
BUG/MEDIUM: resolvers: use correct storage for the target address

The struct resolv_answer_item contains an address field of type
"sockaddr" which is only 16 bytes long, but which is used to store
either IPv4 or IPv6. Fortunately, the contents only overlap with
the "target" field that follows it and that is large enough to
absorb the extra bytes needed to store AAAA records. But this is
dangerous as just moving fields around could result in memory
corruption.

The fix uses a union and removes the casts that were used to hide
the problem.

Older versions need to be checked and possibly fixed. This needs
to be backported anyway.
include/haproxy/resolvers-t.h
src/resolvers.c