mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
17 lines
687 B
C#
17 lines
687 B
C#
using System.IO;
|
|
using System.IO.Compression;
|
|
|
|
class Good
|
|
{
|
|
public static void WriteToDirectory(ZipArchiveEntry entry,
|
|
string destDirectory)
|
|
{
|
|
string destFileName = Path.GetFullPath(Path.Combine(destDirectory, entry.FullName));
|
|
string fullDestDirPath = Path.GetFullPath(destDirectory + Path.DirectorySeparatorChar);
|
|
if (!destFileName.StartsWith(fullDestDirPath)) {
|
|
throw new System.InvalidOperationException("Entry is outside of the target dir: " +
|
|
destFileName);
|
|
}
|
|
entry.ExtractToFile(destFileName);
|
|
}
|
|
} |