You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since mpc_parse_run isn't tail recursive it is possible to trigger a stack overflow with input languages allowing infinite nesting. An example of such an input language is the one used by examples/maths.c. Consider the following input generation program:
#!/bin/sh
PARENTHESES="${1:-5000}"
i=0
while [ $i -ne "${PARENTHESES}" ]; do
printf '('
i=$((i + 1))
done
printf "40 + 2"
while [ $i -ne 0 ]; do
printf ')'
i=$((i - 1))
done
printf '\n'
This is somewhat problematic if mpc is used for parsing a network protocol as it potentially allows a denial-of-service. Not sure if there is any easy way to fix this but including some kind of recursion limit would probably be one way of doing it.
The text was updated successfully, but these errors were encountered:
I added a recursion limit in ea778d1. Right now it is controlled by a define in the source code but we could also make it defined by some user specified parameter. Of course I don't think it makes mpc completely secure in the slightest but should be a good first line of defense and might help debugging too.
Since
mpc_parse_run
isn't tail recursive it is possible to trigger a stack overflow with input languages allowing infinite nesting. An example of such an input language is the one used byexamples/maths.c
. Consider the following input generation program:And run
maths
as:This is somewhat problematic if mpc is used for parsing a network protocol as it potentially allows a denial-of-service. Not sure if there is any easy way to fix this but including some kind of recursion limit would probably be one way of doing it.
The text was updated successfully, but these errors were encountered: