mirror of
https://github.com/micropython/micropython.git
synced 2026-04-28 03:40:22 +02:00
bd69a0ddef
Otherwise, a very deeply nested regular expression like
re.compile("(" * 65536)
can exhaust the host stack during the compile phase. This turns
that into a `RuntimeError: maximum recursion depth exceeded`
instead.
This crash was found via fuzzing.
Signed-off-by: Jeff Epler <jepler@unpythonic.net>
26 lines
449 B
Python
26 lines
449 B
Python
# Test overflow in re.compile output code.
|
|
|
|
try:
|
|
import re
|
|
except ImportError:
|
|
print("SKIP")
|
|
raise SystemExit
|
|
|
|
|
|
def test_re(r):
|
|
try:
|
|
re.compile(r)
|
|
except:
|
|
print("Error")
|
|
|
|
|
|
try:
|
|
r = "(" * 65536 + ")" * 65536
|
|
except MemoryError:
|
|
print("SKIP")
|
|
raise SystemExit
|
|
|
|
# This happens to trigger RecursionError on current versions of CPython
|
|
# (tested with 3.13.5) as well, so no .exp file is needed.
|
|
test_re(r)
|