Skip to content

Fixes .hdr+.cab installshield cabinet files not being extracted by BOS when relative paths are provided. #374

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions BinaryObjectScanner.Test/FileType/InstallShieldCABTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.IO;
using System;
using System.IO;
using BinaryObjectScanner.FileType;
using Xunit;

Expand All @@ -25,8 +26,7 @@ public void ExtractStream_Null_False()
string outDir = string.Empty;
var extractable = new InstallShieldCAB();

bool actual = extractable.Extract(stream, file, outDir, includeDebug: false);
Assert.False(actual);
Assert.Throws<ArgumentException>(() => extractable.Extract(stream, file, outDir, includeDebug: false));
}

[Fact]
Expand All @@ -37,8 +37,7 @@ public void ExtractStream_Empty_False()
string outDir = string.Empty;
var extractable = new InstallShieldCAB();

bool actual = extractable.Extract(stream, file, outDir, includeDebug: false);
Assert.False(actual);
Assert.Throws<ArgumentException>(() => extractable.Extract(stream, file, outDir, includeDebug: false));
}
}
}
2 changes: 2 additions & 0 deletions BinaryObjectScanner/FileType/InstallShieldCAB.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ public bool Extract(string file, string outDir, bool includeDebug)
/// <inheritdoc/>
public bool Extract(Stream? stream, string file, string outDir, bool includeDebug)
{
// Handles getting full path if relative paths were passed.
file = Path.GetFullPath(file);
// Get the name of the first cabinet file or header
var directory = Path.GetDirectoryName(file);
string noExtension = Path.GetFileNameWithoutExtension(file);
Expand Down
2 changes: 1 addition & 1 deletion BinaryObjectScanner/Scanner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ private ProtectionDictionary GetInternalProtections(string file)
try
{
using FileStream fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
return GetInternalProtections(file, fs);
return GetInternalProtections(fs.Name, fs);
}
catch (Exception ex)
{
Expand Down
Loading