Skip to content
This repository was archived by the owner on May 1, 2023. It is now read-only.

Commit 62b922a

Browse files
JayRod12facebook-github-bot
authored andcommitted
address path traversal vulnerability
Summary: Address vulnerability task as per the suggested fix Reviewed By: BurntBrunch Differential Revision: D33633205 fbshipit-source-id: 1834fcdfa96ba1e4fce4d59edabdc4ebfd45fb87
1 parent f539221 commit 62b922a

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

deps/zip/ZipHelper.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
import java.util.zip.ZipOutputStream;
1616

1717
public class ZipHelper {
18-
1918
public static final String ZIP_SUFFIX = ".zip";
2019
public static final String TMP_SUFFIX = ".tmp";
2120

@@ -135,6 +134,9 @@ public static boolean extractZip(InputStream inputStream, File extractDir) throw
135134

136135
while (entry != null) {
137136
File newFile = new File(extractDir, entry.getName());
137+
if (!newFile.getCanonicalPath().startsWith(extractDir.getName())) {
138+
throw new IOException("Invalid entry name");
139+
}
138140
if (entry.isDirectory()) {
139141
if (!newFile.isDirectory() && !newFile.mkdirs()) {
140142
throw new IOException("Can't create directory");

0 commit comments

Comments
 (0)