From e8fea07f1954a9eea4da1203e6a16f844508c22a Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Sun, 22 Jul 2018 21:26:31 +0200 Subject: [PATCH] memchr() can process its input in any order Fixes #737 --- .../scryptsalsa208sha256/pwhash_scryptsalsa208sha256.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libsodium/crypto_pwhash/scryptsalsa208sha256/pwhash_scryptsalsa208sha256.c b/src/libsodium/crypto_pwhash/scryptsalsa208sha256/pwhash_scryptsalsa208sha256.c index d1afd91a..13b81895 100644 --- a/src/libsodium/crypto_pwhash/scryptsalsa208sha256/pwhash_scryptsalsa208sha256.c +++ b/src/libsodium/crypto_pwhash/scryptsalsa208sha256/pwhash_scryptsalsa208sha256.c @@ -234,8 +234,8 @@ crypto_pwhash_scryptsalsa208sha256_str_verify( escrypt_local_t escrypt_local; int ret = -1; - if (memchr(str, 0, crypto_pwhash_scryptsalsa208sha256_STRBYTES) != - &str[crypto_pwhash_scryptsalsa208sha256_STRBYTES - 1U]) { + if (strnlen(str, crypto_pwhash_scryptsalsa208sha256_STRBYTES) != + crypto_pwhash_scryptsalsa208sha256_STRBYTES - 1U) { return -1; } if (escrypt_init_local(&escrypt_local) != 0) { @@ -268,8 +268,8 @@ crypto_pwhash_scryptsalsa208sha256_str_needs_rehash( errno = EINVAL; return -1; } - if (memchr(str, 0, crypto_pwhash_scryptsalsa208sha256_STRBYTES) != - &str[crypto_pwhash_scryptsalsa208sha256_STRBYTES - 1U]) { + if (strnlen(str, crypto_pwhash_scryptsalsa208sha256_STRBYTES) != + crypto_pwhash_scryptsalsa208sha256_STRBYTES - 1U) { errno = EINVAL; return -1; }