From 9bfe2c9f267579454fc63688fde3d023b338d938 Mon Sep 17 00:00:00 2001 From: Bill Richardson Date: Tue, 27 Jan 2015 12:21:04 -0800 Subject: futility: vbutil_kernel should check the kernel a bit more Trying to repack an invalid kernel blob should notice and complain that the blob is invalid instead of just segfaulting. BUG=chromium:452353 BRANCH=ToT TEST=manual See the bug report for an example test case. Many more tests are being added as futility development continues. Change-Id: I2bbfb8ab41a0f596b25a76f76f74d7b47b7e4a17 Signed-off-by: Bill Richardson Reviewed-on: https://chromium-review.googlesource.com/243583 Reviewed-by: Mike Frysinger Reviewed-by: Randall Spangler --- futility/cmd_vbutil_kernel.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/futility/cmd_vbutil_kernel.c b/futility/cmd_vbutil_kernel.c index 3b2643e4..40deba9e 100644 --- a/futility/cmd_vbutil_kernel.c +++ b/futility/cmd_vbutil_kernel.c @@ -21,6 +21,7 @@ #include "futility.h" #include "host_common.h" #include "kernel_blob.h" +#include "traversal.h" #include "vb1_helper.h" static void Fatal(const char *format, ...) @@ -461,6 +462,11 @@ static int do_vbutil_kernel(int argc, char *argv[]) /* Load the kernel partition */ kpart_data = ReadOldKPartFromFileOrDie(oldfile, &kpart_size); + /* Make sure we have a kernel partition */ + if (FILE_TYPE_KERN_PREAMBLE != + futil_what_file_type_buf(kpart_data, kpart_size)) + Fatal("%s is not a kernel blob\n", oldfile); + kblob_data = UnpackKPart(kpart_data, kpart_size, opt_pad, &keyblock, &preamble, &kblob_size); -- cgit v1.2.3