Skip to content

sudoreplay: stash the last byte written, not the one after it - #563

Merged
millert merged 1 commit into
sudo-project:mainfrom
iefa-m:write-output-lastc-offset
Oct 12, 2026
Merged

millert merged 1 commit into
sudo-project:mainfrom
iefa-m:write-output-lastc-offset

Conversation

@iefa-m

@iefa-m iefa-m commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

Off-by-one reading the last written byte in write_output

After a writev, sudoreplay stashes iobuf->lastc from iov_base + nwritten, but the byte it just wrote ends at nwritten - 1, so this reads one past the written data. When an output record fills the 64 KiB replay buffer and is written in full that address is iobuf->buf[65536], which is the io_buffer trailing padding on LP64 but one byte past the allocation on ILP32 where that struct has no padding; switched it to nwritten - 1 to match how a last byte is stashed elsewhere in the tree.

@millert millert left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks correct, thanks!

@millert
millert merged commit c1316db into sudo-project:main Oct 12, 2026
5 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