Skip to content

Commit 4b15cc3

Browse files
committed
Fix MD5 checksum for empty buffers
1 parent 2282943 commit 4b15cc3

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

Shared/sdk/CChecksum.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,10 @@ class CChecksum
6666
{
6767
CChecksum result;
6868
result.ulCRC = CRCGenerator::GetCRCFromBuffer(cpBuffer, ulLength);
69-
CMD5Hasher().Calculate(cpBuffer, ulLength, result.md5);
69+
70+
if (result.ulCRC != 0)
71+
CMD5Hasher().Calculate(cpBuffer, ulLength, result.md5);
72+
7073
return result;
7174
}
7275

Shared/sdk/SharedUtil.Hash.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,9 @@ namespace SharedUtil
145145

146146
void CMD5Hasher::Update(unsigned char* input, unsigned int input_length)
147147
{
148+
if (input_length == 0)
149+
return;
150+
148151
// CRYPT_START
149152
unsigned int input_index, buffer_index;
150153
unsigned int buffer_space; // how much space is left in buffer

0 commit comments

Comments
 (0)