This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug libc/18096] null deref in wordexp/parse_dollars/parse_arith
- From: "konstantin.s.serebryany at gmail dot com" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sourceware dot org
- Date: Mon, 09 Mar 2015 16:24:32 +0000
- Subject: [Bug libc/18096] null deref in wordexp/parse_dollars/parse_arith
- Auto-submitted: auto-generated
- References: <bug-18096-131 at http dot sourceware dot org/bugzilla/>
https://sourceware.org/bugzilla/show_bug.cgi?id=18096
--- Comment #1 from Kostya Serebryany <konstantin.s.serebryany at gmail dot com> ---
Another similar looking, but on different line:
#include <wordexp.h>
#include <string.h>
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.