8000 修复zip解压的安全缺陷 · newcoderzhang/LuaViewSDK@9c0bbc9 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9c0bbc9

Browse files
author
tuoli
committed
修复zip解压的安全缺陷
1 parent b785725 commit 9c0bbc9

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Android/LuaViewSDK/src/com/taobao/luaview/scriptbundle/ScriptBundle.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,13 @@ public static ScriptBundle unpackBundle(boolean isBytecode, boolean saveFile, fi
190190
String fileName = null;
191191
String filePath = null;
192192
while ((entry = zipStream.getNextEntry()) != null) {
193-
fileName = FileUtil.getSecurityFileName(entry.getName());//TODO 这里需要重新修改下,需要处理一下../ 这种方式只能使用单层路径,不能处理子目录,在这里可以添加公用path
193+
// 处理../ 这种方式只能使用单层路径,不能处理子目录,在这里可以添加公用path
194+
String szName = entry.getName();
195+
if(szName != null && szName.indexOf("../") != -1){
196+
return null;
197+
}
198+
199+
fileName = FileUtil.getSecurityFileName(szName);
194200

195201
if (saveFile && entry.isDirectory()) {
196202
filePath = FileUtil.buildPath(scriptBundleFolderPath, fileName);

0 commit comments

Comments
 (0)
0