diff options
Diffstat (limited to 'packaging/0017-Fix-alignment-of-reads-in-MD5Transform.-12800.patch')
-rw-r--r-- | packaging/0017-Fix-alignment-of-reads-in-MD5Transform.-12800.patch | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/packaging/0017-Fix-alignment-of-reads-in-MD5Transform.-12800.patch b/packaging/0017-Fix-alignment-of-reads-in-MD5Transform.-12800.patch new file mode 100644 index 0000000000..f2d736f1ca --- /dev/null +++ b/packaging/0017-Fix-alignment-of-reads-in-MD5Transform.-12800.patch @@ -0,0 +1,51 @@ +From 9483a7c0c4a90bd8a6eaa4faecf3136623318cc2 Mon Sep 17 00:00:00 2001 +From: Ruben Ayrapetyan <ruben-ayrapetyan@users.noreply.github.com> +Date: Mon, 17 Jul 2017 17:10:42 +0300 +Subject: [PATCH 17/32] Fix alignment of reads in MD5Transform. (#12800) + +--- + src/utilcode/md5.cpp | 14 +++++++++++++- + 1 file changed, 13 insertions(+), 1 deletion(-) + +diff --git a/src/utilcode/md5.cpp b/src/utilcode/md5.cpp +index 8d6f8a3..6901ddb 100644 +--- a/src/utilcode/md5.cpp ++++ b/src/utilcode/md5.cpp +@@ -10,6 +10,7 @@ + #include "stdafx.h" + + #include <stdlib.h> ++#include "stdmacros.h" + #include "md5.h" + #include "contract.h" + +@@ -76,7 +77,16 @@ void MD5::HashMore(const void* pvInput, ULONG cbInput) + // Hash the data in 64-byte runs, starting just after what we've copied + while (cbInput >= 64) + { +- MD5Transform(m_state, (ULONG*)pbInput); ++ if (IS_ALIGNED(pbInput, sizeof(ULONG))) ++ { ++ MD5Transform(m_state, (ULONG*)pbInput); ++ } ++ else ++ { ++ ULONG inputCopy[64 / sizeof(ULONG)]; ++ memcpy(inputCopy, pbInput, sizeof(inputCopy)); ++ MD5Transform(m_state, inputCopy); ++ } + pbInput += 64; + cbInput -= 64; + } +@@ -213,6 +223,8 @@ void MD5::GetHashValue(MD5HASHDATA* phash) + STATIC_CONTRACT_NOTHROW; + STATIC_CONTRACT_GC_NOTRIGGER; + ++ _ASSERTE(IS_ALIGNED(data, sizeof(ULONG))); ++ + ULONG a=state[0]; + ULONG b=state[1]; + ULONG c=state[2]; +-- +2.7.4 + |