> - *state = ts.tv_nsec;
> + *state = (intptr_t)&printf ^ time(NULL) ^ (ts.tv_nsec * 0xAC5533CD);
tv_nsec is `long` which is signed. Signed interger overflow is
undefined. You need to cast it to `unsigned long` before multiply:
... ^ ((unsigned long)ts.tv_nsec * 0xAC5533CD)
- NRK
On Mon, Mar 4, 2024 at 5:03 PM Elie Le Vaillant wrote:
>
> Thanks NRK
> ---
> libutil/random.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/libutil/random.c b/libutil/random.c
> index 780ba29..6b795a9 100644
> --- a/libutil/random.c
> +++ b/libutil/random.c
> @@ -1,4