From 3af69850507e6e6afac7c0de689bbd8545a6085a Mon Sep 17 00:00:00 2001 From: Nico Huber Date: Thu, 26 Jan 2017 23:22:46 +0100 Subject: util/nvramtool: Bail out on unaligned multi-byte entries MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-on: https://review.coreboot.org/18246 Reviewed-by: Philippe Mathieu-Daudé Tested-by: build bot (Jenkins) Reviewed-by: Arthur Heymans --- util/nvramtool/layout.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'util/nvramtool/layout.c') diff --git a/util/nvramtool/layout.c b/util/nvramtool/layout.c index 241dd19c6d..6fdb28216b 100644 --- a/util/nvramtool/layout.c +++ b/util/nvramtool/layout.c @@ -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(); -- cgit v1.2.3