ec_asn1.c (openssl-1.1.1o) | : | ec_asn1.c (openssl-1.1.1p) | ||
---|---|---|---|---|
/* | /* | |||
* Copyright 2002-2021 The OpenSSL Project Authors. All Rights Reserved. | * Copyright 2002-2022 The OpenSSL Project Authors. All Rights Reserved. | |||
* | * | |||
* Licensed under the OpenSSL license (the "License"). You may not use | * Licensed under the OpenSSL license (the "License"). You may not use | |||
* this file except in compliance with the License. You can obtain a copy | * this file except in compliance with the License. You can obtain a copy | |||
* in the file LICENSE in the source distribution or at | * in the file LICENSE in the source distribution or at | |||
* https://www.openssl.org/source/license.html | * https://www.openssl.org/source/license.html | |||
*/ | */ | |||
#include <string.h> | #include <string.h> | |||
#include "ec_local.h" | #include "ec_local.h" | |||
#include <openssl/err.h> | #include <openssl/err.h> | |||
skipping to change at line 754 | skipping to change at line 754 | |||
goto err; | goto err; | |||
} | } | |||
if (ret == NULL) { | if (ret == NULL) { | |||
ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, ERR_R_EC_LIB); | ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, ERR_R_EC_LIB); | |||
goto err; | goto err; | |||
} | } | |||
/* extract seed (optional) */ | /* extract seed (optional) */ | |||
if (params->curve->seed != NULL) { | if (params->curve->seed != NULL) { | |||
/* | ||||
* This happens for instance with | ||||
* fuzz/corpora/asn1/65cf44e85614c62f10cf3b7a7184c26293a19e4a | ||||
* and causes the OPENSSL_malloc below to choke on the | ||||
* zero length allocation request. | ||||
*/ | ||||
if (params->curve->seed->length == 0) { | ||||
ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, EC_R_ASN1_ERROR); | ||||
goto err; | ||||
} | ||||
OPENSSL_free(ret->seed); | OPENSSL_free(ret->seed); | |||
if ((ret->seed = OPENSSL_malloc(params->curve->seed->length)) == NULL) { | if ((ret->seed = OPENSSL_malloc(params->curve->seed->length)) == NULL) { | |||
ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, ERR_R_MALLOC_FAILURE); | ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, ERR_R_MALLOC_FAILURE); | |||
goto err; | goto err; | |||
} | } | |||
memcpy(ret->seed, params->curve->seed->data, | memcpy(ret->seed, params->curve->seed->data, | |||
params->curve->seed->length); | params->curve->seed->length); | |||
ret->seed_len = params->curve->seed->length; | ret->seed_len = params->curve->seed->length; | |||
} | } | |||
End of changes. 2 change blocks. | ||||
1 lines changed or deleted | 11 lines changed or added |