From 302cf2e14f987fc6a1825465158e361d2418813b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 16 Jan 2026 09:30:05 +0000 Subject: [PATCH 1/2] Initial plan From 9fa686b8f9cce2f9393349e3a3ae5d0eac8133ef Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 16 Jan 2026 09:35:24 +0000 Subject: [PATCH 2/2] Fix empty catch blocks in TarArchive.Factory.cs with explicit exception handling Co-authored-by: adamhathcock <527620+adamhathcock@users.noreply.github.com> --- .../Archives/Tar/TarArchive.Factory.cs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/SharpCompress/Archives/Tar/TarArchive.Factory.cs b/src/SharpCompress/Archives/Tar/TarArchive.Factory.cs index 8b7961ada..4f1520f9c 100644 --- a/src/SharpCompress/Archives/Tar/TarArchive.Factory.cs +++ b/src/SharpCompress/Archives/Tar/TarArchive.Factory.cs @@ -161,8 +161,12 @@ public static bool IsTarFile(Stream stream) && Enum.IsDefined(typeof(EntryType), tarHeader.EntryType); return readSucceeded || isEmptyArchive; } - catch { } - return false; + catch (Exception) + { + // Catch all exceptions during tar header reading to determine if this is a valid tar file + // Invalid tar files or corrupted streams will throw various exceptions + return false; + } } public static async ValueTask IsTarFileAsync( @@ -182,8 +186,12 @@ public static async ValueTask IsTarFileAsync( && Enum.IsDefined(typeof(EntryType), tarHeader.EntryType); return readSucceeded || isEmptyArchive; } - catch { } - return false; + catch (Exception) + { + // Catch all exceptions during tar header reading to determine if this is a valid tar file + // Invalid tar files or corrupted streams will throw various exceptions + return false; + } } public static IWritableArchive CreateArchive() => new TarArchive();