-
-
Notifications
You must be signed in to change notification settings - Fork 34.2k
Closed
Labels
3.11only security fixesonly security fixes3.12only security fixesonly security fixes3.13bugs and security fixesbugs and security fixesdocsDocumentation in the Doc dirDocumentation in the Doc dirtopic-regextype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
Bug description:
The re module's documentation says it only raises the re.error exception, but the regex "\x00(?<!\x00{2147483648})" causes RuntimeError:
Python 3.11.5 (main, Sep 20 2023, 10:46:56) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import re
>>> re.compile("\x00(?<!\x00{2147483647})")
re.compile('\x00(?<!\x00{2147483647})')
>>>
>>>
>>> re.compile("\x00(?<!\x00{2147483648})")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.11/re/__init__.py", line 227, in compile
return _compile(pattern, flags)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/re/__init__.py", line 294, in _compile
p = _compiler.compile(pattern, flags)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/re/_compiler.py", line 759, in compile
return _sre.compile(
^^^^^^^^^^^^^
RuntimeError: invalid SRE codeOther re methods, such as match or split show the same result.
For brevity:
"\x00(?<!\x00{2147483648})" -> RuntimeError
"\x00(?<!\x00{2147483647})" -> no errors
I have found this with libFuzzer by testing the fuzz_sre_compile binary.
CPython versions tested on:
3.11
Operating systems tested on:
Linux
Linked PRs
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
3.11only security fixesonly security fixes3.12only security fixesonly security fixes3.13bugs and security fixesbugs and security fixesdocsDocumentation in the Doc dirDocumentation in the Doc dirtopic-regextype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error