From 07e1a670bc85fa9c6ad6d5a07dd9fb07c0905d9a Mon Sep 17 00:00:00 2001 From: rpdigos Date: Tue, 2 May 2017 18:30:47 -0300 Subject: [PATCH] Replaced strcopy with memmove (#2061) Shortened the original title and commit message a little. Thanks to @rpdigos! Original commit message: When we try to run the application we got the signal Abort trap 6 and the application is interrupted by the OS. This issue is related with the fact that when using strncpy the source and destination string should not overlap, as we can see in the man page: man stpncpy() ... The source and destination strings should not overlap, as the behavior is undefined. We've replaced it by the function memove: man memmove() ... The two strings may overlap; the copy is always done in a non-destructive manner. Follow ec1fe15d7d480e4fa6ff3f56986bbfd49a4cde2a --- src/map/map.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/map/map.c b/src/map/map.c index 289d1b1636..761d863746 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -3990,9 +3990,8 @@ int inter_config_read(char *cfgName) #define RENEWALPREFIX "renewal-" if (!strncmpi(w1, RENEWALPREFIX, strlen(RENEWALPREFIX))) { #ifdef RENEWAL - // Copy the original name - // Do not use safestrncpy here - enforces zero termination before copying and will break it [Lemongrass] - strncpy(w1, w1 + strlen(RENEWALPREFIX), strlen(w1) - strlen(RENEWALPREFIX) + 1); + // Move the original name to the beginning of the string + memmove(w1, w1 + strlen(RENEWALPREFIX), strlen(w1) - strlen(RENEWALPREFIX) + 1); #else // In Pre-Renewal the Renewal specific configurations can safely be ignored continue;