fix:修复压缩路径遍历问题(google play:Zip Path Traversal )
This commit is contained in:
@@ -753,6 +753,7 @@ public class DynamicFaceModel extends BaseModel implements IDynamicFaceModel {
|
||||
BufferedInputStream bis = new BufferedInputStream(zis);
|
||||
//输出路径(文件夹目录)
|
||||
String parent = facesRootDir.getAbsolutePath() + "/" + faceListInfo.getVersion();
|
||||
String parentPre = new File(parent).getCanonicalPath();
|
||||
File file;
|
||||
ZipEntry entry;
|
||||
while ((entry = zis.getNextEntry()) != null) {
|
||||
@@ -768,6 +769,9 @@ public class DynamicFaceModel extends BaseModel implements IDynamicFaceModel {
|
||||
continue;
|
||||
}
|
||||
file = new File(parent, entry.getName());
|
||||
if (!file.getCanonicalPath().startsWith(parentPre)) {
|
||||
throw new SecurityException();
|
||||
}
|
||||
if (!file.exists()) {
|
||||
(new File(file.getParent())).mkdirs();
|
||||
} else if (file.exists() && file.isFile() && file.length() > 0) {
|
||||
|
Reference in New Issue
Block a user