diff --git a/src/libsodium/randombytes/salsa20/randombytes_salsa20_random.c b/src/libsodium/randombytes/salsa20/randombytes_salsa20_random.c index b21925dd..2d214721 100644 --- a/src/libsodium/randombytes/salsa20/randombytes_salsa20_random.c +++ b/src/libsodium/randombytes/salsa20/randombytes_salsa20_random.c @@ -359,9 +359,13 @@ randombytes_salsa20_random_stir_unlocked(void) static void randombytes_salsa20_random_stir(void) { - sodium_crit_enter(); + if (sodium_crit_enter() != 0) { + abort(); + } randombytes_salsa20_random_stir_unlocked(); - sodium_crit_leave(); + if (sodium_crit_leave() != 0) { + abort(); + } } static void @@ -385,7 +389,9 @@ randombytes_salsa20_random_close(void) { int ret = -1; - sodium_crit_enter(); + if (sodium_crit_enter() != 0) { + abort(); + } #ifndef _WIN32 if (stream.random_data_source_fd != -1 && close(stream.random_data_source_fd) == 0) { @@ -413,8 +419,9 @@ randombytes_salsa20_random_close(void) ret = 0; } #endif - sodium_crit_leave(); - + if (sodium_crit_leave() != 0) { + abort(); + } return ret; } @@ -424,7 +431,9 @@ randombytes_salsa20_random_buf(void * const buf, const size_t size) size_t i; int ret; - sodium_crit_enter(); + if (sodium_crit_enter() != 0) { + abort(); + } randombytes_salsa20_random_stir_if_needed(); COMPILER_ASSERT(sizeof stream.nonce == crypto_stream_salsa20_NONCEBYTES); #ifdef ULONG_LONG_MAX @@ -440,7 +449,9 @@ randombytes_salsa20_random_buf(void * const buf, const size_t size) stream.nonce++; crypto_stream_salsa20_xor(stream.key, stream.key, sizeof stream.key, (unsigned char *) &stream.nonce, stream.key); - sodium_crit_leave(); + if (sodium_crit_leave() != 0) { + abort(); + } } static uint32_t @@ -449,7 +460,9 @@ randombytes_salsa20_random(void) uint32_t val; int ret; - sodium_crit_enter(); + if (sodium_crit_enter() != 0) { + abort(); + } COMPILER_ASSERT(sizeof stream.rnd32 >= (sizeof stream.key) + (sizeof val)); COMPILER_ASSERT(((sizeof stream.rnd32) - (sizeof stream.key)) % sizeof val == (size_t) 0U); @@ -468,8 +481,9 @@ randombytes_salsa20_random(void) stream.rnd32_outleft -= sizeof val; memcpy(&val, &stream.rnd32[stream.rnd32_outleft], sizeof val); memset(&stream.rnd32[stream.rnd32_outleft], 0, sizeof val); - sodium_crit_leave(); - + if (sodium_crit_leave() != 0) { + abort(); + } return val; }