1
0
mirror of synced 2024-11-23 22:40:58 +01:00

Loosen GZip header detection threshold to prevent false negatives

This commit is contained in:
samyuu 2022-01-29 07:32:40 +01:00
parent 1abbf3044e
commit ae713dd15d

View File

@ -364,7 +364,7 @@ namespace PeepoHappy
combinedByte |= (upperCaseHexCharToNibble(upperCaseHexChars[(byteIndex * hexDigitsPerByte) + 1]) << 0); combinedByte |= (upperCaseHexCharToNibble(upperCaseHexChars[(byteIndex * hexDigitsPerByte) + 1]) << 0);
outBytes[byteIndex] = combinedByte; outBytes[byteIndex] = combinedByte;
} }
return true; return true;
} }
} }
@ -433,14 +433,15 @@ namespace PeepoHappy
const GZipHeader* header = reinterpret_cast<const GZipHeader*>(fileContent); const GZipHeader* header = reinterpret_cast<const GZipHeader*>(fileContent);
// NOTE: This is by no means comprehensive but should be enough for datatable files and (not falsely) detecting encrypted data // NOTE: This is by no means comprehensive but should be enough for datatable files and (not falsely) detecting encrypted data
#if 1 #if 0
return (header->Magic[0] == 0x1F && header->Magic[1] == 0x8B) && return (header->Magic[0] == 0x1F && header->Magic[1] == 0x8B) &&
(header->CompressionMethod == Z_DEFLATED) && (header->CompressionMethod == Z_DEFLATED) &&
(header->Flags == 0) && (header->Flags == 0) &&
(header->Timestamp == 0) && (header->Timestamp == 0) &&
(header->ExtraFlags == 0); (header->ExtraFlags == 0);
#else // DEBUG: Less precise check for FArc testing #else // NOTE: Less precise because becuase of some false negatives
return (header->Magic[0] == 0x1F && header->Magic[1] == 0x8B) && (header->CompressionMethod == Z_DEFLATED); return (header->Magic[0] == 0x1F && header->Magic[1] == 0x8B) &&
(header->CompressionMethod == Z_DEFLATED);
#endif #endif
} }