]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Avoid out-of-bounds read
authorRich Salz <rsalz@openssl.org>
Tue, 22 Aug 2017 15:44:41 +0000 (11:44 -0400)
committerRich Salz <rsalz@openssl.org>
Mon, 28 Aug 2017 17:34:08 +0000 (13:34 -0400)
Fixes CVE 2017-3735

Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
(Merged from https://github.com/openssl/openssl/pull/4276)

(cherry picked from commit b23171744b01e473ebbfd6edad70c1c3825ffbcd)

crypto/x509v3/v3_addr.c

index 1290dec9bb8c0ccec58b5476ec4d8ae16a6a6a5e..af080a04f2ba2035ff72b2ea0d7e921a1aaa4b4a 100644 (file)
@@ -130,10 +130,12 @@ static int length_from_afi(const unsigned afi)
  */
 unsigned int v3_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];
 }
 
 /*