From 531c51e7a3503e3337136b659d58fd15d92f70ec Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Sat, 2 Apr 2016 01:06:04 +0200 Subject: [PATCH] Stronger types for >= 16 bits shifts --- src/libsodium/crypto_pwhash/argon2/argon2-encoding.c | 2 +- .../nosse/pwhash_scryptsalsa208sha256_nosse.c | 2 +- .../scryptsalsa208sha256/sse/pwhash_scryptsalsa208sha256_sse.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libsodium/crypto_pwhash/argon2/argon2-encoding.c b/src/libsodium/crypto_pwhash/argon2/argon2-encoding.c index 2a55cf31..5b8d6c43 100644 --- a/src/libsodium/crypto_pwhash/argon2/argon2-encoding.c +++ b/src/libsodium/crypto_pwhash/argon2/argon2-encoding.c @@ -180,7 +180,7 @@ static const char *from_base64(void *dst, size_t *dst_len, const char *src) { * otherwise, only 0, 2 or 4 bits are buffered. The buffered * bits must also all be zero. */ - if (acc_len > 4 || (acc & (((unsigned)1 << acc_len) - 1)) != 0) { + if (acc_len > 4 || (acc & ((1U << acc_len) - 1)) != 0) { return NULL; } *dst_len = len; diff --git a/src/libsodium/crypto_pwhash/scryptsalsa208sha256/nosse/pwhash_scryptsalsa208sha256_nosse.c b/src/libsodium/crypto_pwhash/scryptsalsa208sha256/nosse/pwhash_scryptsalsa208sha256_nosse.c index 0536dff4..86961625 100644 --- a/src/libsodium/crypto_pwhash/scryptsalsa208sha256/nosse/pwhash_scryptsalsa208sha256_nosse.c +++ b/src/libsodium/crypto_pwhash/scryptsalsa208sha256/nosse/pwhash_scryptsalsa208sha256_nosse.c @@ -275,7 +275,7 @@ escrypt_kdf_nosse(escrypt_local_t * local, return -1; } #endif - if ((uint64_t)(r) * (uint64_t)(p) >= (1 << 30)) { + if ((uint64_t)(r) * (uint64_t)(p) >= ((uint64_t) 1 << 30)) { errno = EFBIG; return -1; } diff --git a/src/libsodium/crypto_pwhash/scryptsalsa208sha256/sse/pwhash_scryptsalsa208sha256_sse.c b/src/libsodium/crypto_pwhash/scryptsalsa208sha256/sse/pwhash_scryptsalsa208sha256_sse.c index e68272c1..5fd71f39 100644 --- a/src/libsodium/crypto_pwhash/scryptsalsa208sha256/sse/pwhash_scryptsalsa208sha256_sse.c +++ b/src/libsodium/crypto_pwhash/scryptsalsa208sha256/sse/pwhash_scryptsalsa208sha256_sse.c @@ -324,7 +324,7 @@ escrypt_kdf_sse(escrypt_local_t * local, return -1; } #endif - if ((uint64_t)(r) * (uint64_t)(p) >= (1 << 30)) { + if ((uint64_t)(r) * (uint64_t)(p) >= ((uint64_t) 1 << 30)) { errno = EFBIG; return -1; }