[PATCH] Avoid potential NULL deref in scripts/genksyms/lex.l

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <[email protected]>
---

 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);
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux