File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed
dotnet/src/dotnetframework/GxCompress Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -603,6 +603,14 @@ private static void DecompressZip(FileInfo file, string outputPath)
603603 foreach ( var entry in archive . Entries )
604604 {
605605 string fullPath = Path . Combine ( outputPath , entry . FullName ) ;
606+ string destFileName = Path . GetFullPath ( fullPath ) ;
607+ string fullDestDirPath = Path . GetFullPath ( outputPath + Path . DirectorySeparatorChar ) ;
608+ if ( ! destFileName . StartsWith ( fullDestDirPath ) )
609+ {
610+ throw new InvalidOperationException ( "Entry is outside the target dir: " + destFileName ) ;
611+ }
612+
613+
606614 if ( string . IsNullOrEmpty ( entry . Name ) )
607615 {
608616 Directory . CreateDirectory ( fullPath ) ;
@@ -742,6 +750,14 @@ private static void DecompressJar(FileInfo file, string outputPath)
742750 foreach ( var entry in archive . Entries )
743751 {
744752 string destinationPath = Path . Combine ( outputPath , entry . FullName ) ;
753+ string destFileName = Path . GetFullPath ( destinationPath ) ;
754+ string fullDestDirPath = Path . GetFullPath ( outputPath + Path . DirectorySeparatorChar ) ;
755+ if ( ! destFileName . StartsWith ( fullDestDirPath ) )
756+ {
757+ throw new InvalidOperationException ( "Entry is outside the target dir: " + destFileName ) ;
758+ }
759+
760+
745761 if ( string . IsNullOrEmpty ( entry . Name ) )
746762 {
747763 Directory . CreateDirectory ( destinationPath ) ;
You can’t perform that action at this time.
0 commit comments