add chaos_calmer branch
[15.05/openwrt.git] / package / boot / uboot-lantiq / patches / 0041-lzma-fixup.patch
1 From: Antonios Vamporakis <ant@area128.com>
2 Date: Tue, 31 Dec 2013 01:05:42 +0100
3 Subject: [PATCH] lzma: fix buffer bound check error
4
5 Variable uncompressedSize references the space available, while outSizeFull is
6 the actual expected uncompressed size. Using the wrong value causes LzmaDecode
7 to return SZ_ERROR_INPUT_EOF. Problem was introduced in commit afca294. While
8 at it add additional debug message.
9
10 Signed-off-by: Antonios Vamporakis <ant@area128.com>
11 CC: Kees Cook <keescook@chromium.org>
12 CC: Simon Glass <sjg@chromium.org>
13 CC: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
14 CC: Luka Perkov <luka@openwrt.org>
15 ---
16  lib/lzma/LzmaTools.c | 5 ++++-
17  1 file changed, 4 insertions(+), 1 deletion(-)
18
19 diff --git a/lib/lzma/LzmaTools.c b/lib/lzma/LzmaTools.c
20 index 0aec2f9..90d31cd 100644
21 --- a/lib/lzma/LzmaTools.c
22 +++ b/lib/lzma/LzmaTools.c
23 @@ -102,7 +102,7 @@ int lzmaBuffToBuffDecompress (unsigned char *outStream, SizeT *uncompressedSize,
24          return SZ_ERROR_OUTPUT_EOF;
25  
26      /* Decompress */
27 -    outProcessed = *uncompressedSize;
28 +    outProcessed = outSizeFull;
29  
30      WATCHDOG_RESET();
31  
32 @@ -111,6 +111,9 @@ int lzmaBuffToBuffDecompress (unsigned char *outStream, SizeT *uncompressedSize,
33          inStream + LZMA_DATA_OFFSET, &compressedSize,
34          inStream, LZMA_PROPS_SIZE, LZMA_FINISH_END, &state, &g_Alloc);
35      *uncompressedSize = outProcessed;
36 +
37 +    debug("LZMA: Uncompresed ................ 0x%zx\n", outProcessed);
38 +
39      if (res != SZ_OK)  {
40          return res;
41      }
42 -- 
43 1.8.3.2
44