pgkaila / winzipaes

Automatically exported from code.google.com/p/winzipaes
0 stars 0 forks source link

File resource is not closed in case of exception in initDirOffsetPosAndComment() #50

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Try to open a file, which is not a zip file, using AesZipFileDecrypter, by 
passing java.io.File to it.
2. It will throw an exception, which is as expected.
3. But the file resource is not closed by decrypter.

What is the expected output? What do you see instead?
The exception should be thrown, but the file must be closed.

What version of the product are you using? On what operating system?
We found the source of bug by looking into code in trunk of winzipaes.

Please provide any additional information below.
The following monkey-patch resolves the problem:
replace
dec   = new AesZipFileDecrypter(packedFile, decBc);
with 
            dec   = new AesZipFileDecrypter(packedFile, decBc){
                protected void initDirOffsetPosAndComment() throws IOException {
                    try {
                        super.initDirOffsetPosAndComment();
                    } catch(IOException e) {
                        try{
                            close();
                        } catch(IOException ex){
                        }
                        throw e;
                    }
                }
             } ;

Original issue reported on code.google.com by ilya.por...@gmail.com on 16 Feb 2015 at 6:05

GoogleCodeExporter commented 9 years ago
fix implemented, please review

Original comment by olaf.merkert on 16 Feb 2015 at 6:45