Skip to content

parser_syslog: do not skip unmatched header fields in the RFC 5424 re… - #5643

Closed
Shriraj1901 wants to merge 1 commit into
fluent:masterfrom
Shriraj1901:fix-syslog-rfc5424-regexp-anchor
Closed

Shriraj1901 wants to merge 1 commit into
fluent:masterfrom
Shriraj1901:fix-syslog-rfc5424-regexp-anchor

Conversation

@Shriraj1901

Copy link
Copy Markdown

…gexp parser

parse_plain calls re.match(text, idx), but Regexp#match with a position only starts searching there; it does not anchor the match. When the host, ident, pid, msgid or structured data at idx did not match, the regexp engine could match further on in the text, so the record got values from the wrong place and the text in between was dropped without any warning.

For example, a hostname with a non-ASCII character returned "st" as the host, and a header split by a line break returned the second line's fields as the record.

Anchor the RFC 5424 regexp with \G so that a header that does not match at idx is reported as not matched.

Fixes #5630

Which issue(s) this PR fixes:
Fixes #

What this PR does / why we need it:

Docs Changes:

Release Note:

…gexp parser

parse_plain calls re.match(text, idx), but Regexp#match with a position
only starts searching there; it does not anchor the match. When the host,
ident, pid, msgid or structured data at idx did not match, the regexp
engine could match further on in the text, so the record got values from
the wrong place and the text in between was dropped without any warning.

For example, a hostname with a non-ASCII character returned "st" as the
host, and a header split by a line break returned the second line's
fields as the record.

Anchor the RFC 5424 regexp with \G so that a header that does not match
at idx is reported as not matched.

Fixes fluent#5630

Signed-off-by: shreeraj <shreerajjadhav19@gmail.com>
@Watson1978

Copy link
Copy Markdown
Contributor

Thank you for working on this. #5641 was opened a few hours earlier for the same issue, with the same change to the regexp and the same test inputs, so I'm closing this one as a duplicate. Sorry about the overlap.

@Watson1978 Watson1978 closed this Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

parser_syslog: the regexp engine for RFC 5424 can match the header later in the message and corrupt the record

2 participants