From: Olivier Houchard Date: Tue, 17 Nov 2026 10:14:57 +0000 (+0100) Subject: BUG/MINOR: http/hardening: free the new profile on strdup() failure X-Git-Tag: v3.5-dev13~35 X-Git-Url: https://git.kaiwu.me/http/$%7BISSUES%7D/static/gitweb.js?a=commitdiff_plain;h=0b4bb8f447fdf8e36bee3c5d97c185dee4f1285e;p=haproxy.git BUG/MINOR: http/hardening: free the new profile on strdup() failure In cfg_parse_http_hardening(), when strdup() of the file name fails after a new profile was allocated by http_hardening_new(), the profile is not yet indexed and its only reference is lost on "goto out", leaking it and its name. Let's release it with http_hardening_free(), which is safe for the static profiles. This was reported by Coverity (CID 1690184) in GitHub issue #3560, with the analysis and fix provided by Alexandre Laroche. It was introduced by commit fa70a47cb ("MINOR: cfgparse/http: add a simple parser for new section "http-fingerprint"") in 3.5-dev11, so no backport is needed. --- diff --git a/src/http.c b/src/http.c index 6327b1713..7701a8b5d 100644 --- a/src/http.c +++ b/src/http.c @@ -1889,6 +1889,8 @@ struct http_hdng_prf *http_hardening_resolve(const char *name, char **err) * hardening option is followed by "on" or "off" to enable or disable the * matching checks. */ +static void http_hardening_free(struct http_hdng_prf *prf); + int cfg_parse_http_hardening(const char *file, int linenum, char **args, int kwm) { struct http_hdng_prf *prf, *other, *base = NULL; @@ -1973,6 +1975,7 @@ int cfg_parse_http_hardening(const char *file, int linenum, char **args, int kwm if (!file_copy) { ha_alert("parsing [%s:%d] : out of memory.\n", file, linenum); err_code |= ERR_ALERT | ERR_ABORT; + http_hardening_free(prf); goto out; } prf->file = file_copy;