aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAngel Pons <th3fanbus@gmail.com>2022-10-11 21:45:30 +0200
committerFelix Singer <felixsinger@posteo.net>2022-10-13 06:46:23 +0000
commitbf541422e9ed40ad0903f8e4a46c0f00d3f141a6 (patch)
tree7b0a642856e445aa28eb53e76fd8226f708dd588
parentcdc156ebd17655646eb178784e96036f58ac7859 (diff)
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 <th3fanbus@gmail.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/68323 Reviewed-by: Patrick Georgi <patrick@coreboot.org> Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Felix Singer <felixsinger@posteo.net>
-rw-r--r--src/mainboard/prodrive/hermes/mainboard.c4
1 files changed, 1 insertions, 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;
}