diff options
author | Doug Zongker <dougz@android.com> | 2009-06-16 17:36:04 -0700 |
---|---|---|
committer | Doug Zongker <dougz@android.com> | 2009-06-16 17:36:04 -0700 |
commit | 287c71ca84533da008e9cc240224910a9d05139e (patch) | |
tree | 909262661c9d3854d42156b8f830f3d7bcbbb80e /libzipfile/zipfile.c | |
parent | f8b8288c165166adcd09c4c28b099d583715a569 (diff) | |
download | core-287c71ca84533da008e9cc240224910a9d05139e.tar.gz core-287c71ca84533da008e9cc240224910a9d05139e.tar.bz2 core-287c71ca84533da008e9cc240224910a9d05139e.zip |
fix decompression bug in fastboot
fastboot passes the *uncompressed* length of the file as the length of
the input to the inflate() call, which happens to work unless the
compressed data is actually larger than the uncompressed data (which
it can be for very small files). Fix this to pass the correct
compressed length down to the inflate call.
Diffstat (limited to 'libzipfile/zipfile.c')
-rw-r--r-- | libzipfile/zipfile.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/libzipfile/zipfile.c b/libzipfile/zipfile.c index b52d02df7..a401a9b16 100644 --- a/libzipfile/zipfile.c +++ b/libzipfile/zipfile.c @@ -82,13 +82,13 @@ uninflate(unsigned char* out, int unlen, const unsigned char* in, int clen) unsigned long crc; int err = 0; int zerr; - + memset(&zstream, 0, sizeof(zstream)); zstream.zalloc = Z_NULL; zstream.zfree = Z_NULL; zstream.opaque = Z_NULL; zstream.next_in = (void*)in; - zstream.avail_in = unlen; + zstream.avail_in = clen; zstream.next_out = (Bytef*) out; zstream.avail_out = unlen; zstream.data_type = Z_UNKNOWN; @@ -99,7 +99,7 @@ uninflate(unsigned char* out, int unlen, const unsigned char* in, int clen) if (zerr != Z_OK) { return -1; } - + // uncompress the data zerr = inflate(&zstream, Z_FINISH); if (zerr != Z_STREAM_END) { @@ -107,7 +107,7 @@ uninflate(unsigned char* out, int unlen, const unsigned char* in, int clen) zstream.total_out); err = -1; } - + inflateEnd(&zstream); return err; } |