From d6e655ad976c164ed5f814517a82f39d945a0971 Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Wed, 9 Apr 2014 19:07:41 -0700 Subject: [PATCH] A DWORD is the maximum CryptGenRandom() can support. --- src/libsodium/randombytes/sysrandom/randombytes_sysrandom.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/libsodium/randombytes/sysrandom/randombytes_sysrandom.c b/src/libsodium/randombytes/sysrandom/randombytes_sysrandom.c index ff86c0b0..d0e25209 100644 --- a/src/libsodium/randombytes/sysrandom/randombytes_sysrandom.c +++ b/src/libsodium/randombytes/sysrandom/randombytes_sysrandom.c @@ -169,7 +169,9 @@ randombytes_sysrandom_buf(void * const buf, const size_t size) abort(); } #else - // Is cast from size_t to DWORD safe here? + if (size > 0xffffffff) { + abort(); + } if (! CryptGenRandom(stream.hcrypt_prov, (DWORD) size, (BYTE *) buf)) { abort(); }