From 72d77a9a0c1030c872f0245ae7ed6e74b54abac0 Mon Sep 17 00:00:00 2001 From: Joel Kitching Date: Wed, 18 Jul 2018 13:23:52 +0800 Subject: [PATCH] cbfstool/extract: ignore compression field for some payload segments When extracting a payload from CBFS, ignore compression fields for these types of payload segments: - PAYLOAD_SEGMENT_ENTRY - PAYLOAD_SEGMENT_BSS - PAYLOAD_SEGMENT_PARAMS These types of payload segments cannot be compressed, and in certain cases are being erroneously labeled as compressed, causing errors when extracting the payload. For an example of this problem, see creation of PAYLOAD_SEGMENT_ENTRY segments in cbfs-mkpayload.c, where the only field that is written to is |load_addr|. Also, add a linebreak to an ERROR line. BUG=https://ticket.coreboot.org/issues/170 TEST=cbfstool tianocore.cbfs extract -m x86 -n payload -f /tmp/payload -v -v Change-Id: I8c5c40205d648799ea577ad0c5bee6ec2dd7d05f Signed-off-by: kitching@google.com Reviewed-on: https://review.coreboot.org/27520 Reviewed-by: Hung-Te Lin Reviewed-by: Paul Menzel Reviewed-by: Aaron Durbin Reviewed-by: Julius Werner Tested-by: build bot (Jenkins) --- util/cbfstool/cbfs_image.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/util/cbfstool/cbfs_image.c b/util/cbfstool/cbfs_image.c index e5334831fd..4b6bda929a 100644 --- a/util/cbfstool/cbfs_image.c +++ b/util/cbfstool/cbfs_image.c @@ -925,14 +925,6 @@ static int cbfs_payload_decompress(struct cbfs_payload_segment *segments, struct buffer tbuff; size_t decomp_size; - /* The payload uses an unknown compression algorithm. */ - decompress = decompression_function(segments[i].compression); - if (decompress == NULL) { - ERROR("Unknown decompression algorithm: %u", - segments[i].compression); - return -1; - } - /* Segments BSS and ENTRY do not have binary data. */ if (segments[i].type == PAYLOAD_SEGMENT_BSS || segments[i].type == PAYLOAD_SEGMENT_ENTRY) { @@ -947,6 +939,14 @@ static int cbfs_payload_decompress(struct cbfs_payload_segment *segments, continue; } + /* The payload uses an unknown compression algorithm. */ + decompress = decompression_function(segments[i].compression); + if (decompress == NULL) { + ERROR("Unknown decompression algorithm: %u\n", + segments[i].compression); + return -1; + } + if (buffer_create(&tbuff, segments[i].mem_len, "segment")) { buffer_delete(&new_buffer); return -1;