Skip to content

ndp: reject router advertisement durations that do not fit - #33

Merged
mdlayher merged 1 commit into
mdlayher:mainfrom
SashaMIT:fix/ra-duration-range
Oct 16, 2026
Merged

mdlayher merged 1 commit into
mdlayher:mainfrom
SashaMIT:fix/ra-duration-range

Conversation

@SashaMIT

@SashaMIT SashaMIT commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Router advertisement marshal wrote RouterLifetime, ReachableTime, and RetransmitTimer with a narrowing cast. 65536 seconds became a uint16 of 0. RFC 4861 treats a lifetime of 0 as not a default router. A negative lifetime wrapped to a large positive value. Reachable time and the retransmit timer wrapped past 32 bits the same way.

Marshal now returns an error when a value does not fit. Zero and 65535 seconds still marshal, and sub-second truncation is unchanged.

go test -count=1 . passes. With the range checks disabled, the four new cases fail with "expected an error, but none occurred."

A lifetime of 65536 seconds wrapped to a uint16 of 0, which means the
router is not a default router. Reachable and retransmit times wrapped
the same way. Marshal now returns an error instead.

Signed-off-by: Sasha Mitchell <sash.t.mitchell@gmail.com>
@mdlayher
mdlayher merged commit 5dfd243 into mdlayher:main Oct 16, 2026
3 checks passed
@SashaMIT

Copy link
Copy Markdown
Contributor Author

Thanks for the merge.

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