mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
修复ZipReader.checkZipBomb遇到空目录报错问题
This commit is contained in:
@@ -252,12 +252,14 @@ public class ZipReader implements Closeable {
|
||||
* @return 检查后的{@link ZipEntry}
|
||||
*/
|
||||
private ZipEntry checkZipBomb(ZipEntry entry) {
|
||||
if(maxSizeDiff < 0){
|
||||
return entry;
|
||||
}
|
||||
if (null == entry) {
|
||||
return null;
|
||||
}
|
||||
if(maxSizeDiff < 0 || entry.isDirectory()){
|
||||
// 目录不检查
|
||||
return entry;
|
||||
}
|
||||
|
||||
final long compressedSize = entry.getCompressedSize();
|
||||
final long uncompressedSize = entry.getSize();
|
||||
if (compressedSize < 0 || uncompressedSize < 0 ||
|
||||
|
@@ -0,0 +1,25 @@
|
||||
package cn.hutool.core.util;
|
||||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
public class IssueI9K494Test {
|
||||
@Test
|
||||
@Ignore
|
||||
public void unzipTest() {
|
||||
FileInputStream inputStream = IoUtil.toStream(FileUtil.file("d:/test/unzip5616889482468994725.zip"));
|
||||
ZipUtil.unzip(inputStream, FileUtil.file("d:/test/"), StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void unzipTest2() {
|
||||
FileInputStream inputStream = IoUtil.toStream(FileUtil.file("d:/test/test.zip"));
|
||||
ZipUtil.unzip(inputStream, FileUtil.file("d:/test/"), StandardCharsets.UTF_8);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user