Don't report |ERR_R_MALLOC_FAILURE| on failure of |EC_KEY_new_by_curve_name|.

Change |EC_KEY_new_by_curve_name| to report |ERR_R_MALLOC_FAILURE|
itself, so that reporting of |EC_R_UNKNOWN_GROUP| is not confused by
the caller's addition of a spurious |ERR_R_MALLOC_FAILURE|.

Change-Id: Id3f5364f01eb8e3597bcddd6484bc03d5578befb
Reviewed-on: https://boringssl-review.googlesource.com/4690
Reviewed-by: Adam Langley <agl@google.com>
This commit is contained in:
Matt Braithwaite 2015-05-08 16:19:18 -07:00 committed by Adam Langley
parent d100c2498f
commit 3bf1cca262
3 changed files with 2 additions and 1 deletions

View File

@ -127,6 +127,7 @@ err1:
EC_KEY *EC_KEY_new_by_curve_name(int nid) { EC_KEY *EC_KEY_new_by_curve_name(int nid) {
EC_KEY *ret = EC_KEY_new(); EC_KEY *ret = EC_KEY_new();
if (ret == NULL) { if (ret == NULL) {
OPENSSL_PUT_ERROR(EC, EC_KEY_new_by_curve_name, ERR_R_MALLOC_FAILURE);
return NULL; return NULL;
} }
ret->group = EC_GROUP_new_by_curve_name(nid); ret->group = EC_GROUP_new_by_curve_name(nid);

View File

@ -147,7 +147,6 @@ static EC_KEY *eckey_type2param(int ptype, void *pval) {
* by an asn1 OID */ * by an asn1 OID */
eckey = EC_KEY_new_by_curve_name(OBJ_obj2nid(poid)); eckey = EC_KEY_new_by_curve_name(OBJ_obj2nid(poid));
if (eckey == NULL) { if (eckey == NULL) {
OPENSSL_PUT_ERROR(EVP, eckey_type2param, ERR_R_MALLOC_FAILURE);
goto err; goto err;
} }
} else { } else {

View File

@ -380,6 +380,7 @@ OPENSSL_EXPORT void EC_GROUP_set_point_conversion_form(
#define EC_F_ec_GFp_nistp256_points_mul 162 #define EC_F_ec_GFp_nistp256_points_mul 162
#define EC_F_ec_group_copy 163 #define EC_F_ec_group_copy 163
#define EC_F_nistp256_pre_comp_new 164 #define EC_F_nistp256_pre_comp_new 164
#define EC_F_EC_KEY_new_by_curve_name 165
#define EC_R_BUFFER_TOO_SMALL 100 #define EC_R_BUFFER_TOO_SMALL 100
#define EC_R_COORDINATES_OUT_OF_RANGE 101 #define EC_R_COORDINATES_OUT_OF_RANGE 101
#define EC_R_D2I_ECPKPARAMETERS_FAILURE 102 #define EC_R_D2I_ECPKPARAMETERS_FAILURE 102