From 3c8d29c204c6feb91ad951e2e1c5190d4ca98a13 Mon Sep 17 00:00:00 2001 From: Hung-Te Lin Date: Thu, 11 Sep 2014 11:50:03 +0800 Subject: futility: Wipe GBB data before writing new values. 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 Commit-Queue: Hung-Te Lin Tested-by: Hung-Te Lin --- futility/cmd_gbb_utility.c | 6 ++++++ 1 file changed, 6 insertions(+) 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); } -- cgit v1.2.1