]> git.kaiwu.me - haproxy.git/commitdiff
BUG/MINOR: hbuf: treat unexpected escape sequences as literals
authorFrederic Lecaille <flecaille@haproxy.com>
Wed, 8 Jul 2026 06:24:19 +0000 (08:24 +0200)
committerFrederic Lecaille <flecaille@haproxy.com>
Wed, 8 Jul 2026 06:27:49 +0000 (08:27 +0200)
When encountering an unexpected escape sequence, treat it as a literal
character instead of skipping it.

This is a deliberate choice for two reasons:

- to avoid a desynchronization between the h->data counter and the
  buffer content, which would otherwise leave uninitialized memory
  ("garbage") in the destination buffer;

- to ensure that an invalid configuration string triggers a parsing
  error immediately (fail-fast), rather than resulting in a silently
  malformed configuration.

Thank to @dirkmueller for having reported this issue.

No need to backport. huf arrived with this current version.

src/hbuf.c

index 6c16580b126f2a35de94f5d2c31216bcbc3d464b..e15bd85d5f99c47b191835db1dd1318966f7e2bc 100644 (file)
@@ -55,6 +55,10 @@ void hbuf_str_append(struct hbuf *h, const char *line)
                        }
                        else if (*p == 't')
                                *to++ = '\t';
+                       else {
+                               /* unexpected escape sequence, treat as literal */
+                               *to++ = *p;
+                       }
                        p++;
                        h->data++;
                }