-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dash parser fixes #18
Conversation
Instead of blowing up the stack, let the user know that there was an error.
Smoosh mishandled Dash's memory routines that could lead to buffer overflows when executing nested evals. After an eval is done, the stackmark must be popped before the file is popped and the input string is unallocated. Skipping the stack popping can lead to situations where Dash mistakenly believes that the free space spans multiple stack blocks. This change makes Smoosh pop the stackmark before unallocating.
I am putting this here, otherwise there would be merge conflicts. Another crash caused by miscommunication between Smoosh and Dash. This time a buffer overflow. Reproducer: force="echo 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\
AAAAAAAAAAAAA' >/dev/null"
eval "eval ${force}"
eval "${force}" Why does it fail? In Dash, the order of memory operations when executing
In Smoosh, one of the pieces was missing:
The problem with this is that in Dash, stack blocks can only be deallocated using After the inner
Where When the outer eval is done, the situation turns into the following:
The block of inner eval is still the active block, but the next free byte is now pointing to the beginning of outer eval. Everything between the two is viewed as free memory by Dash, and the next Popping the stackmark like Dash does fixes this issue. |
Whew---I'm finally getting to these! I'm sorry to have taken so long. Travis is being weird (stuck in an old .travis.yml file), but the tests look good here. Thank you!!!!! |
This is for handling cases like
${}
,${,}
,${+}
, etc. Without this, they would end up in an endless mutual recursion ofshim.parse_arg
andshim.arg_char
, ending with a stack overflow:...repeating endlessly.
With this patch, the output is: