On error path, do not set the signature len if a NULL pointer was given.

This commit is contained in:
Frank Denis 2014-08-15 15:10:24 -07:00
parent 6c8df6adad
commit d01e1f4875

View File

@ -63,7 +63,9 @@ crypto_sign(unsigned char *sm, unsigned long long *smlen,
if (crypto_sign_detached(sm, &siglen, m, mlen, sk) != 0 || if (crypto_sign_detached(sm, &siglen, m, mlen, sk) != 0 ||
siglen > crypto_sign_ed25519_BYTES) { siglen > crypto_sign_ed25519_BYTES) {
if (smlen != NULL) {
*smlen = 0; *smlen = 0;
}
memset(sm, 0, mlen + crypto_sign_ed25519_BYTES); memset(sm, 0, mlen + crypto_sign_ed25519_BYTES);
return -1; return -1;
} }