From: Bruno Haible Date: Sun, 18 Aug 2019 23:02:26 +0000 (+0200) Subject: xgettext: Fix endless loop in shell parser. X-Git-Tag: v0.20.2~50 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=58de220065d79f854e69850a8f5454ac12085e3e;p=thirdparty%2Fgettext.git xgettext: Fix endless loop in shell parser. Reported by Hanno Boeck at . Based on patch by Daiki Ueno. * gettext-tools/src/x-sh.c (read_word): React on CLOSING_BACKQUOTE even when we are currently not looking for a closing backquote. --- diff --git a/gettext-tools/src/x-sh.c b/gettext-tools/src/x-sh.c index 79631f825..0cf542efd 100644 --- a/gettext-tools/src/x-sh.c +++ b/gettext-tools/src/x-sh.c @@ -807,12 +807,29 @@ read_word (struct word *wp, int looking_for, flag_context_ty context) phase2_ungetc (c2); } - if (looking_for == CLOSING_BACKQUOTE && c == CLOSING_BACKQUOTE) + if (c == CLOSING_BACKQUOTE) { - saw_closing_backquote (); - wp->type = t_backquote; - last_non_comment_line = line_number; - return; + if (looking_for == CLOSING_BACKQUOTE) + { + saw_closing_backquote (); + wp->type = t_backquote; + last_non_comment_line = line_number; + return; + } + else if (looking_for == ')') + { + /* The input is invalid syntax, such as `a<(` + Push back the closing backquote and pretend that we have seen a + closing parenthesis. */ + phase2_ungetc (c); + wp->type = t_paren; + last_non_comment_line = line_number; + return; + } + else + /* We shouldn't be reading a CLOSING_BACKQUOTE when + looking_for == '\0'. */ + abort (); } if (looking_for == ')' && c == ')')