From 030c5aba94788f152f9ceef3549815df45bef702 Mon Sep 17 00:00:00 2001 From: Matt Caswell Date: Thu, 19 Aug 2021 12:24:17 +0100 Subject: [PATCH] Fix EC_GROUP_new_from_ecparameters to check the base length Check that there's at least one byte in params->base before trying to read it. CVE-2021-3712 Reviewed-by: Viktor Dukhovni Reviewed-by: Paul Dale Reviewed-by: David Benjamin --- crypto/ec/ec_asn1.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crypto/ec/ec_asn1.c b/crypto/ec/ec_asn1.c index 0e37b21ac39..b3a791eb645 100644 --- a/crypto/ec/ec_asn1.c +++ b/crypto/ec/ec_asn1.c @@ -699,7 +699,8 @@ EC_GROUP *EC_GROUP_new_from_ecparameters(const ECPARAMETERS *params) if (params->order == NULL || params->base == NULL - || params->base->data == NULL) { + || params->base->data == NULL + || params->base->length == 0) { ERR_raise(ERR_LIB_EC, EC_R_ASN1_ERROR); goto err; } -- 2.47.2