From patchwork Wed Nov 5 08:48:26 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Herbert Xu X-Patchwork-Id: 5232841 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: X-Original-To: patchwork-dash@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 7DB93C11AC for ; Wed, 5 Nov 2014 08:48:44 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B0A8920173 for ; Wed, 5 Nov 2014 08:48:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DD90A20165 for ; Wed, 5 Nov 2014 08:48:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751403AbaKEIsa (ORCPT ); Wed, 5 Nov 2014 03:48:30 -0500 Received: from helcar.apana.org.au ([209.40.204.226]:55412 "EHLO helcar.apana.org.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750860AbaKEIs3 (ORCPT ); Wed, 5 Nov 2014 03:48:29 -0500 Received: from gondolin.me.apana.org.au ([192.168.0.6]) by fornost.hengli.com.au with esmtp (Exim 4.80 #3 (Debian)) id 1XlwGR-0005S5-HM for ; Wed, 05 Nov 2014 19:48:27 +1100 Received: from herbert by gondolin.me.apana.org.au with local (Exim 4.80) (envelope-from ) id 1XlwGQ-0005Xu-Ks; Wed, 05 Nov 2014 16:48:26 +0800 Subject: [PATCH 3/3] [PARSER] Catch variable length expansions on non-existant specials References: <20141105084749.GA21242@gondor.apana.org.au> To: dash@vger.kernel.org Message-Id: From: Herbert Xu Date: Wed, 05 Nov 2014 16:48:26 +0800 Sender: dash-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dash@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Currently we only check special variable names that follow directly after $ or ${. So errors such as ${#&} are not caught. This patch fixes that by moving the is_special check to just before we print out the special variable name. Signed-off-by: Herbert Xu --- ChangeLog | 4 ++++ src/parser.c | 11 +++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe dash" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/ChangeLog b/ChangeLog index 8e0d276..6a64f74 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2014-10-30 Herbert Xu + + * Catch variable length expansions on non-existant specials. + 2014-10-28 Herbert Xu * Removed unnecessary pungetc on EOF from parser. diff --git a/src/parser.c b/src/parser.c index 382ddf2..382658e 100644 --- a/src/parser.c +++ b/src/parser.c @@ -1229,8 +1229,7 @@ varname: STPUTC(c, out); c = pgetc_eatbnl(); } while (is_digit(c)); - } - else if (is_special(c)) { + } else { int cc = c; c = pgetc_eatbnl(); @@ -1251,10 +1250,14 @@ varname: } } + if (!is_special(cc)) { + if (subtype == VSLENGTH) + subtype = 0; + goto badsub; + } + USTPUTC(cc, out); } - else - goto badsub; if (subtype == 0) { switch (c) {