Skip to content

Fix overflow in from_timeval - #690

Open
pederbe wants to merge 1 commit into
rust-lang:masterfrom
pederbe:fix/from-timeval-overflow
Open

pederbe wants to merge 1 commit into
rust-lang:masterfrom
pederbe:fix/from-timeval-overflow

Conversation

@pederbe

@pederbe pederbe commented Nov 16, 2026

Copy link
Copy Markdown

Normalise the microsecond field before converting it to nanoseconds so large non-normalised values do not overflow or lose high bits. Keep from_timeval const and preserve the zero timeout None result.

The new internal tests reproduce the debug panic and incorrect release result with the old conversion and cover the overflow boundary and maximum nonnegative fields.

Fixes #685.

@pederbe
pederbe marked this pull request as ready for review November 16, 2026 07:05

This branch has not been deployed

No deployments
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.

from_timeval overflows on a non-normalised tv_usec

1 participant