]> git.ipfire.org Git - thirdparty/haproxy.git/commit
CLEANUP: resolvers: use read_n32() instead of open-coded big-endian read
authorWilly Tarreau <w@1wt.eu>
Fri, 22 May 2026 06:01:49 +0000 (06:01 +0000)
committerWilly Tarreau <w@1wt.eu>
Mon, 25 May 2026 08:57:13 +0000 (10:57 +0200)
commit8fe8d5fbe3e4f7e3b6debb0741223c07f4c5a248
tree33dc8fb074d9fa8305c37f9bca07b34dcf8a4f9b
parentb78b023d5543197a5a1dc3fca267938db01176c5
CLEANUP: resolvers: use read_n32() instead of open-coded big-endian read

In resolv_validate_dns_response(), the second DNS record parsing path
manually constructs a 32-bit big-endian TTL value from four individual
bytes using the expression:

  reader[0] * 16777216 + reader[1] * 65536 + reader[2] * 256 + reader[3]

We have read_n32() to do this, and it's more robust against unexpected
signedness surprises (which should not happen right here since reader is
unsigned char and we use -fwrapv so the result is defined). Also, let's
make the ttl an uint instead of an int. The TTL is only retrieved and not
used for now, so better clean it now.
include/haproxy/resolvers-t.h
src/resolvers.c