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>
This commit is contained in:
Angel Pons 2022-10-11 21:45:30 +02:00 committed by Felix Singer
parent cdc156ebd1
commit bf541422e9
1 changed files with 1 additions and 3 deletions

View File

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