From patchwork Mon Apr 2 16:40:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Herbert Xu X-Patchwork-Id: 10320057 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4E55C602C8 for ; Mon, 2 Apr 2018 16:40:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3E5562893C for ; Mon, 2 Apr 2018 16:40:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 32B2828A14; Mon, 2 Apr 2018 16:40:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 312782893C for ; Mon, 2 Apr 2018 16:40:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752331AbeDBQkd (ORCPT ); Mon, 2 Apr 2018 12:40:33 -0400 Received: from orcrist.hmeau.com ([104.223.48.154]:56736 "EHLO deadmen.hmeau.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751443AbeDBQkd (ORCPT ); Mon, 2 Apr 2018 12:40:33 -0400 Received: from gondobar.mordor.me.apana.org.au ([192.168.128.4] helo=gondobar) by deadmen.hmeau.com with esmtp (Exim 4.84_2 #2 (Debian)) id 1f32VP-0004ES-IH; Tue, 03 Apr 2018 00:40:27 +0800 Received: from herbert by gondobar with local (Exim 4.84_2) (envelope-from ) id 1f32VN-0000Bn-Ev; Tue, 03 Apr 2018 00:40:25 +0800 Date: Tue, 3 Apr 2018 00:40:25 +0800 From: Herbert Xu To: DASH Mailing List Subject: parser: Fix parsing of ${} Message-ID: <20180402164025.GA715@gondor.apana.org.au> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) Sender: dash-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dash@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP dash -c 'echo ${}' should print "Bad subtitution" but instead fails with "Syntax error: Missing '}'". This is caused by us reading an extra character beyond the right brace. This patch fixes it so that this construct only fails during expansion rather than during parsing. Fixes: 3df3edd13389 ("[PARSER] Report substition errors at...") Signed-off-by: Herbert Xu diff --git a/src/parser.c b/src/parser.c index 6a8a4a4..efa8060 100644 --- a/src/parser.c +++ b/src/parser.c @@ -1262,7 +1262,7 @@ varname: STPUTC(c, out); c = pgetc_eatbnl(); } while (is_digit(c)); - } else { + } else if (c != '}') { int cc = c; c = pgetc_eatbnl(); @@ -1290,7 +1290,8 @@ varname: } USTPUTC(cc, out); - } + } else + goto badsub; if (subtype == 0) { int cc = c;