From 30c628eeada274fc8b94f8f69f9df4f33cbfc773 Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Mon, 19 Aug 2013 12:24:45 -0700 Subject: [PATCH] libpayload: Make lzma truncation non-fatal. If the size the lzma header claims it needs is bigger than the space we have, print a message and continue rather than erroring out. Apparently the encoder is lazy sometimes and just puts a large value there regardless of what the actual size is. This was the original intention for this code, but an outdated version of the patch ended up being submitted. BUG=chrome-os-partner:19420 TEST=Built and booted on pit. Saw the recovery screen come up where it had not before. BRANCH=None Change-Id: Ibcf7ac0fd4b65ce85377421a4ee67b82d92d29d3 Signed-off-by: Gabe Black Reviewed-on: https://gerrit.chromium.org/gerrit/66235 Reviewed-by: Stefan Reinauer Commit-Queue: Gabe Black Tested-by: Gabe Black --- payloads/libpayload/liblzma/lzma.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/payloads/libpayload/liblzma/lzma.c b/payloads/libpayload/liblzma/lzma.c index af5555b3b0..23c95620ce 100644 --- a/payloads/libpayload/liblzma/lzma.c +++ b/payloads/libpayload/liblzma/lzma.c @@ -29,10 +29,8 @@ unsigned long ulzman(const unsigned char *src, unsigned long srcn, memcpy(properties, src, LZMA_PROPERTIES_SIZE); memcpy(&outSize, src + LZMA_PROPERTIES_SIZE, sizeof(outSize)); - if (outSize > dstn) { - printf("lzma: Output truncated.\n"); - return 0; - } + if (outSize > dstn) + outSize = dstn; if (LzmaDecodeProperties(&state.Properties, properties, LZMA_PROPERTIES_SIZE) != LZMA_RESULT_OK) { printf("lzma: Incorrect stream properties.\n");