summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHung-Te Lin <hungte@chromium.org>2014-09-11 11:50:03 +0800
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-09-11 08:06:04 +0000
commit3c8d29c204c6feb91ad951e2e1c5190d4ca98a13 (patch)
treeb76ac3669a91c1138631a2dda9d143f8c691dd35
parentf510973497a430c1bb41d9b7e996d02fb7f7179e (diff)
downloadvboot-factory-samus-6207.B.tar.gz
futility: Wipe GBB data before writing new values.factory-samus-6207.B
The previous version of gbb_utility always zeros data before writing new values and we should keep this behavior, to simplify firmware hash calculation and potential security concern. BRANCH=none BUG=chromium:413066 TEST=emerge gbb_utility; factory/bin/gooftool get_firmware_hash bios.bin Original-Change-Id: Ic97a118cefc9698d52d9370b627670ff103d5e23 Change-Id: If38e15f35ee491cc80f96b360c63ee25f71c1854 Reviewed-on: https://chromium-review.googlesource.com/217700 Reviewed-by: Hung-Te Lin <hungte@chromium.org> Commit-Queue: Hung-Te Lin <hungte@chromium.org> Tested-by: Hung-Te Lin <hungte@chromium.org>
-rw-r--r--futility/cmd_gbb_utility.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/futility/cmd_gbb_utility.c b/futility/cmd_gbb_utility.c
index 9810058d..85b47829 100644
--- a/futility/cmd_gbb_utility.c
+++ b/futility/cmd_gbb_utility.c
@@ -342,6 +342,9 @@ static int read_from_file(const char *msg, const char *filename,
goto done_close;
}
+ /* Wipe existing data. */
+ memset(start, 0, size);
+
/* It's okay if we read less than size. That's just the max. */
count = fread(start, 1, size, fp);
if (ferror(fp)) {
@@ -568,6 +571,9 @@ static int do_gbb_utility(int argc, char *argv[])
gbb->hwid_size);
errorcnt++;
} else {
+ /* Wipe data before writing new value. */
+ memset(gbb_base + gbb->hwid_offset, 0,
+ gbb->hwid_size);
strcpy((char *)(gbb_base + gbb->hwid_offset),
opt_hwid);
}