Skip to content

fix off-by-one truncation detection in VADoRawLog and DoRawLog - #2125

Open
nabhan06 wants to merge 2 commits into
abseil:masterfrom
nabhan06:raw-log-truncation-off-by-one
Open

fix off-by-one truncation detection in VADoRawLog and DoRawLog#2125
nabhan06 wants to merge 2 commits into
abseil:masterfrom
nabhan06:raw-log-truncation-off-by-one

Conversation

@nabhan06

Copy link
Copy Markdown
Contributor

treat n == size as truncation in VADoRawLog and DoRawLog: vsnprintf writes only size-1 chars at that boundary, so an exactly-buffer-filling raw log message was losing its last byte and being emitted without the (message truncated) marker or trailing newline, letting a following line concatenate onto it.

Comment thread absl/base/raw_logging_test.cc Outdated
Comment on lines +77 to +83
// A message whose formatted length exactly equals the remaining buffer size is
// still truncated: vsnprintf() only writes size-1 characters plus the NUL, so
// truncation must be detected when the would-be length is >= the size, not only
// when it is strictly greater. With the off-by-one, such a message loses its
// final character and is emitted without the "(message truncated)" marker (and
// without the trailing newline). A custom zero-length prefix hook makes the
// whole raw-log buffer available so the boundary is hit deterministically.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment is describing the old buggy state, and isn't particularly useful. I'd just delete the whole thing

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call, dropped it.

@mkruskal-google mkruskal-google self-assigned this Aug 12, 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.

2 participants