From bf541422e9ed40ad0903f8e4a46c0f00d3f141a6 Mon Sep 17 00:00:00 2001 From: Angel Pons Date: Tue, 11 Oct 2022 21:45:30 +0200 Subject: mb/prodrive/hermes: Use `snprintf()` to handle strings Strings in C are highly cursed. Use `snprintf()` to minimize the potential of running into undefined behavior in the future. Change-Id: I3caef25bc7676ac84bb1c40efe6d16f50f8f4d26 Signed-off-by: Angel Pons Reviewed-on: https://review.coreboot.org/c/coreboot/+/68323 Reviewed-by: Patrick Georgi Tested-by: build bot (Jenkins) Reviewed-by: Felix Singer --- src/mainboard/prodrive/hermes/mainboard.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/mainboard/prodrive/hermes/mainboard.c b/src/mainboard/prodrive/hermes/mainboard.c index e94a8bc90c..64494b175a 100644 --- a/src/mainboard/prodrive/hermes/mainboard.c +++ b/src/mainboard/prodrive/hermes/mainboard.c @@ -178,9 +178,7 @@ static const char *format_pn(const char *prefix, size_t offset) const char *part_num = eeprom_read_serial(offset, "N/A"); - memset(buffer, 0, sizeof(buffer)); - strcpy(buffer, prefix); - strcpy(buffer + strlen(prefix), part_num); + snprintf(buffer, sizeof(buffer), "%s%s", prefix, part_num); return buffer; } -- cgit v1.2.3