From patchwork Mon Nov 19 10:41:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Herbert Xu X-Patchwork-Id: 10688471 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-2.web.codeaurora.org (Postfix) with ESMTP id 8ABF014D6 for ; Mon, 19 Nov 2018 10:41:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 789FE29A08 for ; Mon, 19 Nov 2018 10:41:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6B30B29A40; Mon, 19 Nov 2018 10:41:24 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, 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 11C3729A08 for ; Mon, 19 Nov 2018 10:41:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727677AbeKSVEh (ORCPT ); Mon, 19 Nov 2018 16:04:37 -0500 Received: from orcrist.hmeau.com ([104.223.48.154]:43486 "EHLO deadmen.hmeau.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725911AbeKSVEg (ORCPT ); Mon, 19 Nov 2018 16:04:36 -0500 Received: from gondobar.mordor.me.apana.org.au ([192.168.128.4] helo=gondobar) by deadmen.hmeau.com with esmtps (Exim 4.89 #2 (Debian)) id 1gOgza-0008I6-7s; Mon, 19 Nov 2018 18:41:22 +0800 Received: from herbert by gondobar with local (Exim 4.89) (envelope-from ) id 1gOgzY-0001LH-Ko; Mon, 19 Nov 2018 18:41:20 +0800 Date: Mon, 19 Nov 2018 18:41:20 +0800 From: Herbert Xu To: Martijn Dekker Cc: DASH shell mailing list Subject: [PATCH] expand: Eat closing brace for length parameter expansion Message-ID: <20181119104120.r2rx3vapaoh3ilvk@gondor.apana.org.au> References: <20180905132359.s57mpwhsm3opsrvg@gondor.apana.org.au> <20180906050715.vb3tlbagyiryc3pd@gondor.apana.org.au> <38011ac0-04b7-2dd7-b1a8-11377f7c9ade@inlv.org> <20180912062716.boa32pwabi6fpaal@gondor.apana.org.au> <20181119055449.2qkyd7t4ycwn3a76@gondor.apana.org.au> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20181119055449.2qkyd7t4ycwn3a76@gondor.apana.org.au> User-Agent: NeoMutt/20170113 (1.7.2) Sender: dash-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dash@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Apologies for the reposts, but I'm having problems making this get into patchwork. ---8<--- When we are doing VSLENGTH expansion, the closing brace is currently not removed in evalvar. This causes the caller argstr to terminate prematurely as it would interpret the closing brace as one that belongs to a parameter expansion at the outer level. This patch fixes it. Reported-by: Martijn Dekker Fixes: 3cd538634f71 ("expand: Do not reprocess data when...") Signed-off-by: Herbert Xu diff --git a/src/expand.c b/src/expand.c index 856b7a9..af9cac9 100644 --- a/src/expand.c +++ b/src/expand.c @@ -745,6 +745,7 @@ again: varunset(p, var, 0, 0); if (subtype == VSLENGTH) { + p++; if (flag & EXP_DISCARD) return p; cvtnum(varlen > 0 ? varlen : 0, flag);