Radically unbloated DEFLATE/zlib/gzip compression/decompression library. Can decompress any gzip/zlib data, and offers simplified compressor which produces gzip-compatible output, while requiring much less resources (and providing less compression ratio of course).
Other
302
stars
82
forks
source link
Unexpected TINF_DATA_ERROR when using uzlib_uncompress with small input and output buffers #49
I am working on an embedded project where RAM is very limited. The firmware update image is compressed (and encrypted with AES) using the Deflate algorithm. My embedded processor doesn't have enough RAM to uncompress the entire image so I need to do it piece mill using uzlib. When I attempt to make multiple calls to uzlib_uncompress it results in receiving a TINF_DATA_ERROR at some point before the end of the image has been reached.
To reproduce the exact scenario I did the following steps:
Create an image sufficiently large enough to trigger the error (I did 10000 bytes):
openssl rand -out orig.bin 10000
Modify tgzip to allow for creating a compressed image with only the compressed bytes:
Use the attached decomp.c example to try to decompress the above file:
decomp.txt
Instructions for compiling it provided (I use WSL on Windows).
The goal is to decompress a series of bytes to feed into the firmware upgrade of another processor over a serial connection so each uzlib_uncompress call would be done before sending the uncompressed bytes over the serial connection.
Thank you for any help you can provide in troubleshooting what is going wrong.
From my actual image, you can see that with a buffer size of 128, I only get slightly into the 2nd call before it fails:
Thanks for the report. Unfortunately, currently I don't have time for the active uzlib maintenance. Sorry for the bot reply though, I made sure the ticket stays open until better times.
I am working on an embedded project where RAM is very limited. The firmware update image is compressed (and encrypted with AES) using the Deflate algorithm. My embedded processor doesn't have enough RAM to uncompress the entire image so I need to do it piece mill using uzlib. When I attempt to make multiple calls to uzlib_uncompress it results in receiving a TINF_DATA_ERROR at some point before the end of the image has been reached. To reproduce the exact scenario I did the following steps:
./tgzip orig.bin compressed.bin
Instructions for compiling it provided (I use WSL on Windows).
The goal is to decompress a series of bytes to feed into the firmware upgrade of another processor over a serial connection so each uzlib_uncompress call would be done before sending the uncompressed bytes over the serial connection. Thank you for any help you can provide in troubleshooting what is going wrong.
From my actual image, you can see that with a buffer size of 128, I only get slightly into the 2nd call before it fails:
The failure appears to be this comparison: offs > d->dest - d->destStart