glibc/stdlib
Joseph Myers 8a07b0c43c Fix signed integer overflow in random_r (bug 17343).
Bug 17343 reports that stdlib/random_r.c has code with undefined
behavior because of signed integer overflow on int32_t.  This patch
changes the code so that the possibly overflowing computations use
unsigned arithmetic instead.

Note that the bug report refers to "Most code" in that file.  The
places changed in this patch are the only ones I found where I think
such overflow can occur.

Tested for x86_64 and x86.

	[BZ #17343]
	* stdlib/random_r.c (__random_r): Use unsigned arithmetic for
	possibly overflowing computations.
2018-03-20 18:25:24 +00:00
..
bits
sys
Depend
Makefile Separate out error_t definition 2018-03-04 17:27:58 +01:00
Versions
a64l.c
abort.c
abs.c
add_n.c
addmul_1.c
alloca.h
at_quick_exit.c
atexit.c
atof.c
atoi.c Use libc_hidden_* for atoi (bug 15105). 2018-02-26 18:17:47 +00:00
atol.c
atoll.c
bsearch.c
bug-fmtmsg1.c
bug-getcontext.c
bug-strtod.c
bug-strtod2.c
canonicalize.c
cmp.c
cxa_at_quick_exit.c
cxa_atexit.c
cxa_finalize.c
cxa_thread_atexit_impl.c
dbl2mpn.c
div.c
divmod_1.c
divrem.c
drand48-iter.c
drand48.c
drand48_r.c
erand48.c
erand48_r.c
errno.h Separate out error_t definition 2018-03-04 17:27:58 +01:00
exit.c
exit.h
fmtmsg.c
fmtmsg.h
fpioconst.c
fpioconst.h
gen-fpioconst.c
gen-tst-strtod-round.c
getcontext.c
getentropy.c
getenv.c
getrandom.c
getsubopt.c
gmp-impl.h
gmp.h
grouping.c
grouping.h
groupingwc.c
inlines.c
isomac.c
jrand48.c
jrand48_r.c
l64a.c
labs.c
lcong48.c
lcong48_r.c
ldbl2mpn.c
ldiv.c
llabs.c
lldiv.c
longlong.h
lrand48.c
lrand48_r.c
lshift.c
makecontext.c
mblen.c
mbstowcs.c
mbtowc.c
mod_1.c
monetary.h
mp_clz_tab.c
mpn2dbl.c
mpn2flt.c
mpn2ldbl.c
mrand48.c
mrand48_r.c
msort.c
mul.c
mul_1.c
mul_n.c
nrand48.c
nrand48_r.c
old_atexit.c
on_exit.c
putenv.c
qsort.c
quick_exit.c
rand.c
rand_r.c
random.c
random_r.c Fix signed integer overflow in random_r (bug 17343). 2018-03-20 18:25:24 +00:00
rpmatch.c
rshift.c
secure-getenv.c
seed48.c
seed48_r.c
setcontext.c
setenv.c
srand48.c
srand48_r.c
stdlib.h
strfmon.c
strfmon_l.c
strfrom-skeleton.c
strfromd.c
strfromf.c
strfroml.c
strtod.c
strtod_l.c
strtod_nan.c
strtod_nan_double.h
strtod_nan_float.h
strtod_nan_main.c
strtod_nan_narrow.h
strtod_nan_wide.h
strtof.c
strtof_l.c
strtof_nan.c
strtoimax.c
strtol.c
strtol_l.c
strtold.c
strtold_l.c
strtold_nan.c
strtoll.c
strtoll_l.c
strtoul.c
strtoul_l.c
strtoull.c
strtoull_l.c
strtoumax.c
sub_n.c
submul_1.c
swapcontext.c
system.c
tens_in_limb.c
test-a64l.c
test-at_quick_exit-race.c
test-atexit-race-common.c hurd: Fix build 2018-02-04 14:02:36 +01:00
test-atexit-race.c
test-canon.c
test-canon2.c
test-cxa_atexit-race.c
test-dlclose-exit-race-helper.c
test-dlclose-exit-race.c
test-on_exit-race.c
testdiv.c
testdiv.input
testmb.c
testmb2.c
testrand.c
testsort.c
tst-at_quick_exit.c
tst-atexit-common.c
tst-atexit.c
tst-atof1.c
tst-atof2.c
tst-bsearch.c
tst-cxa_atexit.c
tst-empty-env.c
tst-environ.c
tst-fmtmsg.c
tst-fmtmsg.sh
tst-getrandom.c
tst-limits.c
tst-makecontext-align.c i386: In makecontext, align the stack before calling exit [BZ #22667] 2018-01-04 18:47:35 +01:00
tst-makecontext.c
tst-makecontext2.c
tst-makecontext3.c
tst-on_exit.c
tst-putenv.c
tst-putenvmod.c
tst-qsort.c
tst-qsort2.c
tst-quick_exit.cc
tst-rand48-2.c
tst-rand48.c
tst-random.c
tst-random2.c
tst-secure-getenv.c
tst-setcontext.c
tst-setcontext2.c
tst-setcontext3.c
tst-setcontext3.sh
tst-strfmon_l.c
tst-strfrom-locale.c
tst-strfrom.c
tst-strfrom.h
tst-strtod-nan-locale-main.c
tst-strtod-nan-locale.c
tst-strtod-overflow.c
tst-strtod-round-data
tst-strtod-round-data.h
tst-strtod-round-skeleton.c
tst-strtod-round.c
tst-strtod-underflow.c
tst-strtod.c
tst-strtod.h
tst-strtod1i.c
tst-strtod2.c
tst-strtod3.c
tst-strtod4.c
tst-strtod5.c
tst-strtod5i.c
tst-strtod6.c
tst-strtol-locale-main.c
tst-strtol-locale.c
tst-strtol.c
tst-strtoll.c
tst-system.c
tst-thread-quick_exit.cc
tst-tininess.c
tst-tls-atexit-lib.c
tst-tls-atexit-nodelete.c
tst-tls-atexit.c
tst-unsetenv1.c
tst-width-stdint.c
tst-width.c
tst-xpg-basename.c
ucontext.h
udiv_qrnnd.c
wcstoimax.c
wcstombs.c
wcstoumax.c
wctomb.c
xpg_basename.c