Skip to content

Commit 3be9118

Browse files
crrodriguezdevnexen
authored andcommitted
random: whitelist arc4random_buf if glibc
Glibc will soon implement the BSD arc4random API. whitelist its implementation as safe. Closes #8984.
1 parent 2673c1d commit 3be9118

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

NEWS

+2
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ PHP NEWS
3232
. Fixed empty array returned by str_split on empty input. (Michael Vorisek)
3333
. Added ini_parse_quantity function to convert ini quantities shorthand
3434
notation to int. (Dennis Snell)
35+
. Enable arc4random_buf for Linux glibc 2.36 and onwards
36+
for the random_bytes. (Cristian Rodriguez)
3537

3638
07 Jul 2022, PHP 8.2.0alpha3
3739

ext/standard/random.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ PHPAPI int php_random_bytes(void *bytes, size_t size, bool should_throw)
9494
}
9595
return FAILURE;
9696
}
97-
#elif HAVE_DECL_ARC4RANDOM_BUF && ((defined(__OpenBSD__) && OpenBSD >= 201405) || (defined(__NetBSD__) && __NetBSD_Version__ >= 700000001) || defined(__APPLE__))
97+
#elif HAVE_DECL_ARC4RANDOM_BUF && ((defined(__OpenBSD__) && OpenBSD >= 201405) || (defined(__NetBSD__) && __NetBSD_Version__ >= 700000001) || defined(__APPLE__) || defined(__GLIBC__))
9898
arc4random_buf(bytes, size);
9999
#else
100100
size_t read_bytes = 0;

0 commit comments

Comments
 (0)