Skip to content

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

Merged
jiegec merged 1 commit into
masterfrom
fix-off-by-two-in-printinaddr
Jul 17, 2026
Merged

fix: off-by-two in printinaddr remaining-length accounting#366
jiegec merged 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
@jiegec
jiegec merged commit 0bd6985 into master Jul 17, 2026
17 checks passed
@jiegec
jiegec deleted the fix-off-by-two-in-printinaddr branch July 17, 2026 15:12
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