]> git.ipfire.org Git - thirdparty/gcc.git/commit
libstdc++: Check for overflow in regex back-reference [PR106607]
authorJonathan Wakely <jwakely@redhat.com>
Mon, 22 Aug 2022 14:16:16 +0000 (15:16 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Fri, 23 Jun 2023 12:37:05 +0000 (13:37 +0100)
commitfab3692a2cf961b7364d7f77dd976ba0e4f752b7
treef12e0816d8ce5deac4d7f59d6dd8ee8cac693ac9
parent596aa947770806d93395d190de3b1d7e14391a21
libstdc++: Check for overflow in regex back-reference [PR106607]

Currently we fail to notice integer overflow when parsing a
back-reference expression, or when converting the parsed result from
long to int. This changes the result to be int, so no conversion is
needed, and uses the overflow-checking built-ins to detect an
out-of-range back-reference.

libstdc++-v3/ChangeLog:

PR libstdc++/106607
* include/bits/regex_compiler.tcc (_Compiler::_M_cur_int_value):
Use built-ins to check for integer overflow in back-reference
number.
* testsuite/28_regex/basic_regex/106607.cc: New test.

(cherry picked from commit 1b09eea33f2bf9d1eae73b25cc25efb05ea1dc3f)
libstdc++-v3/include/bits/regex_compiler.tcc
libstdc++-v3/testsuite/28_regex/basic_regex/106607.cc [new file with mode: 0644]