[PATCH] NDnS: Avoid calling memcpy with identical source and destination addresses

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <david.ward at ll.mit.edu>
---
 .../WiMax/Agents/NDnS/L4_db/NDnSAgent_DB_Common.c  |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

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++;
 			}			
 		}	
-- 
1.7.1



[Index of Archives]     [Linux Kernel]     [Linux Wireless]     [Linux Bluetooth]     [Linux Netdev]     [Linux Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux