From: Willy Tarreau Date: Tue, 10 Sep 2024 06:55:29 +0000 (+0200) Subject: BUG/MINOR: pattern: do not leave a leading comma on "set" error messages X-Git-Tag: v3.0.5~16 X-Git-Url: http://git.haproxy.org/?a=commitdiff_plain;h=6cae9b3ead0af8c751e9ed1e160432ae4a8773c6;p=haproxy-3.0.git BUG/MINOR: pattern: do not leave a leading comma on "set" error messages Commit 4f2493f355 ("BUG/MINOR: pattern: pat_ref_set: fix UAF reported by coverity") dropped the condition to concatenate error messages and as such introduced a leading comma in front of all of them. Then commit 911f4d93d4 ("BUG/MINOR: pattern: pat_ref_set: return 0 if err was found") changed the behavior to stop at the first error anyway, so all the mechanics dedicated to the concatenation of error messages is no longer needed and we can simply return the error as-is, without inserting any comma. This should be backported where the patches above are backported. (cherry picked from commit 9f8d9c9e8bdef8e7b8f7d1d641987b4d0dcae988) Signed-off-by: Willy Tarreau --- diff --git a/src/pattern.c b/src/pattern.c index e2fb5c3..2d0c888 100644 --- a/src/pattern.c +++ b/src/pattern.c @@ -1797,8 +1797,10 @@ int pat_ref_set(struct pat_ref *ref, const char *key, const char *value, char ** elt = ebmb_entry(node, struct pat_ref_elt, node); node = ebmb_next_dup(node); if (!pat_ref_set_elt(ref, elt, value, &tmp_err)) { - memprintf(err, "%s, %s", err && *err ? *err : "", tmp_err); - ha_free(&tmp_err); + if (err) + *err = tmp_err; + else + ha_free(&tmp_err); return 0; } found = 1;