Skip to content
This repository was archived by the owner on Apr 10, 2025. It is now read-only.

Commit 97de614

Browse files
Fix undefined behaviour in EC_GROUP_new_from_ecparameters
This happens for instance with fuzz/corpora/asn1/65cf44e85614c62f10cf3b7a7184c26293a19e4a and causes the OPENSSL_malloc below to choke on the zero length allocation request. Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from openssl#18365)
1 parent 22a96c6 commit 97de614

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

crypto/ec/ec_asn1.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,16 @@ EC_GROUP *EC_GROUP_new_from_ecparameters(const ECPARAMETERS *params)
687687

688688
/* extract seed (optional) */
689689
if (params->curve->seed != NULL) {
690+
/*
691+
* This happens for instance with
692+
* fuzz/corpora/asn1/65cf44e85614c62f10cf3b7a7184c26293a19e4a
693+
* and causes the OPENSSL_malloc below to choke on the
694+
* zero length allocation request.
695+
*/
696+
if (params->curve->seed->length == 0) {
697+
ERR_raise(ERR_LIB_EC, EC_R_ASN1_ERROR);
698+
goto err;
699+
}
690700
OPENSSL_free(ret->seed);
691701
if ((ret->seed = OPENSSL_malloc(params->curve->seed->length)) == NULL) {
692702
ERR_raise(ERR_LIB_EC, ERR_R_MALLOC_FAILURE);

0 commit comments

Comments
 (0)