]> git.kaiwu.me - haproxy.git/commit
BUG/MINOR: http-htx: check the strdup() of the "lf-string" http reply argument
authorWilly Tarreau <w@1wt.eu>
Mon, 27 Jul 2026 10:16:30 +0000 (12:16 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Mon, 27 Jul 2026 13:49:21 +0000 (15:49 +0200)
commitd10d08570f61d43e009103c757d387fb17086e7b
tree6d10aa52d45ff4061082bca84f48069ccab07e0f
parent449d4e581c6b47621d6a3cfd925fa587c640bee4
BUG/MINOR: http-htx: check the strdup() of the "lf-string" http reply argument

In http_parse_http_reply(), the "lf-string" argument copies its value with
strdup() without checking the result:

obj = strdup(args[cur_arg]);
objlen = strlen(args[cur_arg]);
reply->type = HTTP_REPLY_LOGFMT;

while every sibling argument does check it ("string", and "lf-file" through its
combined "!obj || read(...)" test). <obj> is later handed over to
parse_logformat_string(), which starts with "lf_expr->str = strdup(fmt)", so a
NULL would be passed to strdup() and dereferenced.

This only happens if an allocation fails while parsing the configuration, so the
impact is limited, but the check is missing where all the others are present.

This should be backported to all supported versions.
src/http_htx.c