Skip to content

Reject undersized SyslogAppender MaxMessageLength values#657

Merged
swebb2066 merged 1 commit into
apache:masterfrom
metsw24-max:syslogappender-maxmessagelength-validation
May 10, 2026
Merged

Reject undersized SyslogAppender MaxMessageLength values#657
swebb2066 merged 1 commit into
apache:masterfrom
metsw24-max:syslogappender-maxmessagelength-validation

Conversation

@metsw24-max
Copy link
Copy Markdown
Contributor

The append() splitting loop computes chunk-end iterators as start + maxMessageLength - 12 to reserve space for an "(x/y)" sequence suffix. With maxMessageLength == 12 the chunk size is zero and the loop never advances, growing the packets vector indefinitely. Smaller positive values walk the iterator before msg.begin() before constructing LogString(start, end) with start > end (undefined behaviour).

Validate the value in setMaxMessageLength so the public setter and the setOption("MaxMessageLength", ...) configuration path both fall back to the documented default when the configured value cannot satisfy the suffix-reservation arithmetic.

Changes

  • Added validation in SyslogAppender::setMaxMessageLength()
  • Values < 13 now fall back to the documented default value (1024)
  • Added a warning when invalid values are supplied
  • Both the public setter and the setOption("MAXMESSAGELENGTH", ...) configuration path now share the same validation logic
    Tests Added

Added tests covering:

  • boundary value 12
  • negative values
  • setOption("MAXMESSAGELENGTH", "5")
  • regression test ensuring valid values (2048) remain unchanged

The append() splitting loop computes chunk-end iterators as
start + maxMessageLength - 12 to reserve space for an "(x/y)" sequence
suffix. With maxMessageLength == 12 the chunk size is zero and the loop
never advances, growing the packets vector indefinitely. Smaller
positive values walk the iterator before msg.begin() before constructing
LogString(start, end) with start > end (undefined behaviour).

Validate the value in setMaxMessageLength so the public setter and the
setOption("MaxMessageLength", ...) configuration path both fall back to
the documented default when the configured value cannot satisfy the
suffix-reservation arithmetic.
@metsw24-max metsw24-max force-pushed the syslogappender-maxmessagelength-validation branch from 9102632 to e981dc8 Compare May 9, 2026 16:48
@swebb2066 swebb2066 merged commit d254334 into apache:master May 10, 2026
17 checks passed
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.

2 participants