From c7b2b7c67dc8afb52c3dc8e9297e5ed81fa22674 Mon Sep 17 00:00:00 2001 From: Werner Zeh Date: Fri, 22 Jan 2016 19:43:01 +0100 Subject: cbfstool: Fix potential error when using hash attribute There can be an error when a cbfs file is added aligned or as xip-stage and hashing of this file is enabled. This commit resolves this error. Though adding a file to a fixed position while hashing is used can still lead to errors. Change-Id: Icd98d970891410538909db2830666bf159553133 Signed-off-by: Werner Zeh Reviewed-on: https://review.coreboot.org/13136 Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin Reviewed-by: Patrick Georgi --- util/cbfstool/cbfstool.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'util/cbfstool') diff --git a/util/cbfstool/cbfstool.c b/util/cbfstool/cbfstool.c index 0ac1eecc5eee..23787d89f4af 100644 --- a/util/cbfstool/cbfstool.c +++ b/util/cbfstool/cbfstool.c @@ -162,6 +162,10 @@ static int do_cbfs_locate(int32_t *cbfs_addr, size_t metadata_size) metadata_size += sizeof(struct cbfs_file_attr_position); } + /* Take care of the hash attribute if it is used */ + if (param.hash != VB2_HASH_INVALID) + metadata_size += sizeof(struct cbfs_file_attr_hash); + int32_t address = cbfs_locate_entry(&image, buffer.size, param.pagesize, param.alignment, metadata_size); buffer_delete(&buffer); -- cgit v1.2.3