Fix more d2i cases to properly update the input pointer
Thanks to David Benjamin <davidben@google.com> for pointing them out.
Reviewed-by: Steve Henson <steve@openssl.org>
MR #1198
(cherry picked from commit 605236f6a8
)
This commit is contained in:
parent
d62c64b947
commit
6b247c1817
@ -104,7 +104,8 @@ EVP_PKEY *d2i_PrivateKey(int type, EVP_PKEY **a, const unsigned char **pp,
|
|||||||
EVP_PKEY_free(ret);
|
EVP_PKEY_free(ret);
|
||||||
ret = EVP_PKCS82PKEY(p8);
|
ret = EVP_PKCS82PKEY(p8);
|
||||||
PKCS8_PRIV_KEY_INFO_free(p8);
|
PKCS8_PRIV_KEY_INFO_free(p8);
|
||||||
|
if (ret == NULL)
|
||||||
|
goto err;
|
||||||
} else {
|
} else {
|
||||||
ASN1err(ASN1_F_D2I_PRIVATEKEY, ERR_R_ASN1_LIB);
|
ASN1err(ASN1_F_D2I_PRIVATEKEY, ERR_R_ASN1_LIB);
|
||||||
goto err;
|
goto err;
|
||||||
@ -160,8 +161,9 @@ EVP_PKEY *d2i_AutoPrivateKey(EVP_PKEY **a, const unsigned char **pp,
|
|||||||
}
|
}
|
||||||
ret = EVP_PKCS82PKEY(p8);
|
ret = EVP_PKCS82PKEY(p8);
|
||||||
PKCS8_PRIV_KEY_INFO_free(p8);
|
PKCS8_PRIV_KEY_INFO_free(p8);
|
||||||
if (ret != NULL)
|
if (ret == NULL)
|
||||||
*pp = p;
|
return NULL;
|
||||||
|
*pp = p;
|
||||||
if (a) {
|
if (a) {
|
||||||
*a = ret;
|
*a = ret;
|
||||||
}
|
}
|
||||||
|
@ -186,9 +186,7 @@ X509 *d2i_X509_AUX(X509 **a, const unsigned char **pp, long length)
|
|||||||
return NULL;
|
return NULL;
|
||||||
/* update length */
|
/* update length */
|
||||||
length -= q - *pp;
|
length -= q - *pp;
|
||||||
if (!length)
|
if (length > 0 && !d2i_X509_CERT_AUX(&ret->aux, &q, length))
|
||||||
return ret;
|
|
||||||
if (!d2i_X509_CERT_AUX(&ret->aux, &q, length))
|
|
||||||
goto err;
|
goto err;
|
||||||
*pp = q;
|
*pp = q;
|
||||||
return ret;
|
return ret;
|
||||||
|
Loading…
Reference in New Issue
Block a user