vbutil_kernel: gracefully exit if the config file is bad
If the config file is specified in the parameter list but we aren't able
to open (or read) the file, vbutil_kernel should return an error instead
of crashing with a Segmentation Fault.
BUG=chromium-os:33087
TEST=manual
Invoke vbutil_kernel with a bogus path for the config file (--config).
Change-Id: I32dab7c381b9094f4015a554bc59989f1bb329ef
Signed-off-by: Lucian Cojocar <cojocar@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/28740
Reviewed-by: Randall Spangler <rspangler@chromium.org>
diff --git a/utility/vbutil_kernel.c b/utility/vbutil_kernel.c
index 29d508a..586ad77 100644
--- a/utility/vbutil_kernel.c
+++ b/utility/vbutil_kernel.c
@@ -839,6 +839,8 @@
if (config_file) {
Debug("Reading %s\n", config_file);
g_config_data = ReadConfigFile(config_file, &g_config_size);
+ if (!g_config_data)
+ Fatal("Error reading config file.\n");
}
if (vmlinuz_file)
@@ -900,6 +902,8 @@
free(g_config_data);
Debug("Reading %s\n", config_file);
g_config_data = ReadConfigFile(config_file, &g_config_size);
+ if (!g_config_data)
+ Fatal("Error reading config file.\n");
}
if (keyblock_file) {