lib: avoid overflow in computation of s_seq_expect

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.

https://github.com/thom311/libnl/pull/438
1 file changed