projects/linux·commit aa1e816f

[PATCH] Fix potential NULL pointer deref in gen_init_cpio

aa1e816f · Jesper Juhl <[email protected]> · 2006-04-18 22:21:54 -07:00

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]>
Commit
aa1e816fc92215f94bdfd90107baae8fdc2440d1
Parents
9dfb563b

Changes

1 files changed · +3 −1

FileStatusAddDelContent
usr/gen_init_cpio.cmodified+3−1View file

usr/gen_init_cpio.c

View file
diff --git a/usr/gen_init_cpio.c b/usr/gen_init_cpio.c
index 33dbcbf..83acd6c 100644
--- a/usr/gen_init_cpio.c
+++ b/usr/gen_init_cpio.c
@@ -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);
}