bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bash regexp parsing would benefit from safe recursion limit


From: Dale R. Worley
Subject: Re: Bash regexp parsing would benefit from safe recursion limit
Date: Fri, 08 Apr 2022 20:17:24 -0400

willi1337 bald <willi1337bald1337@gmail.com> writes:
> A deeply nested and incorrect regex expression can cause exhaustion of
> stack resources, which crashes the bash process.

Further, you could construct a deeply nested regex that is correct but
would still crash the process.  It's hard to define what should happen
in a way that is implementable -- there are innumerable programs that
are theoretically correct but exhaust the stack if you try to execute
them.  More or less what you want is some sort of "checkpoint" of the
status of the overall computation (shell process) that you would return
to.  (a continuation!)  Your suggestion is effectively that the
checkpoint is "when bash prompts for the next command".  But in a sense,
that's what crashing the process is, too -- you return to the checkpoint
"before you started the shell".  If you had to worry about this in
practice, you'd turn

$ command1
$ command2
$ command3

into

$ bash -c command1
$ bash -c command2
$ bash -c command3

Dale



reply via email to

[Prev in Thread] Current Thread [Next in Thread]