Repository navigation
sudoreplay: write output records larger than the I/O buffer - #565
Merged
Merged
Conversation
write_output() moved on to the next timing record as soon as the 64KB I/O buffer was drained, without checking whether the current record still had bytes left to read. A record whose size exceeds the buffer was truncated and the rest of the session was then read from the wrong offset. Reset the buffer and finish the record before advancing.
millert
approved these changes
Oct 17, 2026
millert
left a comment
Collaborator
There was a problem hiding this comment.
Thanks, sudo won't currently create an I/O buffer larger than 64KiB, but sudoreplay should be able to handle it if that changes.
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.
write_output() advances to the next timing record as soon as the 64KB I/O buffer is drained (off == len), without checking whether the current record still has bytes left to read (iobuf.toread). A record whose byte count is larger than the buffer is truncated to 65536 bytes, and because get_timing_record() then runs with the data file positioned in the middle of the record, every following record is read from the wrong offset and replays as garbage. sudo caps each locally logged record at the 64KB I/O buffer, but sudo_logsrvd writes one record per client IoBuffer, so a log collected from a client that sends a buffer larger than 64KB hits this.
Reset the buffer and reschedule the output event to finish the current record before moving on to the next timing entry. Keeping the check next to the existing off == len handling leaves the common case where a record fits in the buffer unchanged.
Reproduced with a session whose ttyout record is 100000 bytes: before, sudoreplay writes 65536 bytes and drops the remaining 34464 (and a following record then reads from the wrong offset); after, all 100000 bytes replay. A record of exactly 65536 bytes and smaller records are unaffected.