From f87c20a00dca412ad8fa255ef38fd954762afa4b Mon Sep 17 00:00:00 2001 From: Alexandru Gagniuc Date: Sun, 8 Dec 2013 17:46:40 -0600 Subject: cbfstool: Properly handle EOF in update_fit step During the update_fit step, 'file_length' is used to determine how many bytes are left in the CBFS file. It was decremented in a loop from an array 'mcus[num_mcus].size', but 'num_mcus' was incremented right before. Since 'mcus' is memset(0) externally, 'file_length' was never decremented. The loop exited when it reached a dummy terminator, usually 48 bytes of 0 which are internationally added to microcode blobs in coreboot. However, if that terminator is removed, the loop doesn't stop and continues until it segfaults. Change-Id: I840727add69379ffef75b694d90402ed89769e3b Signed-off-by: Alexandru Gagniuc Reviewed-on: http://review.coreboot.org/4508 Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin --- util/cbfstool/fit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'util') diff --git a/util/cbfstool/fit.c b/util/cbfstool/fit.c index 02cfaee21d..c76ba480ad 100644 --- a/util/cbfstool/fit.c +++ b/util/cbfstool/fit.c @@ -216,8 +216,8 @@ static int parse_microcode_blob(struct cbfs_image *image, /* Proceed to next payload. */ current_offset += mcus[num_mcus].size; - num_mcus++; file_length -= mcus[num_mcus].size; + num_mcus++; /* Reached limit of FIT entries. */ if (num_mcus == *total_mcus) -- cgit v1.2.3