Permalink
Browse files

Avoid out-of-bounds read

Fixes CVE 2017-3735

Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
(Merged from #4276)

(cherry picked from commit b231717)
  • Loading branch information...
richsalz committed Aug 22, 2017
1 parent 7c188d4 commit 068b963bb7afc57f5bdd723de0dd15e7795d5822
Showing with 6 additions and 4 deletions.
  1. +6 −4 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];
}
/*

0 comments on commit 068b963

Please sign in to comment.