[PATCH] shell: avoid segfault on ${0::0/0~09J}. Closes 15216
Steffen Nurpmeso
steffen at sdaoden.eu
Thu Dec 29 17:20:08 UTC 2022
Ron Yorston wrote in
<63ad9a0f.MQrBKX7zM8Pqj639%rmy at pobox.com>:
|Both ash and hush segfault when asked to evaluate ${0::0/0~09J}.
...
| shell/math.c | 3 ++-
...
Without hurry or pressure or any of such sort, but to be more
explicit than in the patch commit message of the thing i had sent,
it must be said that the $(()) evaluator currently in use is
broken in some ways. There are explicitly disabled tests. But
more than what is tested. (And the ?: problem is not easy fixable
with Dijkstra, a recursive descendent thing like bash is however
also not a small solution.)
I am sorry that the one i posted (too often) adds 2000 bytes,
i would have thought it shrinks a bit when fully integrated. All
i could offer for that is to introduce another configuration
switch which disables the very costy and large ?: conditional
branch evaluation, i would assume doing so would bring costs down
by a large amount, while keeping the benefit of the (hopefully)
graceful parser and evaluator. (And ?: is not standardized (yet);
like &&, || etc. etc., but these are all simple binary operators.)
P.S.: the only change since then is that i added some more tests,
maybe grazy stuff
e "<$((0||0||0||0||0||0||0||0||0||0))>"
e "<$((0||0||0||0||0||0||0||0||0||3||0||0))>"
e "<$((0||0||0||0||0||0||0||0||0||3||0&&0))>"
e "<$((0||0||0||0||0||0||0||0||0||3&&0))>"
e "<$(((0||0||0||0||0||0||0||0||0||3||0)&&0))>"
e "<$(((0||0||0||0||0||0||0||0||0||3||0)&&3))>"
s I1=10 I2=20;p "<$((I1+=I2+=I2))>";e "<$I1><$I2>"
s I1=10 I2=20;p "<$((I1+=I2+=I1))>";e "<$I1><$I2>"
s I1=10 I2=20;p "<$((I1+=I2+=I1+=I2))>";e "<$I1><$I2>"
s I1=10 I2=20;p "<$((I1+=I2+=I1+=I1))>";e "<$I1><$I2>"
--steffen
|
|Der Kragenbaer, The moon bear,
|der holt sich munter he cheerfully and one by one
|einen nach dem anderen runter wa.ks himself off
|(By Robert Gernhardt)
More information about the busybox
mailing list