[coreboot-gerrit] New patch to review for coreboot: chromeos: vpd: properly null terminate values

Patrick Georgi (pgeorgi@google.com) gerrit at coreboot.org
Mon Jun 22 19:25:35 CEST 2015

Patrick Georgi (pgeorgi at google.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/10627


commit 47781ddd92f882eb36c44438aeb963f649daf124
Author: Stephen Barber <smbarber at chromium.org>
Date:   Fri Jun 19 12:56:34 2015 -0700

    chromeos: vpd: properly null terminate values
    VPD strings are not null terminated, so we can't use strcpy
    on them in cros_vpd_gets.
    TEST=add serial_number followed by cam_calib_data to VPD on smaug;
    make sure that smaug boots and serial number matches exactly (no garbage)
    Change-Id: Id72885517b3d0b1934ba329c1ef0d89a67bd2bb4
    Signed-off-by: Patrick Georgi <pgeorgi at chromium.org>
    Original-Commit-Id: 56bbe6688b11043360a046a250d1ea93db4d9f0e
    Original-Change-Id: I811dfc2f0830a91410eb69961a6565080ff78267
    Original-Signed-off-by: Stephen Barber <smbarber at chromium.org>
    Original-Reviewed-on: https://chromium-review.googlesource.com/280836
    Original-Reviewed-by: David Hendricks <dhendrix at chromium.org>
    Original-Reviewed-by: Benson Leung <bleung at chromium.org>
 src/vendorcode/google/chromeos/cros_vpd.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/vendorcode/google/chromeos/cros_vpd.c b/src/vendorcode/google/chromeos/cros_vpd.c
index fed1d82..f9aec88 100644
--- a/src/vendorcode/google/chromeos/cros_vpd.c
+++ b/src/vendorcode/google/chromeos/cros_vpd.c
@@ -132,7 +132,8 @@ char *cros_vpd_gets(const char *key, char *buffer, int size)
 		return NULL;
 	if (size > (string_size + 1)) {
-		strcpy(buffer, string_address);
+		memcpy(buffer, string_address, string_size);
+		buffer[string_size] = '\0';
 	} else {
 		memcpy(buffer, string_address, size - 1);
 		buffer[size - 1] = '\0';

More information about the coreboot-gerrit mailing list