diff --git a/BinaryObjectScanner/FileType/PKZIP.cs b/BinaryObjectScanner/FileType/PKZIP.cs
index 8eb00e59..ca9f7e60 100644
--- a/BinaryObjectScanner/FileType/PKZIP.cs
+++ b/BinaryObjectScanner/FileType/PKZIP.cs
@@ -46,6 +46,10 @@ namespace BinaryObjectScanner.FileType
if (entry.IsDirectory)
continue;
+ // If we have a partial entry due to an incomplete multi-part archive, skip it
+ if (!entry.IsComplete)
+ continue;
+
string tempFile = Path.Combine(tempPath, entry.Key);
var directoryName = Path.GetDirectoryName(tempFile);
if (directoryName != null && !Directory.Exists(directoryName))
diff --git a/BinaryObjectScanner/Packer/WinZipSFX.cs b/BinaryObjectScanner/Packer/WinZipSFX.cs
index 7fbf8c23..09c5e259 100644
--- a/BinaryObjectScanner/Packer/WinZipSFX.cs
+++ b/BinaryObjectScanner/Packer/WinZipSFX.cs
@@ -73,20 +73,18 @@ namespace BinaryObjectScanner.Packer
///
/// Handle common extraction between executable types
///
- private static string? Extract(string file, bool includeDebug)
+ ///
+ public string? Extract(string file, bool includeDebug)
{
#if NET462_OR_GREATER || NETCOREAPP
try
{
- // Should be using stream instead of file, but stream fails to extract anything. My guess is that the executable portion of the archive is causing stream to fail, but not file.
+ // Create a temp output directory
+ string tempPath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
+ Directory.CreateDirectory(tempPath);
+
using (ZipArchive zipFile = ZipArchive.Open(file))
{
- if (!zipFile.IsComplete)
- return null;
-
- string tempPath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
- Directory.CreateDirectory(tempPath);
-
foreach (var entry in zipFile.Entries)
{
try
@@ -95,7 +93,14 @@ namespace BinaryObjectScanner.Packer
if (entry.IsDirectory)
continue;
+ // If we have a partial entry due to an incomplete multi-part archive, skip it
+ if (!entry.IsComplete)
+ continue;
+
string tempFile = Path.Combine(tempPath, entry.Key);
+ var directoryName = Path.GetDirectoryName(tempFile);
+ if (directoryName != null && !Directory.Exists(directoryName))
+ Directory.CreateDirectory(directoryName);
entry.WriteToFile(tempFile);
}
catch (Exception ex)
@@ -103,9 +108,9 @@ namespace BinaryObjectScanner.Packer
if (includeDebug) Console.WriteLine(ex);
}
}
-
- return tempPath;
}
+
+ return tempPath;
}
catch (Exception ex)
{