projects
/
oweals
/
u-boot.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge https://gitlab.denx.de/u-boot/custodians/u-boot-spi
[oweals/u-boot.git]
/
lib
/
gunzip.c
diff --git
a/lib/gunzip.c
b/lib/gunzip.c
index 832b3064e7614bc7c74159ca04f62b3122420356..bee3b9261f3449c438c43fac77bac45cde127238 100644
(file)
--- a/
lib/gunzip.c
+++ b/
lib/gunzip.c
@@
-1,19
+1,21
@@
+// SPDX-License-Identifier: GPL-2.0+
/*
* (C) Copyright 2000-2006
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
/*
* (C) Copyright 2000-2006
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
- *
- * SPDX-License-Identifier: GPL-2.0+
*/
#include <common.h>
*/
#include <common.h>
-#include <
watchdog
.h>
+#include <
blk
.h>
#include <command.h>
#include <console.h>
#include <command.h>
#include <console.h>
+#include <div64.h>
+#include <gzip.h>
#include <image.h>
#include <malloc.h>
#include <memalign.h>
#include <image.h>
#include <malloc.h>
#include <memalign.h>
+#include <u-boot/crc.h>
+#include <watchdog.h>
#include <u-boot/zlib.h>
#include <u-boot/zlib.h>
-#include <div64.h>
#define HEADER0 '\x1f'
#define HEADER1 '\x8b'
#define HEADER0 '\x1f'
#define HEADER1 '\x8b'
@@
-42,7
+44,7
@@
void gzfree(void *x, void *addr, unsigned nb)
free (addr);
}
free (addr);
}
-int g
unzip(void *dst, int dstlen, unsigned char *src, unsigned long *lenp
)
+int g
zip_parse_header(const unsigned char *src, unsigned long len
)
{
int i, flags;
{
int i, flags;
@@
-63,12
+65,21
@@
int gunzip(void *dst, int dstlen, unsigned char *src, unsigned long *lenp)
;
if ((flags & HEAD_CRC) != 0)
i += 2;
;
if ((flags & HEAD_CRC) != 0)
i += 2;
- if (i >=
*lenp
) {
+ if (i >=
len
) {
puts ("Error: gunzip out of data in header\n");
return (-1);
}
puts ("Error: gunzip out of data in header\n");
return (-1);
}
+ return i;
+}
+
+int gunzip(void *dst, int dstlen, unsigned char *src, unsigned long *lenp)
+{
+ int offset = gzip_parse_header(src, *lenp);
+
+ if (offset < 0)
+ return offset;
- return zunzip(dst, dstlen, src, lenp, 1,
i
);
+ return zunzip(dst, dstlen, src, lenp, 1,
offset
);
}
#ifdef CONFIG_CMD_UNZIP
}
#ifdef CONFIG_CMD_UNZIP