NetBSD/common
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
..
dist/zlib Restore a local change (in rev1.4) that was lost on zlib 1.12.10 merge. 2017-11-12 07:55:05 +00:00
include get rid of caddr_t 2019-06-16 16:01:44 +00:00
lib common/lib/libc/stdlib: Fix possible signed integer overflow. 2020-02-22 14:47:29 +00:00