| Summary: | hush does not throw syntax error when reaching EOF with invalid code | ||
|---|---|---|---|
| Product: | Busybox | Reporter: | Mike Frysinger <vapier> |
| Component: | Other | Assignee: | unassigned |
| Status: | RESOLVED FIXED | ||
| Severity: | enhancement | CC: | busybox-cvs |
| Priority: | P5 | ||
| Version: | unspecified | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Linux | ||
| Host: | Target: | ||
| Build: | |||
| Attachments: | Fix | ||
Created attachment 285 [details]
Fix
Try attached patch please
|
if hush reaches EOF on an invalid script, it does not throw an error but rather exits quietly i imagine this is because it wants to be nice when running in interactive mode, but bash will throw up on you in this case, so we might as well too example: $ echo '(' > test.sh $ bash ./test.sh ; echo $? ./test.sh: line 2: syntax error: unexpected end of file 2 $ hush ./test.sh ; echo $? 0 same behavior can be seen in interactive mode even worse, we segfault when using -c: $ hush -c '(' Segmentation fault i think this is the fix for that case: --- shell/hush.c (revision 25863) +++ shell/hush.c (working copy) @@ -1024,7 +1024,9 @@ */ static int static_get(struct in_str *i) { - int ch = *i->p++; + int ch; + if (!i->p) return EOF; + ch = *i->p++; if (ch == '\0') return EOF; return ch; }