NetBSD/common/lib
fox 819b6be2db common/lib/libc/stdlib: Fix possible signed integer overflow.
common/lib/libc/stdlib/random.c:482:6 can result in signed integer overflow.

This bug was reported by UBSan runs.

The change has been tested using the following program to generate random numbers
in both the old and the new library and can be used to verify the correctness of the
library after the change.

#include <stdio.h>
#include <stdlib.h>

#define COUNT 1000 * 1000

int
main(void)
{
        int i;
        FILE *fp = fopen("numbers.txt", "w");

        srandom(0xdeadbeef);

        for(i = 0; i < COUNT; i++) {
                fprintf(fp, "%ld\n", random());
        }

        fclose(fp);

        return 0;
}

Reviewed by: riastradh@ , kamil@
2020-02-22 14:47:29 +00:00
..
libc common/lib/libc/stdlib: Fix possible signed integer overflow. 2020-02-22 14:47:29 +00:00
libppath Simplify, and comment out xrefs to non-existing pages. 2017-10-23 00:59:44 +00:00
libprop Use posix_madvise() rather than the legacy madvise() call, and 2019-05-08 04:34:33 +00:00
libutil Trailing whitespace 2020-01-06 13:21:18 +00:00
libx86emu