1
0
mirror of https://github.com/golang/go synced 2024-11-24 04:40:24 -07:00
go/src/regexp
Russ Cox 452f24ae94 regexp/syntax: reject very deeply nested regexps in Parse
The regexp code assumes it can recurse over the structure of
a regexp safely. Go's growable stacks make that reasonable
for all plausible regexps, but implausible ones can reach the
“infinite recursion?” stack limit.

This CL limits the depth of any parsed regexp to 1000.
That is, the depth of the parse tree is required to be ≤ 1000.
Regexps that require deeper parse trees will return ErrInternalError.
A future CL will change the error to ErrInvalidDepth,
but using ErrInternalError for now avoids introducing new API
in point releases when this is backported.

Fixes #51112.

Change-Id: I97d2cd82195946eb43a4ea8561f5b95f91fb14c5
Reviewed-on: https://go-review.googlesource.com/c/go/+/384616
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2022-02-10 15:23:05 +00:00
..
syntax regexp/syntax: reject very deeply nested regexps in Parse 2022-02-10 15:23:05 +00:00
testdata
all_test.go
backtrack.go
example_test.go
exec2_test.go
exec_test.go
exec.go
find_test.go
onepass_test.go
onepass.go
regexp.go regexp: add the missing is 2022-01-19 22:56:09 +00:00