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 <werner.zeh@siemens.com>
Reviewed-on: https://review.coreboot.org/13136
Tested-by: build bot (Jenkins)
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-by: Patrick Georgi <pgeorgi@google.com>
This commit is contained in:
Werner Zeh 2016-01-22 19:43:01 +01:00
parent 4408409d05
commit c7b2b7c67d
1 changed files with 4 additions and 0 deletions

View File

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