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
Originial-Change-Id: Ic97a118cefc9698d52d9370b627670ff103d5e23

Change-Id: If199040909c4719c89dbc52fd7488d69abd981e5
Reviewed-on: https://chromium-review.googlesource.com/217478
Reviewed-by: Hung-Te Lin <hungte@chromium.org>
Commit-Queue: Hung-Te Lin <hungte@chromium.org>
Tested-by: Hung-Te Lin <hungte@chromium.org>
diff --git a/futility/cmd_gbb_utility.c b/futility/cmd_gbb_utility.c
index 9810058..85b4782 100644
--- a/futility/cmd_gbb_utility.c
+++ b/futility/cmd_gbb_utility.c
@@ -342,6 +342,9 @@
 		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 @@
 					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);
 			}