]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Fix array index error in address_v6 comparisons
authorJonathan Wakely <jwakely@redhat.com>
Thu, 24 Oct 2019 12:54:05 +0000 (13:54 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Thu, 24 Oct 2019 12:54:05 +0000 (13:54 +0100)
Backport from mainline
2019-09-26  Jonathan Wakely  <jwakely@redhat.com>

* include/experimental/internet (operator==, operator<): Fix loop
condition to avoid reading past the end of the array.

From-SVN: r277378

libstdc++-v3/ChangeLog
libstdc++-v3/include/experimental/internet

index 518427d19f720a6762e3a668f31c52e2961fd46e..92f91d63d93ffa4de19ab469bae5dd0b66436695 100644 (file)
@@ -1,5 +1,11 @@
 2019-10-24  Jonathan Wakely  <jwakely@redhat.com>
 
+       Backport from mainline
+       2019-09-26  Jonathan Wakely  <jwakely@redhat.com>
+
+       * include/experimental/internet (operator==, operator<): Fix loop
+       condition to avoid reading past the end of the array.
+
        Backport from mainline
        2019-08-06  Jonathan Wakely  <jwakely@redhat.com>
 
index 467bdfda3ed1f2c2eeca4ccca5c44201f191a641..e1368ec745a7f918b2b9a0c8295ea0476e8c6cbc 100644 (file)
@@ -539,7 +539,7 @@ namespace ip
     const auto& __aa = __a._M_bytes;
     const auto& __bb = __b._M_bytes;
     int __i = 0;
-    for (; __aa[__i] == __bb[__i] && __i < 16; ++__i)
+    for (; __i < 16 && __aa[__i] == __bb[__i]; ++__i)
       ;
     return __i == 16 ? __a.scope_id() == __b.scope_id() : false;
   }
@@ -554,7 +554,7 @@ namespace ip
     const auto& __aa = __a._M_bytes;
     const auto& __bb = __b._M_bytes;
     int __i = 0;
-    for (; __aa[__i] == __bb[__i] && __i < 16; ++__i)
+    for (; __i < 16 && __aa[__i] == __bb[__i]; ++__i)
       ;
     return __i == 16 ? __a.scope_id() < __b.scope_id() : __aa[__i] < __bb[__i];
   }