diff --git a/BizHawk.Client.Common/SharpCompressArchiveHandler.cs b/BizHawk.Client.Common/SharpCompressArchiveHandler.cs index a1f67db3f7..802ac38201 100644 --- a/BizHawk.Client.Common/SharpCompressArchiveHandler.cs +++ b/BizHawk.Client.Common/SharpCompressArchiveHandler.cs @@ -25,12 +25,22 @@ namespace BizHawk.Client.Common { _archive?.Dispose(); _archive = null; - } + } + + /// + /// whitelist extensions, to avoid thrown exceptions + /// + public string[] ArchiveExtensions = { ".zip", ".gz", ".gzip", ".tar", ".rar", ".7z" }; public bool CheckSignature(string fileName, out int offset, out bool isExecutable) { offset = 0; isExecutable = false; + + var pathExt = Path.GetExtension(fileName).ToLower(); + if (!ArchiveExtensions.Contains(pathExt)) + return false; + try { using (var arcTest = ArchiveFactory.Open(fileName)) diff --git a/BizHawk.Common/HawkFile.cs b/BizHawk.Common/HawkFile.cs index ecec97a69c..b9a320cfb9 100644 --- a/BizHawk.Common/HawkFile.cs +++ b/BizHawk.Common/HawkFile.cs @@ -440,7 +440,8 @@ namespace BizHawk.Common int offset; bool isExecutable; - if (NonArchiveExtensions.Any(ext => Path.GetExtension(path).ToLower() == ext.ToLower())) + var pathExt = Path.GetExtension(path).ToLower(); + if (NonArchiveExtensions.Contains(pathExt)) { return; }