]> git.ipfire.org Git - thirdparty/glibc.git/commit
stdlib: random_r: fix unaligned access in initstate and initstate_r [BZ #30584]
authorSam James <sam@gentoo.org>
Tue, 10 Dec 2024 01:21:46 +0000 (01:21 +0000)
committerSam James <sam@gentoo.org>
Thu, 2 Jan 2025 16:47:51 +0000 (16:47 +0000)
commitd5bceac99d24af1131b90027dab267e437b65cd1
tree6fb637f76ac3a727c3050af608c9701134075fc6
parent6f0ea84f17581d13ad668adbc181c37141d389b8
stdlib: random_r: fix unaligned access in initstate and initstate_r [BZ #30584]

The initstate{,_r} interfaces are documented in BSD as needing an aligned
array of 32-bit values, but neither POSIX nor glibc's own documentation
require it to be aligned. glibc's documentation says it "should" be a power
of 2, but not must.

Use memcpy to read and write to `state` to handle such an unaligned
argument.

Co-authored-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Reviewed-by: Florian Weimer <fweimer@redhat.com>
stdlib/Makefile
stdlib/random_r.c
stdlib/tst-random-bz30584.c [new file with mode: 0644]