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

Tested x86_64-linux, committed to trunk.


commit f5886e6a2c744196c089b16853d73d64e248a735
Author: Jonathan Wakely <jwak...@redhat.com>
Date:   Thu Sep 26 14:57:56 2019 +0100

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

diff --git a/libstdc++-v3/include/experimental/internet 
b/libstdc++-v3/include/experimental/internet
index 44d757c3a97..929a747a250 100644
--- a/libstdc++-v3/include/experimental/internet
+++ b/libstdc++-v3/include/experimental/internet
@@ -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];
   }

Reply via email to