From c24b146943c13a67b018c8297da11faaed1dfc04 Mon Sep 17 00:00:00 2001 From: David Ward Date: Sat, 5 Feb 2011 10:49:48 -0500 Subject: NDnS: Avoid calling memcpy with identical source and destination addresses Add a test to avoid calling memcpy with identical source and destination addresses, which has undefined behavior and causes Valgrind to report an error. Signed-off-by: David Ward --- InfraStack/OSAgnostic/WiMax/Agents/NDnS/L4_db/NDnSAgent_DB_Common.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/InfraStack/OSAgnostic/WiMax/Agents/NDnS/L4_db/NDnSAgent_DB_Common.c b/InfraStack/OSAgnostic/WiMax/Agents/NDnS/L4_db/NDnSAgent_DB_Common.c index b1b8140..ecd51b7 100644 --- a/InfraStack/OSAgnostic/WiMax/Agents/NDnS/L4_db/NDnSAgent_DB_Common.c +++ b/InfraStack/OSAgnostic/WiMax/Agents/NDnS/L4_db/NDnSAgent_DB_Common.c @@ -3078,7 +3078,10 @@ void l4db_RemoveSpecialCharacters(char* string) (0 != OSAL_CAPI_strncmp(&currChar, "+", 1)) && (0 != OSAL_CAPI_strncmp(&currChar, " ", 1))) { - OSAL_memcpy_s(&string[currCharIndex], 1, &string[i], 1); + if (i > currCharIndex) + { + OSAL_memcpy_s(&string[currCharIndex], 1, &string[i], 1); + } currCharIndex++; } } -- cgit v1.2.3