Skip to content

Conversation

@cferris1000
Copy link
Contributor

On some systems, the clock is reset, or is lost, so the value returned by the time function can be a very small value. In that case, the _badrandom_from_time functions returns a large value close to the maximum unsigned int value for s_seq_expect. This can lead to the value wrapping around fairly quickly.

When compiling the library with the unsigned-integer-overflow sanitizer enabled, this causes an abort.

Detect this potential wrap around condition and avoid it.

On some systems, the clock is reset, or is lost, so the value returned
by the time function can be a very small value. In that case, the
_badrandom_from_time functions returns a large value close to the
maximum unsigned int value for s_seq_expect. This can lead to the value
wrapping around fairly quickly.

When compiling the library with the unsigned-integer-overflow sanitizer
enabled, this causes an abort.

Detect this potential wrap around condition and avoid it.
@thom311
Copy link
Owner

thom311 commented Jul 31, 2025

Unsigned overflow is explicitly supported and fine in C. And obviously, the overflow here is not an accident or unintentional.

It seems to me that this sanitizer is a bit too strict. Can you even enable it on a non-trivial code base? Isn't unsigned overflow a common thing (that often enough happens intentionally)?

Anyway. Will merge. Thank you.

thom311 pushed a commit that referenced this pull request Jul 31, 2025
On some systems, the clock is reset, or is lost, so the value returned
by the time function can be a very small value. In that case, the
_badrandom_from_time functions returns a large value close to the
maximum unsigned int value for s_seq_expect. This can lead to the value
wrapping around fairly quickly.

When compiling the library with the unsigned-integer-overflow sanitizer
enabled, this causes an abort.

Detect this potential wrap around condition and avoid it.

#438
@thom311 thom311 closed this Jul 31, 2025
@cferris1000 cferris1000 deleted the sanitize_overflow branch July 31, 2025 21:15
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