fix off-by-one truncation detection in VADoRawLog and DoRawLog - #2125
Open
nabhan06 wants to merge 2 commits into
Open
fix off-by-one truncation detection in VADoRawLog and DoRawLog#2125nabhan06 wants to merge 2 commits into
nabhan06 wants to merge 2 commits into
Conversation
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. |
Contributor
There was a problem hiding this comment.
This comment is describing the old buggy state, and isn't particularly useful. I'd just delete the whole thing
Contributor
Author
There was a problem hiding this comment.
Good call, dropped it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.