util/nvramtool: Bail out on unaligned multi-byte entries

coreboot doesn't support CMOS options that are not byte aligned but
span multiple bytes. So treat them as error.

Change-Id: I2bcff62f153932e9c6646b4ce08e8da1c1532947
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.coreboot.org/18246
Reviewed-by: Philippe Mathieu-Daudé <philippe.mathieu.daude@gmail.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Arthur Heymans <arthur@aheymans.xyz>
This commit is contained in:
Nico Huber
2017-01-26 23:22:46 +01:00
parent 00b9f4c4b1
commit 3af6985050
4 changed files with 16 additions and 0 deletions

View File

@@ -169,6 +169,9 @@ int add_cmos_entry(const cmos_entry_t * e, const cmos_entry_t ** conflict)
if (e->length < 1)
return LAYOUT_ENTRY_BAD_LENGTH;
if (e->bit % 8 && e->bit / 8 != (e->bit + e->length - 1) / 8)
return LAYOUT_MULTIBYTE_ENTRY_NOT_ALIGNED;
if ((new_entry =
(cmos_entry_item_t *) malloc(sizeof(*new_entry))) == NULL)
out_of_memory();