diff options
author | Vincent Richard <[email protected]> | 2005-02-05 09:26:25 +0000 |
---|---|---|
committer | Vincent Richard <[email protected]> | 2005-02-05 09:26:25 +0000 |
commit | 2d02c629a950f432e7a1abbee726a3e0aa9f5282 (patch) | |
tree | 4f98d079e4643664327152712d629290909488b4 | |
parent | Fixed possible segfault when encoding is Base64. (diff) | |
download | vmime-2d02c629a950f432e7a1abbee726a3e0aa9f5282.tar.gz vmime-2d02c629a950f432e7a1abbee726a3e0aa9f5282.zip |
Fixed forward use of swapUint32Array().
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | src/utility/md5.cpp | 42 |
2 files changed, 26 insertions, 21 deletions
@@ -2,6 +2,11 @@ VERSION 0.6.4cvs ================ +2005-02-05 Vincent Richard <[email protected]> + + * utility/md5.cpp: fixed forward use of swapUint32Array() with + gcc 3.3 (Apple). + 2005-02-01 Vincent Richard <[email protected]> * text.cpp: fixed possible segfault when encoding is Base64 (typo). diff --git a/src/utility/md5.cpp b/src/utility/md5.cpp index f630d86d..0bfc9f3e 100644 --- a/src/utility/md5.cpp +++ b/src/utility/md5.cpp @@ -100,6 +100,27 @@ static void copyUint8Array(vmime_uint8* dest, const vmime_uint8* src, unsigned l } +static inline vmime_uint32 swapUint32(const vmime_uint32 D) +{ + return ((D << 24) | ((D << 8) & 0x00FF0000) | ((D >> 8) & 0x0000FF00) | (D >> 24)); +} + + +static inline void swapUint32Array(vmime_uint32* buf, unsigned long words) +{ + for ( ; words >= 4 ; words -= 4, buf += 4) + { + buf[0] = swapUint32(buf[0]); + buf[1] = swapUint32(buf[1]); + buf[2] = swapUint32(buf[2]); + buf[3] = swapUint32(buf[3]); + } + + for ( ; words ; --words, ++buf) + buf[0] = swapUint32(buf[0]); +} + + void md5::update(const string& in) { update(reinterpret_cast <const vmime_uint8*>(in.c_str()), in.length()); @@ -176,27 +197,6 @@ void md5::finalize() } -static inline vmime_uint32 swapUint32(const vmime_uint32 D) -{ - return ((D << 24) | ((D << 8) & 0x00FF0000) | ((D >> 8) & 0x0000FF00) | (D >> 24)); -} - - -static inline void swapUint32Array(vmime_uint32* buf, unsigned long words) -{ - for ( ; words >= 4 ; words -= 4, buf += 4) - { - buf[0] = swapUint32(buf[0]); - buf[1] = swapUint32(buf[1]); - buf[2] = swapUint32(buf[2]); - buf[3] = swapUint32(buf[3]); - } - - for ( ; words ; --words, ++buf) - buf[0] = swapUint32(buf[0]); -} - - void md5::transformHelper() { #if VMIME_BYTE_ORDER_BIG_ENDIAN |