mirror of
https://github.com/go-sylixos/elvish.git
synced 2024-12-13 18:07:51 +08:00
9cda3f643e
The parsing function for Form first tries to parse a temp assignment, and backtracks when an assignment cannot be parsed. When the input is "(" repeated n times, each level of Form parsing will first try to parse the rest of the code as an assignment and then backtrack, without making any progress. This results in a call tree with a branching factor of 2, hence the O(2^n) complexity. The fix is to first try to parse a head instead, and only try to parse it as a temp assignment if it does contain "=". This fixes this particular pathological case, although I'm not 100% sure it eliminates all possibilities of O(2^n) time complexity. With the introduction of the "tmp" special command, the current syntax for temporary assignments will be deprecated and eventually go away, which will eliminate all backtracking in the parser. In the meanwhile, this fix may be good enough. This case was discovered with fuzzing support in Go 1.18. Also add the fuzzing test data. |
||
---|---|---|
.. | ||
buildinfo | ||
cli | ||
daemon | ||
diag | ||
edit | ||
env | ||
eval | ||
fsutil | ||
getopt | ||
glob | ||
logutil | ||
mods | ||
parse | ||
persistent | ||
prog | ||
rpc | ||
shell | ||
store | ||
strutil | ||
sys | ||
testutil | ||
tt | ||
ui | ||
wcwidth |