Hello Nico Huber,
I'd like you to do a code review. Please visit
https://review.coreboot.org/c/coreboot/+/31348
to review the following change.
Change subject: option table: Don't pad string entries with garbage ......................................................................
option table: Don't pad string entries with garbage
set_option_with() expects a buffer of the exact size of the option.
Change-Id: I21332394f88cf2daa4f733a544627d6d3c6ef26c Signed-off-by: Nico Huber nico.huber@secunet.com --- M payloads/libpayload/drivers/options.c 1 file changed, 5 insertions(+), 1 deletion(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/48/31348/1
diff --git a/payloads/libpayload/drivers/options.c b/payloads/libpayload/drivers/options.c index 70c2b17..2b0a42e 100644 --- a/payloads/libpayload/drivers/options.c +++ b/payloads/libpayload/drivers/options.c @@ -357,7 +357,11 @@ *(u64*)raw = strtoull(value, NULL, 0); break; case 's': - raw = strdup(value); + raw = malloc(cmos_entry->length); + if (!raw) + return 1; + memset(raw, 0x00, cmos_entry->length); + strncpy(raw, value, cmos_entry->length); break; case 'e': cmos_enum = lookup_cmos_enum_by_label(option_table, cmos_entry->config_id, value);