]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUG/MINOR: resolvers: don't lower the case of binary DNS format
authorWilly Tarreau <w@1wt.eu>
Mon, 7 Jul 2025 14:33:02 +0000 (16:33 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 8 Jul 2025 05:54:45 +0000 (07:54 +0200)
commit95cf518bfa312b3493f96a4ff6f911b014a49aec
tree6218dd754f103f1f7e3311a949b2f8c1effed727
parent54d36f3e6505a1380b058f43f9e7ba1697f4ef21
BUG/MINOR: resolvers: don't lower the case of binary DNS format

The server's "hostname_dn" is in Domain Name format, not a pure string, as
converted by resolv_str_to_dn_label(). It is made of lower-case string
components delimited by binary lengths, e.g. <0x03>www<0x07>haproxy<0x03)org.
As such it must not be lowercased again in srv_state_srv_update(), because
1) it's useless on the name components since already done, and 2) because
it would replace component lengths 97 and above by 32-char shorter ones.
Granted, not many domain names have that large components so the risk is
very low but the operation is always wrong anyway. This was brought in
2.5 by commit 3406766d57 ("MEDIUM: resolvers: add a ref between servers
and srv request or used SRV record").

In the same vein, let's fix the confusing strcasecmp() that are applied
to this binary format, and use memcmp() instead. Here there's basically
no risk to incorrectly match the wrong record, but that test alone is
confusing enough to provoke the existence of the bug above.

Finally let's update the component for that field to mention that it's
in this format and already lower cased.

Better not backport this, the risk of facing this bug is almost zero, and
every time we touch such files something breaks for bad reasons.
include/haproxy/server-t.h
src/server.c
src/server_state.c