diff --git a/crypto/x509v3/v3_addr.c b/crypto/x509v3/v3_addr.c index f4e1298ca33af50e8d6e818ea9be08fbb6eecfae..bb58e0484611a4f0f40868a01671c78a265267ad 100644 --- a/crypto/x509v3/v3_addr.c +++ b/crypto/x509v3/v3_addr.c @@ -84,10 +84,12 @@ static int length_from_afi(const unsigned afi) */ unsigned int X509v3_addr_get_afi(const IPAddressFamily *f) { - return ((f != NULL && - f->addressFamily != NULL && f->addressFamily->data != NULL) - ? ((f->addressFamily->data[0] << 8) | (f->addressFamily->data[1])) - : 0); + if (f == NULL + || f->addressFamily == NULL + || f->addressFamily->data == NULL + || f->addressFamily->length < 2) + return 0; + return (f->addressFamily->data[0] << 8) | f->addressFamily->data[1]; } /*