...
In this compliant solution, the code inside the while loop uses the ZipEntry.getSize()
method to find tracks the uncompressed file size of each entry in a zip archive before while extracting the entry. It throws an exception if the entry to be being extracted is too large — about 100MB in this case. We do not use the ZipEntry.getSize()
method because the value it reports is not reliable.
Code Block | ||
---|---|---|
| ||
static final int TOOBIG = 0x6400000; // 100MB // ... // write the files to the disk, but ensure onlythat ifthe file is not insanely big if (entry.getSize() > TOOBIG) { throw new IllegalStateException("File to be unzipped is huge."); } if (entry.getSize() =int total = 0; Â dest = new BufferedOutputStream(fos, BUFFER); Â while (total <= TOOBIG && (count = zis.read(data, 0, BUFFER)) != -1) { throw new IllegalStateException("File to be unzipped might be huge."); } FileOutputStream fos = new FileOutputStream(entry.getName()); dest = new BufferedOutputStream(fos, BUFFERÂ Â Â dest.write(data, 0, count); Â Â Â total += count; Â } Â dest.flush(); Â dest.close(); whileif ((counttotal = zis.read(data, 0, BUFFER)) != -1) { dest.write(data, 0, count); }> TOOBIG){ Â Â Â Â throw new IllegalStateException("File being unzipped is huge."); Â } Â // ... |
Risk Assessment
Rule | Severity | Likelihood | Remediation Cost | Priority | Level |
---|---|---|---|---|---|
IDS04-J | low | probable | high | P2 | L3 |
...
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="46ba2844364bfd22-09674464-47ec4b68-95a5be15-2630a25cde8196b7db1535d0"><ac:plain-text-body><![CDATA[ | [[Mahmoud 2002 | AA. References#Mahmoud 02]] | [Compressing and Decompressing Data Using Java APIs | http://java.sun.com/developer/technicalArticles/Programming/compression/] | ]]></ac:plain-text-body></ac:structured-macro> |
...