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 <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);
 			}