]> granicus.if.org Git - json-c/commit
Prevent signed overflow in get_time_seed
authorTobias Stoeckmann <tobias@stoeckmann.org>
Sat, 22 Aug 2020 11:23:23 +0000 (13:23 +0200)
committerTobias Stoeckmann <tobias@stoeckmann.org>
Sat, 22 Aug 2020 11:25:21 +0000 (13:25 +0200)
commitdf62119b7f11dbd97715668a6311410f67bea3c9
tree882356bcae222309fe213bac80d490c78b4cb72e
parent2b439ea59857747067e8272011ad67303e0d4cf1
Prevent signed overflow in get_time_seed

Casting time(2) return value to int and multiplying the result with
such a constant will definitely lead to a signed overflow by this day.

Since signed overflows are undefined behaviour in C, avoid this.

Casting to unsigned is more than enough since the upper bits of a
64 bit time_t value will be removed with the int conversion anyway.
random_seed.c