[Bug 229] New: hush does not throw syntax error when reaching EOF with invalid code

bugzilla at busybox.net bugzilla at busybox.net
Sat Mar 28 19:16:27 UTC 2009


https://bugs.busybox.net/show_bug.cgi?id=229

           Summary: hush does not throw syntax error when reaching EOF with
                    invalid code
           Product: Busybox
           Version: unspecified
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: enhancement
          Priority: P5
         Component: Other
        AssignedTo: unassigned at busybox.net
        ReportedBy: vapier at gentoo.org
                CC: busybox-cvs at busybox.net
   Estimated Hours: 0.0


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;
 }


-- 
Configure bugmail: https://bugs.busybox.net/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


More information about the busybox-cvs mailing list