]> git.ipfire.org Git - thirdparty/glibc.git/commit
Fix signed integer overflow in random_r (bug 17343).
authorJoseph Myers <joseph@codesourcery.com>
Thu, 17 May 2018 12:04:58 +0000 (14:04 +0200)
committerFlorian Weimer <fweimer@redhat.com>
Thu, 17 May 2018 12:04:58 +0000 (14:04 +0200)
commit02f0dd83a4abf190f13eef8d70811a7c8ec896ad
tree07d3d11f0bf0bf4540ea3e72e19f475e95537bc3
parent3241353ab20b4cc8798088d456ffa9aace1514de
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.

(cherry picked from commit 8a07b0c43c46a480da070efd53a2720195e2256f)
ChangeLog
NEWS
stdlib/random_r.c