diff options
author | ache <ache@FreeBSD.org> | 2013-07-03 21:21:54 +0000 |
---|---|---|
committer | ache <ache@FreeBSD.org> | 2013-07-03 21:21:54 +0000 |
commit | 295fb8ce1a43fcd088b63b8b28a6b34191a4faab (patch) | |
tree | 1741a11f1eb25d7ff1fecb14fab8e90d942fec2b /lib/libc/stdlib/atoi.c | |
parent | 9256efca5e1c834cea4f307b2f9a54f095eb1753 (diff) | |
download | FreeBSD-src-295fb8ce1a43fcd088b63b8b28a6b34191a4faab.zip FreeBSD-src-295fb8ce1a43fcd088b63b8b28a6b34191a4faab.tar.gz |
1) POSIX requires rand(3) return values to be in the [0, RAND_MAX] range,
but ACM formula we use have internal state (and return value) in the
[1, 0x7ffffffe] range, so our RAND_MAX (0x7fffffff) is never reached
because it is off by one, zero is not reached too.
Correct both RAND_MAX and rand(3) return value, shifting last one
to the 0 by 1 subtracted, resulting POSIXed [0, 0x7ffffffd(=new RAND_MAX)]
range.
2) Add a checks for not overflowing on too big seeds. It may happens on
the machines, where sizeof(unsigned int) > 32 bits.
Reviewed by: bde [1]
MFC after: 2 weeks
Diffstat (limited to 'lib/libc/stdlib/atoi.c')
0 files changed, 0 insertions, 0 deletions