From 1dae690ad7b6a6b7aecb951360528575577de185 Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Thu, 18 Oct 2018 13:34:29 +0200 Subject: [PATCH] Avoid memset(NULL, _, 0) --- src/libsodium/crypto_sign/ed25519/ref10/open.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/libsodium/crypto_sign/ed25519/ref10/open.c b/src/libsodium/crypto_sign/ed25519/ref10/open.c index c9e8843c..ba833a61 100644 --- a/src/libsodium/crypto_sign/ed25519/ref10/open.c +++ b/src/libsodium/crypto_sign/ed25519/ref10/open.c @@ -75,14 +75,17 @@ crypto_sign_ed25519_open(unsigned char *m, unsigned long long *mlen_p, } mlen = smlen - 64; if (crypto_sign_ed25519_verify_detached(sm, sm + 64, mlen, pk) != 0) { - memset(m, 0, mlen); + if (m != NULL) { + memset(m, 0, mlen); + } goto badsig; } if (mlen_p != NULL) { *mlen_p = mlen; } - memmove(m, sm + 64, mlen); - + if (m != NULL) { + memmove(m, sm + 64, mlen); + } return 0; badsig: