From f272a5d1523477d77edcdfaf523a725d09c6c78b Mon Sep 17 00:00:00 2001 From: burninrubber0 Date: Thu, 29 Jun 2023 20:48:49 -0400 Subject: [PATCH] Handle checksum corruption from (original, 0, original.Length - 1).ToArray(); + try + { + zlibStream.Write(trimmed, 0, trimmed.Length); + } + catch (Exception) + { + return null; + } + + byte[] compressed = Compress(uncompressedData); + + // Test first three checksum bytes + if (original[original.Length - 4] == compressed[compressed.Length - 4] + && original[original.Length - 3] == compressed[compressed.Length - 3] + && original[original.Length - 2] == compressed[compressed.Length - 2]) + { + // Testing of data not necessary, likelihood of 24 bits matching without data matching is negligible + return uncompressedData; + } + + return null; + } + public static bool Matches(this byte[] self, byte[] other) { if (self == null || other == null)