]> Git Repo - linux.git/commitdiff
[PATCH] Fix potential NULL pointer deref in gen_init_cpio
authorJesper Juhl <[email protected]>
Wed, 19 Apr 2006 05:21:54 +0000 (22:21 -0700)
committerLinus Torvalds <[email protected]>
Wed, 19 Apr 2006 16:13:52 +0000 (09:13 -0700)
Fix potential NULL pointer deref in gen_init_cpio.c spotted by coverity
checker.  This fixes coverity bug #86

Without this patch we risk dereferencing a NULL `type' in the
"if ('\n' == *type) {" line.

Signed-off-by: Jesper Juhl <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
usr/gen_init_cpio.c

index 33dbcbf77c5b0d5713d4c6774e5c7f863d4750fb..83acd6cc0b3cd70325ec383eb8fdc309918a0a98 100644 (file)
@@ -471,6 +471,7 @@ int main (int argc, char *argv[])
                                "ERROR: incorrect format, could not locate file type line %d: '%s'\n",
                                line_nr, line);
                        ec = -1;
+                       break;
                }
 
                if ('\n' == *type) {
@@ -506,7 +507,8 @@ int main (int argc, char *argv[])
                                line_nr, line);
                }
        }
-       cpio_trailer();
+       if (ec == 0)
+               cpio_trailer();
 
        exit(ec);
 }
This page took 0.051566 seconds and 4 git commands to generate.