Hello

Crypto++ 5.6.0 triggers this valgrind error:

Source and destination overlap in memcpy(0x7feffef40, 0x7feffef40, 56)
   at 0x4A0809B: memcpy (mc_replace_strmem.c:482)
   by 0x52D115: CryptoPP::IteratedHashBase<unsigned int, 
CryptoPP::HashTransformation>::Update(unsigned char const*,
unsigned long) (iterhash.cpp:69)
   by 0x4FD045: CryptoPP::HashFilter::Put2(unsigned char const*, unsigned long, 
int, bool) (filters.cpp:735)
...


According to the manpage of memcpy (Ubuntu 10.04) this should not be the case:

"The memcpy() function copies n bytes from memory area src to memory area dest. The memory areas should not overlap."

Whenever this error occurs, both pointers are the same.

The attached patch simply fixes this situation by adding an if-statement that suppresses the memcpy call if the pointers are identical.

Regards, Peter.

--
You received this message because you are subscribed to the "Crypto++ Users" 
Google Group.
To unsubscribe, send an email to [email protected].
More information about Crypto++ and this group is available at 
http://www.cryptopp.com.
diff -Nur 5.6.0/iterhash.cpp 5.6.0-patched/iterhash.cpp
--- 5.6.0/iterhash.cpp	2009-03-15 02:48:02.000000000 +0100
+++ 5.6.0-patched/iterhash.cpp	2010-08-03 21:28:51.000000000 +0200
@@ -66,7 +66,8 @@
 			} while (len >= blockSize);
 	}
 
-	memcpy(data, input, len);
+	if (data!=input)
+		memcpy(data, input, len);
 }
 
 template <class T, class BASE> byte * IteratedHashBase<T, BASE>::CreateUpdateSpace(size_t &size)

Reply via email to