From: Jesper Juhl <jesper.juhl@gmail.com>
To: Richard Henderson <rth@tamu.edu>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Jesper Juhl <jesper.juhl@gmail.com>
Subject: [PATCH] Avoid potential NULL deref in scripts/genksyms/lex.l
Date: Sun, 24 Jun 2007 23:40:03 +0200 [thread overview]
Message-ID: <200706242340.03871.jesper.juhl@gmail.com> (raw)
strchr() returns NULL in case the string is not found and if that
happens we risk dereferencing a NULL pointer. It never hurts to
check for that condition and exit normally with an error rather
than crashing.
(no, the indentation is not according to CodingStyle, it's simply
following whatever else is in that file)
Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
---
scripts/genksyms/lex.l | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/scripts/genksyms/lex.l b/scripts/genksyms/lex.l
index 5e544a0..28edc0c 100644
--- a/scripts/genksyms/lex.l
+++ b/scripts/genksyms/lex.l
@@ -154,6 +154,8 @@ repeat:
file = strchr(yytext, '\"')+1;
e = strchr(file, '\"');
+ if (!file || !e)
+ exit(1);
*e = '\0';
cur_filename = memcpy(xmalloc(e-file+1), file, e-file+1);
cur_line = atoi(yytext+2);
next reply other threads:[~2007-06-24 21:40 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-24 21:40 Jesper Juhl [this message]
2007-06-24 21:58 ` Andrew Morton
2007-06-24 22:02 ` Jesper Juhl
2007-06-24 23:00 ` Andrew Morton
2007-06-24 23:08 ` Jesper Juhl
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200706242340.03871.jesper.juhl@gmail.com \
--to=jesper.juhl@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rth@tamu.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®