Skip to content

Commit

Permalink
[PATCH] Fix potential NULL pointer deref in gen_init_cpio
Browse files Browse the repository at this point in the history
Fix potential NULL pointer deref in gen_init_cpio.c spotted by coverity
checker.  This fixes coverity bug torvalds#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]>
  • Loading branch information
Jesper Juhl authored and Linus Torvalds committed Apr 19, 2006
1 parent 9dfb563 commit aa1e816
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion usr/gen_init_cpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -506,7 +507,8 @@ int main (int argc, char *argv[])
line_nr, line);
}
}
cpio_trailer();
if (ec == 0)
cpio_trailer();

exit(ec);
}

0 comments on commit aa1e816

Please sign in to comment.