]> git.ipfire.org Git - thirdparty/haproxy.git/commit
MINOR: auth: silence null dereference warning in check_user()
authorAurelien DARRAGON <adarragon@haproxy.com>
Thu, 24 Nov 2022 07:37:13 +0000 (08:37 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 24 Nov 2022 14:24:02 +0000 (15:24 +0100)
commita7dc251e0747bb41a145b111e66fa54898fcc5fe
tree21ac887d4c183ab3ef2b888aeaef76d799195397
parent95f40c698d3ef3ad25fded5a7c35e2d108d2b542
MINOR: auth: silence null dereference warning in check_user()

In GH issue #1940 cppcheck warns about a possible null-dereference in
check_user() when DEBUG_AUTH is enabled. Indeed, <ep> may potentially
be NULL because upon error crypt_r() and crypt() may return a null
pointer. However it's not directly derefenced, it is only passed to
printf() with '%s' fmt. While it is in practice fine with the printf
implementations we care about (that check strings against null before
printing them), it is undefined behavior according to the spec, hence
the warning.

Let's check <ep> before passing it to printf. This should partly
solve GH #1940.
src/auth.c