]> git.kaiwu.me - haproxy.git/commitdiff
BUG/MINOR: deviceatlas: fix free() of an uninitialized cnew in checkinst
authorWilliam Lallemand <wlallemand@haproxy.com>
Mon, 30 Nov 2026 10:57:48 +0000 (10:57 +0000)
committerWilliam Lallemand <wlallemand@haproxy.com>
Mon, 30 Nov 2026 10:59:48 +0000 (11:59 +0100)
Reported by GitHub user brhenc in issue #3597 (a follow-up of the Coverity
report in #2428). In da_haproxy_checkinst(), "cnew" is filled by
da_atlas_compile(), which does not guarantee to write anything back to
the caller-supplied pointer when the compilation fails. The free() on
the error path could then be called on an indeterminate stack value and
crash the process. The fix introduced by d8ff676592 ("fix resource leak
on hot-reload compile failure") is preserved since free(NULL) is a no-op
if the library leaves the output untouched.

This must be backported to 3.4, 3.3, 3.2, 3.1 and 3.0, which all received
d8ff676592.

addons/deviceatlas/da.c

index ab6d953a3eadd3d02f281e080c2c0c6bb06cba89..ac754e008d5189384aab4ea5b167c8adac68c16f 100644 (file)
@@ -288,7 +288,7 @@ static void da_haproxy_checkinst(void)
 
             if (base[0] != 0 && base[0] != '0') {
             FILE *jsonp;
-            void *cnew, *cold;
+            void *cnew = NULL, *cold;
             da_status_t status;
             size_t atlassz;
             char atlasp[ATLASTOKSZ] = {0};