Skip to content

Commit 3e421ca

Browse files
authored
Fixing zip extraction logic (#3875)
1 parent 898a674 commit 3e421ca

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

build/FileHelpers.cs

+9-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,15 @@ public static void ExtractZipFileForce(string zipFile, string to)
119119
{
120120
foreach (ZipArchiveEntry file in archive.Entries)
121121
{
122-
file.ExtractToFile(Path.Combine(to, file.FullName), overwrite: true);
122+
string destFileName = Path.GetFullPath(Path.Combine(to, file.FullName));
123+
string fullDestDirPath = Path.GetFullPath(to + Path.DirectorySeparatorChar);
124+
125+
if (!destFileName.StartsWith(fullDestDirPath))
126+
{
127+
throw new System.InvalidOperationException("Entry is outside the target dir: " + destFileName);
128+
}
129+
130+
file.ExtractToFile(destFileName, overwrite: true);
123131
}
124132
}
125133
}

0 commit comments

Comments
 (0)