From: TJ Saunders Date: Fri, 10 Jun 2016 07:36:45 +0000 (-0700) Subject: Ensure that NULL r and s parameters cannot be set on DSA_SIG/ECDSA_SIGs. X-Git-Tag: OpenSSL_1_1_0-pre6~466 X-Git-Url: https://git.openssl.org/gitweb/?p=openssl.git;a=commitdiff_plain;h=bbaa9dd850152bc85cad094e0aa0c685553d149c;hp=1d454d58a80971eac941911965e894fdf1621cd8 Ensure that NULL r and s parameters cannot be set on DSA_SIG/ECDSA_SIGs. Reviewed-by: Richard Levitte Reviewed-by: Emilia Käsper Reviewed-by: Rich Salz (Merged from https://github.com/openssl/openssl/pull/1193) --- diff --git a/crypto/dsa/dsa_asn1.c b/crypto/dsa/dsa_asn1.c index f2818f3ab6..f79e1d1404 100644 --- a/crypto/dsa/dsa_asn1.c +++ b/crypto/dsa/dsa_asn1.c @@ -34,6 +34,8 @@ void DSA_SIG_get0(BIGNUM **pr, BIGNUM **ps, const DSA_SIG *sig) int DSA_SIG_set0(DSA_SIG *sig, BIGNUM *r, BIGNUM *s) { + if (r == NULL || s == NULL) + return 0; BN_clear_free(sig->r); BN_clear_free(sig->s); sig->r = r; diff --git a/crypto/ec/ec_asn1.c b/crypto/ec/ec_asn1.c index 9bc4ca7b27..9f7e837308 100644 --- a/crypto/ec/ec_asn1.c +++ b/crypto/ec/ec_asn1.c @@ -1182,6 +1182,8 @@ void ECDSA_SIG_get0(BIGNUM **pr, BIGNUM **ps, const ECDSA_SIG *sig) int ECDSA_SIG_set0(ECDSA_SIG *sig, BIGNUM *r, BIGNUM *s) { + if (r == NULL || s == NULL) + return 0; BN_clear_free(sig->r); BN_clear_free(sig->s); sig->r = r;