From 64f9f8b87fc01881cff6b241d3d3d1928d5fffca Mon Sep 17 00:00:00 2001 From: putao520 Date: Sun, 25 Jul 2021 23:16:13 +0800 Subject: [PATCH] Fix a md5 sum bug without openssl (#951) --- lib/src/ssl_funcs/Md5.cc | 2 +- lib/tests/unittests/MD5Test.cc | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/src/ssl_funcs/Md5.cc b/lib/src/ssl_funcs/Md5.cc index 411d7ef4..318a9c82 100644 --- a/lib/src/ssl_funcs/Md5.cc +++ b/lib/src/ssl_funcs/Md5.cc @@ -51,7 +51,7 @@ uint32_t Md5Encode::fillData(const char *inDataPtr, // int grop_num = bitNum / BIT_OF_GROUP; int modBitNum = bitNum % BIT_OF_GROUP; int bitNeedFill = 0; - if (modBitNum > (BIT_OF_GROUP - SRC_DATA_LEN)) + if (modBitNum >= (BIT_OF_GROUP - SRC_DATA_LEN)) { bitNeedFill = (BIT_OF_GROUP - modBitNum); bitNeedFill += (BIT_OF_GROUP - SRC_DATA_LEN); diff --git a/lib/tests/unittests/MD5Test.cc b/lib/tests/unittests/MD5Test.cc index 5545ae71..8340be2b 100644 --- a/lib/tests/unittests/MD5Test.cc +++ b/lib/tests/unittests/MD5Test.cc @@ -9,4 +9,8 @@ DROGON_TEST(Md5Test) "1234567890") == "49CB3608E2B33FAD6B65DF8CB8F49668"); CHECK(drogon::utils::getMd5("1") == "C4CA4238A0B923820DCC509A6F75849B"); + CHECK(drogon::utils::getMd5("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF") == + "59F761506DFA597B0FAF1968F7CCA867"); }