]> git.kaiwu.me - haproxy.git/commitdiff
BUG/MINOR: spoe: Fix the message list splice with an empty list
authorChristopher Faulet <cfaulet@haproxy.com>
Wed, 7 Oct 2026 19:18:29 +0000 (21:18 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 9 Oct 2026 14:17:35 +0000 (16:17 +0200)
At the end of the parsing of a SPOE agent configuration file, the messages
of the file are moved to the agent message list with a manual splice.
However, this is only correct when the file defines at least one
"spoe-message" section. With an empty list, the manual splice will corrupt
the agent message list.

Replace the manual splice with LIST_SPLICE(), which does nothing with an
empty source list. This fixes the bug and this avoids to deal with list
pointers manually.

The regression was introduced by the commit 11610f3 ("MEDIUM: spoe: Parse
new "spoe-group" section in SPOE config file").

The patch must be backported to all supported versions.

src/flt_spoe.c

index 8a3c0c545739636c86e328834a77aec1bd310852..64a330089b3629f8f2bf1d0c940fce2ce28d904d 100644 (file)
@@ -2583,9 +2583,7 @@ static int parse_spoe_flt(char **args, int *cur_arg, struct proxy *px,
 
  finish:
        /* move curmsgs to the agent message list */
-       curmsgs.n->p = &curagent->messages;
-       curmsgs.p->n = &curagent->messages;
-       curagent->messages = curmsgs;
+       LIST_SPLICE(&curagent->messages, &curmsgs);
        LIST_INIT(&curmsgs);
 
        conf->id    = strdup(engine ? engine : curagent->id);