fix:修复压缩路径遍历问题(google play:Zip Path Traversal )

This commit is contained in:
Max
2024-01-23 11:17:39 +08:00
parent 6cfc44285e
commit db75f129ee

View File

@@ -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) {