projects
/
oweals
/
u-boot.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
colibri_imx6: fix video stdout in default environment
[oweals/u-boot.git]
/
lib
/
lzma
/
LzmaTools.c
diff --git
a/lib/lzma/LzmaTools.c
b/lib/lzma/LzmaTools.c
index 8d1165e11bddf12c52a3c75bf72220333601daa7..521258e623f5e65baddec622fa570926b42cb959 100644
(file)
--- a/
lib/lzma/LzmaTools.c
+++ b/
lib/lzma/LzmaTools.c
@@
-1,3
+1,4
@@
+// SPDX-License-Identifier: GPL-2.0+
/*
* Usefuls routines based on the LzmaTest.c file from LZMA SDK 4.65
*
/*
* Usefuls routines based on the LzmaTest.c file from LZMA SDK 4.65
*
@@
-5,8
+6,6
@@
* Luigi 'Comio' Mantellini (luigi.mantellini@idf-hit.com)
*
* Copyright (C) 1999-2005 Igor Pavlov
* Luigi 'Comio' Mantellini (luigi.mantellini@idf-hit.com)
*
* Copyright (C) 1999-2005 Igor Pavlov
- *
- * SPDX-License-Identifier: GPL-2.0+
*/
/*
*/
/*
@@
-20,6
+19,7
@@
#include <config.h>
#include <common.h>
#include <config.h>
#include <common.h>
+#include <log.h>
#include <watchdog.h>
#ifdef CONFIG_LZMA
#include <watchdog.h>
#ifdef CONFIG_LZMA
@@
-34,8
+34,8
@@
#include <linux/string.h>
#include <malloc.h>
#include <linux/string.h>
#include <malloc.h>
-static void *SzAlloc(void *p, size_t size) {
p = p;
return malloc(size); }
-static void SzFree(void *p, void *address) {
p = p;
free(address); }
+static void *SzAlloc(void *p, size_t size) { return malloc(size); }
+static void SzFree(void *p, void *address) { free(address); }
int lzmaBuffToBuffDecompress (unsigned char *outStream, SizeT *uncompressedSize,
unsigned char *inStream, SizeT length)
int lzmaBuffToBuffDecompress (unsigned char *outStream, SizeT *uncompressedSize,
unsigned char *inStream, SizeT length)
@@
-97,16
+97,23
@@
int lzmaBuffToBuffDecompress (unsigned char *outStream, SizeT *uncompressedSize,
g_Alloc.Alloc = SzAlloc;
g_Alloc.Free = SzFree;
g_Alloc.Alloc = SzAlloc;
g_Alloc.Free = SzFree;
+ /* Short-circuit early if we know the buffer can't hold the results. */
+ if (outSizeFull != (SizeT)-1 && *uncompressedSize < outSizeFull)
+ return SZ_ERROR_OUTPUT_EOF;
+
/* Decompress */
/* Decompress */
- outProcessed =
outSizeFull
;
+ outProcessed =
min(outSizeFull, *uncompressedSize)
;
WATCHDOG_RESET();
res = LzmaDecode(
outStream, &outProcessed,
inStream + LZMA_DATA_OFFSET, &compressedSize,
WATCHDOG_RESET();
res = LzmaDecode(
outStream, &outProcessed,
inStream + LZMA_DATA_OFFSET, &compressedSize,
- inStream, LZMA_PROPS_SIZE, LZMA_FINISH_
ANY
, &state, &g_Alloc);
+ inStream, LZMA_PROPS_SIZE, LZMA_FINISH_
END
, &state, &g_Alloc);
*uncompressedSize = outProcessed;
*uncompressedSize = outProcessed;
+
+ debug("LZMA: Uncompressed ............... 0x%zx\n", outProcessed);
+
if (res != SZ_OK) {
return res;
}
if (res != SZ_OK) {
return res;
}