[Toybox] [PATCH 3/4] sh: fix bug in parameter substitution (pattern replacement)
Alexander Holler
holler at ahsoftware.de
Sat Nov 5 00:10:29 PDT 2022
Avoid a core dump on the following snippet:
V="a.b"; V=${V//./}
---
toys/pending/sh.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/toys/pending/sh.c b/toys/pending/sh.c
index 298bfbc0..c3c081a5 100644
--- a/toys/pending/sh.c
+++ b/toys/pending/sh.c
@@ -2149,7 +2149,7 @@ barf:
ll++;
continue;
}
- if (*delete && (*delete)->arg==ifs) {
+ if (delete && *delete && (*delete)->arg==ifs) {
if (jj==dd) memcpy(ifs+ll, ss, jj);
else if (jj<dd) sprintf(ifs+ll, "%s%s", ss, ifs+ll+dd);
else bird = ifs;
--
2.25.1
More information about the Toybox
mailing list