I have a java application, which recieves compressed files as input. The application then reads the header information of said files and passes the compressed bytes to an external native library for decompression (JNI). In one of the files we recieved, there was a corrupt blob of compressed bytes within the input file wich leads to a hard crash of the dynamically loaded library and our application(no exceptions etc.).
Upon inspection of the compressed array which is passed to the library we verified that the data is indeed corrupt, while the header information is fine.
The question I have is:
How can I prevent my application from crashing from these corrupted input files?
Thoughts:
- To me it seems, that there is no way to inspect compressed data for validity... without decompressing.
- Inspecting the header file for some kind of sanity check is not enough, as the header information is well formed.
- Changing the called library to be more robust for the malformed data would effectively result in forking the external library, which I want to avoid if possible.
Any pointers are appreciated.