From 292969b3b530e5754734c5a54492953b84dc8b07 Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Thu, 7 Apr 2016 08:05:15 +0200 Subject: [PATCH] Argon2: initialize ctx{.pwd,.pwdlen} in the verify function Keep initializing the length for clarity; Compilers know how to optimize this out. --- src/libsodium/crypto_pwhash/argon2/argon2-encoding.c | 1 - src/libsodium/crypto_pwhash/argon2/argon2.c | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libsodium/crypto_pwhash/argon2/argon2-encoding.c b/src/libsodium/crypto_pwhash/argon2/argon2-encoding.c index 5b8d6c43..9f8d63c6 100644 --- a/src/libsodium/crypto_pwhash/argon2/argon2-encoding.c +++ b/src/libsodium/crypto_pwhash/argon2/argon2-encoding.c @@ -299,7 +299,6 @@ int decode_string(argon2_context *ctx, const char *str, argon2_type type) { ctx->adlen = 0; ctx->saltlen = 0; ctx->outlen = 0; - ctx->pwdlen = 0; if (type == Argon2_i) { CC("$argon2i"); } else { diff --git a/src/libsodium/crypto_pwhash/argon2/argon2.c b/src/libsodium/crypto_pwhash/argon2/argon2.c index 9596a8d4..0f47d936 100644 --- a/src/libsodium/crypto_pwhash/argon2/argon2.c +++ b/src/libsodium/crypto_pwhash/argon2/argon2.c @@ -183,6 +183,8 @@ int argon2_verify(const char *encoded, const void *pwd, const size_t pwdlen, memset(&ctx, 0, sizeof ctx); + ctx.pwd = NULL; + ctx.pwdlen = 0; ctx.secret = NULL; ctx.secretlen = 0;