Преглед на файлове

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
rpdigos преди 8 години
родител
ревизия
07e1a670bc
променени са 1 файла, в които са добавени 2 реда и са изтрити 3 реда
  1. 2 3
      src/map/map.c

+ 2 - 3
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;