coreboot/util/cbfstool
Gabe Black b9f622a554 cbfstool: If compression fails, warn and use the uncompressed data.
The LZMA compression algorithm, currently the only one available, will fail
if you ask it to write more data to the output than you've given it space for.
The code that calls into LZMA allocates an output buffer the same size as the
input, so if compression increases the size of the output the call will fail.
The caller(s) were written to assume that the call succeeded and check the
returned length to see if the size would have increased, but that will never
happen with LZMA.

Rather than try to rework the LZMA library to dynamically resize the output
buffer or try to guess what the maximal size the data could expand to is, this
change makes the caller simply print a warning and disable compression if the
call failed for some reason.

This may lead to images that are larger than necessary if compression fails
for some other reason and the user doesn't notice, but since compression
errors were ignored entirely until very recently that will hopefully not be
a problem in practice, and we should be guarnateed to at least produce a
correct image.

BUG=chrome-os-partner:26060
TEST=Built for link and saw that a segment whos size had been set to 0 now has
the correct size and is loaded correctly. Booted into RW depthcharge which had
been broken before this change.
BRANCH=None

Change-Id: I5f59529c2d48e9c4c2e011018b40ec336c4fcca8
Signed-off-by: Gabe Black <gabeblack@google.com>
Reviewed-on: https://chromium-review.googlesource.com/187365
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Tested-by: Gabe Black <gabeblack@chromium.org>
Commit-Queue: Gabe Black <gabeblack@chromium.org>
2014-02-25 05:13:54 +00:00
..
lzma cbfstool: Propogate compression errors back to the caller. 2014-02-24 13:35:19 +00:00
cbfs-mkpayload.c cbfstool: If compression fails, warn and use the uncompressed data. 2014-02-25 05:13:54 +00:00
cbfs-mkstage.c cbfstool: If compression fails, warn and use the uncompressed data. 2014-02-25 05:13:54 +00:00
cbfs.h Add section header parsing and use it in the mk-payload step 2014-01-24 23:51:48 +00:00
cbfs_image.c UPSTREAM: cbfstool: correct size left calculation for "empty" entries 2014-02-19 18:36:36 +00:00
cbfs_image.h cbfstool: add code to serialize the header using the new xdr functions 2014-01-25 05:54:30 +00:00
cbfstool.c Add section header parsing and use it in the mk-payload step 2014-01-24 23:51:48 +00:00
coff.h GPLv2 notice: Unify all files to just use one space in »MA 02110-1301« 2013-03-01 10:16:08 +01:00
common.c Add section header parsing and use it in the mk-payload step 2014-01-24 23:51:48 +00:00
common.h cbfstool: Propogate compression errors back to the caller. 2014-02-24 13:35:19 +00:00
compress.c cbfstool: Propogate compression errors back to the caller. 2014-02-24 13:35:19 +00:00
elf.h aarch64: Add ELF support 2014-02-21 19:31:15 +00:00
elfheaders.c aarch64: Add ELF support 2014-02-21 19:31:15 +00:00
EXAMPLE cbfstool: Update example file. 2013-02-04 11:12:15 +01:00
fit.c Add section header parsing and use it in the mk-payload step 2014-01-24 23:51:48 +00:00
fit.h cbfstool: Add update-fit command 2013-03-27 01:25:12 +01:00
fv.h GPLv2 notice: Unify all files to just use one space in »MA 02110-1301« 2013-03-01 10:16:08 +01:00
Makefile Add section header parsing and use it in the mk-payload step 2014-01-24 23:51:48 +00:00
Makefile.inc Add section header parsing and use it in the mk-payload step 2014-01-24 23:51:48 +00:00
swab.h Various fixes to cbfstool. 2011-10-24 20:29:29 +02:00
xdr.c cbfs: fix issues with word size and endianness. 2013-12-11 09:04:54 +00:00