BUG/MINOR: hbuf: treat unexpected escape sequences as literals

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.
This commit is contained in:
Frederic Lecaille 2026-07-08 08:24:19 +02:00
parent 1e1e780b79
commit ff95f204ec

View 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++;
}