]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: spoe: Properly detect and skip empty NOTIFY frames
authorChristopher Faulet <cfaulet@haproxy.com>
Wed, 20 Aug 2025 13:38:42 +0000 (15:38 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 20 Aug 2025 14:01:50 +0000 (16:01 +0200)
Since the SPOE was refactored, the detection of empty NOTIFY frames is
broken. So it is possible to send a NOTIFY frames to an agent with no
message at all. The bug happens because the frame type is now added to the
buffer before the messages encoding. So the buffer is never really empty.

To fix the issue, the condition to detect empty frame was adapted.

This patch must be backported as far as 3.1.

src/flt_spoe.c

index 8eb2681a0fb6ba4fef2ab09a353ab0e3c28fd39b..371037129bea56198b065db819d8daf97f0af657 100644 (file)
@@ -647,13 +647,14 @@ static int spoe_encode_messages(struct stream *s, struct spoe_context *ctx,
        struct spoe_config  *conf = FLT_CONF(ctx->filter);
        struct spoe_agent   *agent = conf->agent;
        struct spoe_message *msg;
-       char   *p, *end;
+       char   *p, *start, *end;
 
        p   = b_head(&ctx->buffer);
        end =  p + agent->max_frame_size - SPOP_FRAME_HDR_SIZE;
 
        /* Set Frame type */
        *p++ = SPOP_FRM_T_HAPROXY_NOTIFY;
+       start = p;
 
        if (type == SPOE_MSGS_BY_EVENT) { /* Loop on messages by event */
                list_for_each_entry(msg, messages, by_evt) {
@@ -673,7 +674,7 @@ static int spoe_encode_messages(struct stream *s, struct spoe_context *ctx,
 
 
        /* nothing has been encoded */
-       if (p == b_head(&ctx->buffer))
+       if (p == start)
                goto skip;
 
        b_set_data(&ctx->buffer, p - b_head(&ctx->buffer));