From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 94981 invoked by alias); 9 Mar 2015 16:24:36 -0000 Mailing-List: contact glibc-bugs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: glibc-bugs-owner@sourceware.org Received: (qmail 94938 invoked by uid 48); 9 Mar 2015 16:24:32 -0000 From: "konstantin.s.serebryany at gmail dot com" To: glibc-bugs@sourceware.org Subject: [Bug libc/18096] null deref in wordexp/parse_dollars/parse_arith Date: Mon, 09 Mar 2015 16:24:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: glibc X-Bugzilla-Component: libc X-Bugzilla-Version: unspecified X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: konstantin.s.serebryany at gmail dot com X-Bugzilla-Status: NEW X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-03/txt/msg00078.txt.bz2 https://sourceware.org/bugzilla/show_bug.cgi?id=18096 --- Comment #1 from Kostya Serebryany --- Another similar looking, but on different line: #include #include int main() { char *p = strdup("$(())"); wordexp_t w; wordexp(p, &w, 0); } #0 0x7fc1c04a26f6 in parse_arith /build/buildd/eglibc-2.19/posix/wordexp.c:736 #1 0x7fc1c04a0123 in parse_dollars /build/buildd/eglibc-2.19/posix/wordexp.c:2096 #2 0x7fc1c04a2feb in wordexp /build/buildd/eglibc-2.19/posix/wordexp.c:2348 The following stops the bug for me: --- a/posix/wordexp.c +++ b/posix/wordexp.c @@ -736,7 +736,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; @@ -774,7 +774,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; -- You are receiving this mail because: You are on the CC list for the bug.