aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2019-09-26 17:08:33 +0100
committerJonathan Wakely <redi@gcc.gnu.org>2019-09-26 17:08:33 +0100
commitd5f7e04923c5fe55db12e7da006c41c3853b4ddb (patch)
tree305a30c000581e4b78fba943d49f96bcd512aab9
parent8eb60b2f2254eee16d44ed5169837743b0debd5a (diff)
downloadgcc-d5f7e04923c5fe55db12e7da006c41c3853b4ddb.zip
gcc-d5f7e04923c5fe55db12e7da006c41c3853b4ddb.tar.gz
gcc-d5f7e04923c5fe55db12e7da006c41c3853b4ddb.tar.bz2
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. From-SVN: r276153
-rw-r--r--libstdc++-v3/ChangeLog3
-rw-r--r--libstdc++-v3/include/experimental/internet4
2 files changed, 5 insertions, 2 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 5d2349b..8484a7e 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,5 +1,8 @@
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.
+
* include/std/array: Remove references to profile mode.
* include/std/bitset: Likewise.
* include/std/deque: Likewise.
diff --git a/libstdc++-v3/include/experimental/internet b/libstdc++-v3/include/experimental/internet
index 44d757c..929a747 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];
}