0041-lzma-fixup.patch 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. Variable uncompressedSize references the space available, while outSizeFull is
  5. the actual expected uncompressed size. Using the wrong value causes LzmaDecode
  6. to return SZ_ERROR_INPUT_EOF. Problem was introduced in commit afca294. While
  7. at it add additional debug message.
  8. Signed-off-by: Antonios Vamporakis <ant@area128.com>
  9. CC: Kees Cook <keescook@chromium.org>
  10. CC: Simon Glass <sjg@chromium.org>
  11. CC: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
  12. CC: Luka Perkov <luka@openwrt.org>
  13. ---
  14. lib/lzma/LzmaTools.c | 5 ++++-
  15. 1 file changed, 4 insertions(+), 1 deletion(-)
  16. diff --git a/lib/lzma/LzmaTools.c b/lib/lzma/LzmaTools.c
  17. index 0aec2f9..90d31cd 100644
  18. --- a/lib/lzma/LzmaTools.c
  19. +++ b/lib/lzma/LzmaTools.c
  20. @@ -102,7 +102,7 @@ int lzmaBuffToBuffDecompress (unsigned char *outStream, SizeT *uncompressedSize,
  21. return SZ_ERROR_OUTPUT_EOF;
  22. /* Decompress */
  23. - outProcessed = *uncompressedSize;
  24. + outProcessed = outSizeFull;
  25. WATCHDOG_RESET();
  26. @@ -111,6 +111,9 @@ int lzmaBuffToBuffDecompress (unsigned char *outStream, SizeT *uncompressedSize,
  27. inStream + LZMA_DATA_OFFSET, &compressedSize,
  28. inStream, LZMA_PROPS_SIZE, LZMA_FINISH_END, &state, &g_Alloc);
  29. *uncompressedSize = outProcessed;
  30. +
  31. + debug("LZMA: Uncompresed ................ 0x%zx\n", outProcessed);
  32. +
  33. if (res != SZ_OK) {
  34. return res;
  35. }
  36. --
  37. 1.8.3.2