Skip to content

Commit 068b963

Browse files
author
Rich Salz
committed
Avoid out-of-bounds read
Fixes CVE 2017-3735 Reviewed-by: Kurt Roeckx <kurt@roeckx.be> (Merged from #4276) (cherry picked from commit b231717)
1 parent 7c188d4 commit 068b963

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

crypto/x509v3/v3_addr.c

+6-4
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,12 @@ static int length_from_afi(const unsigned afi)
8484
*/
8585
unsigned int X509v3_addr_get_afi(const IPAddressFamily *f)
8686
{
87-
return ((f != NULL &&
88-
f->addressFamily != NULL && f->addressFamily->data != NULL)
89-
? ((f->addressFamily->data[0] << 8) | (f->addressFamily->data[1]))
90-
: 0);
87+
if (f == NULL
88+
|| f->addressFamily == NULL
89+
|| f->addressFamily->data == NULL
90+
|| f->addressFamily->length < 2)
91+
return 0;
92+
return (f->addressFamily->data[0] << 8) | f->addressFamily->data[1];
9193
}
9294

9395
/*

0 commit comments

Comments
 (0)