From a13c8372028a71659743ebbe18e7f5f566fc4e09 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Fri, 29 Aug 2025 11:06:37 -0400 Subject: [PATCH] Probably fix the MD5 bug in IS-CAB --- .../Wrappers/InstallShieldCabinet.cs | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/SabreTools.Serialization/Wrappers/InstallShieldCabinet.cs b/SabreTools.Serialization/Wrappers/InstallShieldCabinet.cs index 6bf9ce45..f3dac980 100644 --- a/SabreTools.Serialization/Wrappers/InstallShieldCabinet.cs +++ b/SabreTools.Serialization/Wrappers/InstallShieldCabinet.cs @@ -573,19 +573,19 @@ namespace SabreTools.Serialization.Wrappers reader?.Dispose(); output?.Close(); - // Failing the file has been disabled because for a subset of CABs the values don't seem to match - // TODO: Investigate what is causing this to fail and what data needs to be hashed + // Validate the data written, if required + if (MajorVersion >= 6) + { + string expectedMd5 = BitConverter.ToString(fileDescriptor.MD5!); + expectedMd5 = expectedMd5.ToLowerInvariant().Replace("-", string.Empty); - // // Validate the data written, if required - // if (HeaderList!.MajorVersion >= 6) - // { - // string? md5result = md5.CurrentHashString; - // if (md5result == null || md5result != BitConverter.ToString(fileDescriptor.MD5!)) - // { - // Console.Error.WriteLine($"MD5 checksum failure for file {index} ({HeaderList.GetFileName(index)})"); - // return false; - // } - // } + string? actualMd5 = md5.CurrentHashString; + if (actualMd5 == null || actualMd5 != expectedMd5) + { + Console.Error.WriteLine($"MD5 checksum failure for file {index} ({GetFileName(index)})"); + return false; + } + } return true; }