BUG/MINOR: spoe: add missing key length check before checking key names
authorWilly Tarreau <w@1wt.eu>
Tue, 16 Jun 2020 15:58:14 +0000 (17:58 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 3 Jul 2020 17:03:54 +0000 (19:03 +0200)
commit52d4af0accaa9440c0434387ec29beac1816fdd0
tree3788eaedf86f2b969668d12af3fe884ba71e77d0
parentfaab6fd895fa40cd02a75b435254527f3c16b6bc
BUG/MINOR: spoe: add missing key length check before checking key names

The spoe parser fails to check that the decoded key length is large
enough to match a given key but it uses the returned length in memcmp().
So returning "ver" could match "version" for example. In addition this
makes clang 10's ASAN complain because the second argument to memcmp()
is the static key which is shorter than the decoded buffer size, which
in practice has no impact.

I'm still not 100% sure the parser is entirely correct because even
with this fix it cannot parse a key whose name matches the beginning
of another one, but in practice this does not happen. Ideally a
preliminary length check before the comparison would be safer.

This needs to be backported as far as 1.7.

(cherry picked from commit da21ed1662ff7f1610db14b3ce48f19ec37a695b)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
src/flt_spoe.c