aboutsummaryrefslogtreecommitdiff
path: root/newlib/libc/stdlib/arc4random.c
diff options
context:
space:
mode:
authorJan Dubiec <jdx@o2.pl>2025-03-03 01:15:44 +0100
committerCorinna Vinschen <corinna@vinschen.de>2025-03-03 11:45:36 +0100
commit53483eddbce70247a28a9d41dd33e2c559925ed4 (patch)
tree7a1857a4569c26b3bf2aa305f6de46b2e15d54c3 /newlib/libc/stdlib/arc4random.c
parent7962e3b26e5d6e8a1228baa63350321c8d9f31de (diff)
downloadnewlib-53483eddbce70247a28a9d41dd33e2c559925ed4.zip
newlib-53483eddbce70247a28a9d41dd33e2c559925ed4.tar.gz
newlib-53483eddbce70247a28a9d41dd33e2c559925ed4.tar.bz2
Silence -Woverflow warning in arc4random.c
This patch fixes "integer overflow" warning in arc4random.c. It explicitly casts REKEY_BASE macro to size_t. The existing code relies on an implicit conversion to int and assumes that sizeof(int)=sizeof(size_t), which is not always true. 2025-03-02 Jan Dubiec <jdx@o2.pl> newlib/ChangeLog: * libc/stdlib/arc4random.c (REKEY_BASE): Explicitly cast the macro to size_t. newlib/libc/stdlib/arc4random.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
Diffstat (limited to 'newlib/libc/stdlib/arc4random.c')
-rw-r--r--newlib/libc/stdlib/arc4random.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/newlib/libc/stdlib/arc4random.c b/newlib/libc/stdlib/arc4random.c
index 09a134c..bc59678 100644
--- a/newlib/libc/stdlib/arc4random.c
+++ b/newlib/libc/stdlib/arc4random.c
@@ -50,11 +50,11 @@
#define RSBUFSZ (16*BLOCKSZ)
#if SIZE_MAX <= 65535
-#define REKEY_BASE ( 32*1024) /* NB. should be a power of 2 */
+#define REKEY_BASE ( (size_t)32*1024) /* NB. should be a power of 2 */
#elif SIZE_MAX <= 1048575
-#define REKEY_BASE ( 512*1024) /* NB. should be a power of 2 */
+#define REKEY_BASE ( (size_t)512*1024) /* NB. should be a power of 2 */
#else
-#define REKEY_BASE (1024*1024) /* NB. should be a power of 2 */
+#define REKEY_BASE ((size_t)1024*1024) /* NB. should be a power of 2 */
#endif
/* Marked MAP_INHERIT_ZERO, so zero'd out in fork children. */