From patchwork Sun Jul 12 07:49:17 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?T25kxZllaiBCw61sa2E=?= X-Patchwork-Id: 494072 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id D77B91402A7 for ; Sun, 12 Jul 2015 17:49:35 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b=lsST1Los; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:subject:message-id:mime-version :content-type; q=dns; s=default; b=XPrJLA34o45JxiR19gEXHa0GfuZST tAX126QNdKuDEo2f38W+t8hzk6++O1ZwGbz8hTFGGWMcaPe7xsMu/LkK7URdnsVE 21whtasD5sQ44B7cDvJ+zeQXEZuAlkx9wACHDnhrcnvNyxJkoL8IVPHZcr6gHa3V w23bZsTtqhFWjk= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:subject:message-id:mime-version :content-type; s=default; bh=2nvZkA6/Tqp3e7fLVKnMyZ+dD0Y=; b=lsS T1LostfTpG8KHwVid3SwKVF/whcggz1IGDoK2jQLHRxmz5k/gb/dqtmN4kvqr8mt C9a7auaXpEjdmKgcofuQswBYje0Mx3NIMPbiQibVM0Vz06QqpFONwD6teeqZgukP rYKKrOfzPt10G3WF7W6K8ATV3dYgGZtFbzdbuamo= Received: (qmail 115637 invoked by alias); 12 Jul 2015 07:49:27 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 115622 invoked by uid 89); 12 Jul 2015 07:49:26 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.7 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, SPF_NEUTRAL autolearn=no version=3.3.2 X-HELO: popelka.ms.mff.cuni.cz Date: Sun, 12 Jul 2015 09:49:17 +0200 From: =?utf-8?B?T25kxZllaiBCw61sa2E=?= To: libc-alpha@sourceware.org Subject: [PATCH][BZ #18096] Handle null dereferences in wordexp Message-ID: <20150712074917.GA6245@domone> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) Hi, Kostya, and Carlos wrote this patch on bugzilla but I didn't seen it on libc-alpha. These look good for me. Carlos, could you commit it? diff --git a/posix/wordexp.c b/posix/wordexp.c index e711d43..d3f3764 100644 --- a/posix/wordexp.c +++ b/posix/wordexp.c @@ -740,7 +740,7 @@ parse_arith (char **word, size_t *word_length, size_t *max_length, ++(*offset); /* Go - evaluate. */ - if (*expr && eval_expr (expr, &numresult) != 0) + if (expr && *expr && eval_expr (expr, &numresult) != 0) { free (expr); return WRDE_SYNTAX; @@ -778,7 +778,7 @@ parse_arith (char **word, size_t *word_length, size_t *max_length, long int numresult = 0; /* Go - evaluate. */ - if (*expr && eval_expr (expr, &numresult) != 0) + if (expr && *expr && eval_expr (expr, &numresult) != 0) { free (expr); return WRDE_SYNTAX; @@ -1843,11 +1843,11 @@ envsubst: if (!colon_seen && value) /* Substitute NULL */ ; - else + else if (flags & WRDE_SHOWERR) { const char *str = pattern; - if (str[0] == '\0') + if (str && str[0] == '\0') str = _("parameter null or not set"); __fxprintf (NULL, "%s: %s\n", env, str);