Skip to content

fix: off-by-two in printinaddr remaining-length accounting#366

Open
jiegec wants to merge 1 commit into
masterfrom
fix-off-by-two-in-printinaddr
Open

fix: off-by-two in printinaddr remaining-length accounting#366
jiegec wants to merge 1 commit into
masterfrom
fix-off-by-two-in-printinaddr

Conversation

@jiegec

@jiegec jiegec commented Jul 13, 2026

Copy link
Copy Markdown
Member

In printinaddr(), the remaining-length counter nl was decremented by len - 1 instead of len + 1 after writing ":" + port string (len + 1 bytes). This inflates nl by 2 after each port field, allowing the final snpf() to write 2 bytes past the end of the heap-allocated Namech buffer.

Reported-by: f9j2n6nd8k-eng
Fixes #365

In printinaddr(), the remaining-length counter nl was decremented by
len - 1 instead of len + 1 after writing ":" + port string (len + 1
bytes). This inflated nl by 2 after each port field, allowing the final
snpf() to write 2 bytes past the end of the heap-allocated Namech buffer.

Reported-by: f9j2n6nd8k-eng
Fixes #365
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.

[BUG]off-by-two in printinaddr() remaining-length accounting

1 participant