From bbcb8bd33b822ea00e0c8a0b582b3ea4e8570974 Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Sun, 12 Mar 2017 18:02:46 +0100 Subject: [PATCH] Avoid useless comparisons --- .../randombytes/salsa20/randombytes_salsa20_random.c | 4 +++- src/libsodium/randombytes/sysrandom/randombytes_sysrandom.c | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/libsodium/randombytes/salsa20/randombytes_salsa20_random.c b/src/libsodium/randombytes/salsa20/randombytes_salsa20_random.c index fa2268e1..a2261952 100644 --- a/src/libsodium/randombytes/salsa20/randombytes_salsa20_random.c +++ b/src/libsodium/randombytes/salsa20/randombytes_salsa20_random.c @@ -422,9 +422,11 @@ randombytes_salsa20_random_buf(void * const buf, const size_t size) randombytes_salsa20_random_stir_if_needed(); COMPILER_ASSERT(sizeof stream.nonce == crypto_stream_salsa20_NONCEBYTES); -#ifdef ULONG_LONG_MAX +#if defined(ULONG_LONG_MAX) && defined(SIZE_MAX) +# if SIZE_MAX > ULONG_LONG_MAX /* coverity[result_independent_of_operands] */ assert(size <= ULONG_LONG_MAX); +# endif #endif ret = crypto_stream_salsa20((unsigned char *) buf, (unsigned long long) size, (unsigned char *) &stream.nonce, stream.key); diff --git a/src/libsodium/randombytes/sysrandom/randombytes_sysrandom.c b/src/libsodium/randombytes/sysrandom/randombytes_sysrandom.c index 41b95b95..feede465 100644 --- a/src/libsodium/randombytes/sysrandom/randombytes_sysrandom.c +++ b/src/libsodium/randombytes/sysrandom/randombytes_sysrandom.c @@ -313,9 +313,11 @@ static void randombytes_sysrandom_buf(void * const buf, const size_t size) { randombytes_sysrandom_stir_if_needed(); -#ifdef ULONG_LONG_MAX +#if defined(ULONG_LONG_MAX) && defined(SIZE_MAX) +# if SIZE_MAX > ULONG_LONG_MAX /* coverity[result_independent_of_operands] */ assert(size <= ULONG_LONG_MAX); +# endif #endif #ifndef _WIN32 # if defined(SYS_getrandom) && defined(__NR_getrandom)