libnl
libnl copied to clipboard
lib: adjust small time values in _badrandom_from_time
On some systems, the clock is reset, or is lost, so the value returned by time can be a very small value. In that case, the _badrandom_from_time function returns a large value close to the maximum uint32_t value. This can be a problem when used to create a sequence number and that number overflows the uint32_t maximum value when it is incremented.
In this case, detect when the time value is too small, and add a value to make sure the value returned is not too close to the uint32_t maximum value.