diff options
author | Matthias Fuchs <matthias.fuchs@esd-electronics.com> | 2009-01-02 15:11:41 +0100 |
---|---|---|
committer | Wolfgang Denk <wd@denx.de> | 2009-01-27 20:59:09 +0100 |
commit | 107b801cf3fe39612d69d70581ebc3bf5e215554 (patch) | |
tree | 6e15eae452a228d7025dba569b67dd62f1a3b935 /lib_generic | |
parent | 49ad4801714039ac8b9cae4de9c097224183e465 (diff) |
Fix gunzip in case of insufficient output buffer
U-Boot's gunzip() function does not handle the return code
of zlib's inflate() function correctly. gunzip() is implemented
to uncompress all input data in one run. So the correct return
code for the good case is Z_STREAM_END. In case of insufficient
output buffer memory inflate returns Z_OK. For gunzip() this
is an error.
It also makes sense to me to call inflateEnd() also in case
of an error.
Signed-off-by: Matthias Fuchs <matthias.fuchs@esd-electronics.com>
Diffstat (limited to 'lib_generic')
-rw-r--r-- | lib_generic/gunzip.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/lib_generic/gunzip.c b/lib_generic/gunzip.c index 74f0bf9f3e1..5bcf5b7b24f 100644 --- a/lib_generic/gunzip.c +++ b/lib_generic/gunzip.c @@ -102,8 +102,9 @@ int gunzip(void *dst, int dstlen, unsigned char *src, unsigned long *lenp) s.next_out = dst; s.avail_out = dstlen; r = inflate(&s, Z_FINISH); - if (r != Z_OK && r != Z_STREAM_END) { + if (r != Z_STREAM_END) { printf ("Error: inflate() returned %d\n", r); + inflateEnd(&s); return (-1); } *lenp = s.next_out - (unsigned char *) dst; |