Originally posted by: R�bert Szucs
A bug exists in the checksum computing:
// Calc Checksum of last dword padding with zeroes
m_dwChecksum += dwBuffer[((dwRead+3) >> 2)] &
(0xFFFFFFFF >> ((dwRead & 0x3) << 3));
This is wrong because addresses dwBuffer _after_ last dword with one position in most of cases. The symptom is that: for the same file it compute different checksum, because it uses a dword survived from the previous file.
Correct version:
// Calc Checksum of last dword padding with zeroes
m_dwChecksum += dwBuffer[dwRead >> 2] &
(0xFFFFFFFF >> ((dwRead & 0x3) << 3));
This is trivial, if you see the preceding for cycle:
for (UINT i=0;i<(dwRead >> 2);i++)
{
m_dwChecksum += dwBuffer[i];
This run for dwRead>>2, but not reach this value, so this is the index of the next (and last) dword.
At CRC computing exists the same error.
Bye, Robi
Reply