Skip to content

ndp: validate PREF64 lifetimes before narrowing - #34

Open
omrzk wants to merge 1 commit into
mdlayher:mainfrom
omrzk:fix-pref64-lifetime-range
Open

omrzk wants to merge 1 commit into
mdlayher:mainfrom
omrzk:fix-pref64-lifetime-range

Conversation

@omrzk

@omrzk omrzk commented Oct 25, 2026

Copy link
Copy Markdown

PREF64 lifetime validation currently narrows the scaled value to uint16 before checking its 13-bit range. A lifetime of 524288 seconds wraps to zero, which advertises withdrawal of the NAT64 prefix; other oversized values can wrap to a plausible positive lifetime. A small negative duration also rounds to zero and is accepted.

Validate negative durations and the rounded scaled value before conversion. Existing eight-second rounding, zero lifetime, and the maximum encoded lifetime remain supported.

Validation: go test -p 2 -race -tags gofuzz -count=1 ./..., go vet -p 2 ./..., and staticcheck ./... pass. The new tests fail against the original implementation for negative and wrapped lifetimes; they also cover zero, the maximum, and both sides of the rounding boundary. These are marshal/unmarshal fixture tests.

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.

1 participant