Ensure we check i2d_X509 return val
The i2d_X509() function can return a negative value on error. Therefore we should make sure we check it. Issue reported by Yuan Jochen Kang. Reviewed-by: Emilia Käsper <emilia@openssl.org> (cherry picked from commit 446ba8de9af9aa4fa3debc7c76a38f4efed47a62)
This commit is contained in:
parent
1ee4541576
commit
a04d08fc18
@ -201,9 +201,18 @@ X509 *d2i_X509_AUX(X509 **a, const unsigned char **pp, long length)
|
|||||||
|
|
||||||
int i2d_X509_AUX(X509 *a, unsigned char **pp)
|
int i2d_X509_AUX(X509 *a, unsigned char **pp)
|
||||||
{
|
{
|
||||||
int length;
|
int length, tmplen;
|
||||||
|
unsigned char *start = *pp;
|
||||||
length = i2d_X509(a, pp);
|
length = i2d_X509(a, pp);
|
||||||
if (a)
|
if (length < 0 || a == NULL)
|
||||||
length += i2d_X509_CERT_AUX(a->aux, pp);
|
return length;
|
||||||
|
|
||||||
|
tmplen = i2d_X509_CERT_AUX(a->aux, pp);
|
||||||
|
if (tmplen < 0) {
|
||||||
|
*pp = start;
|
||||||
|
return tmplen;
|
||||||
|
}
|
||||||
|
length += tmplen;
|
||||||
|
|
||||||
return length;
|
return length;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user