From 3e75d9fa3b6a54a3c72b848c7bc056c2ca7cc340 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Wed, 15 May 2024 13:09:40 -0400 Subject: [PATCH] Add safety around executable wrapper creation --- BinaryObjectScanner/Scanner.cs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/BinaryObjectScanner/Scanner.cs b/BinaryObjectScanner/Scanner.cs index 0cd2306a..5ac10a37 100644 --- a/BinaryObjectScanner/Scanner.cs +++ b/BinaryObjectScanner/Scanner.cs @@ -15,6 +15,7 @@ using BinaryObjectScanner.FileType; using BinaryObjectScanner.Interfaces; using BinaryObjectScanner.Utilities; using SabreTools.IO.Extensions; +using SabreTools.Serialization.Interfaces; using SabreTools.Serialization.Wrappers; using static BinaryObjectScanner.Utilities.Dictionary; @@ -425,9 +426,18 @@ namespace BinaryObjectScanner #endif { // Try to create a wrapper for the proper executable type - var wrapper = WrapperFactory.CreateExecutableWrapper(stream); - if (wrapper == null) + IWrapper? wrapper; + try + { + wrapper = WrapperFactory.CreateExecutableWrapper(stream); + if (wrapper == null) + return null; + } + catch (Exception ex) + { + if (IncludeDebug) Console.WriteLine(ex); return null; + } // Create the output dictionary #if NET20 || NET35