ecere: Fixed calls to strcpy with overlapping buffers (New libc is stricter, it was...
authorJerome St-Louis <jerome@ecere.com>
Sun, 4 Mar 2012 21:26:25 +0000 (16:26 -0500)
committerJerome St-Louis <jerome@ecere.com>
Sun, 4 Mar 2012 21:26:25 +0000 (16:26 -0500)
compiler/bootstrap/ecere/bootstrap/String.c
compiler/bootstrap/ecere/bootstrap/i18n.c
ecere/src/com/String.ec
ecere/src/sys/i18n.ec

index f042fe5..ac5d845 100644 (file)
@@ -900,6 +900,7 @@ return 0x0;
 
 char * __ecereNameSpace__ecere__sys__ChangeExtension(char * string, char * ext, char * output)
 {
+if(string != output)
 strcpy(output, string);
 __ecereNameSpace__ecere__sys__StripExtension(output);
 if(ext[0])
@@ -1178,7 +1179,7 @@ int c;
 
 for(c = 0; string[c] && string[c] == ' '; c++)
 ;
-strcpy(output, string + c);
+memmove(output, string + c, strlen(string + c) + 1);
 return output;
 }
 
index f6644f2..b6bbff7 100644 (file)
@@ -357,6 +357,7 @@ if(locale)
 {
 char * dot;
 
+if(language != locale)
 strcpy(language, locale);
 dot = strstr(language, ".");
 if(dot)
index a5efa25..cd51949 100644 (file)
@@ -672,7 +672,8 @@ public bool StripExtension(char * string)
 
 public char * ChangeExtension(char * string, char * ext, char * output)
 {
-   strcpy(output, string);
+   if(string != output)
+      strcpy(output, string);
    StripExtension(output);
    if(ext[0])
       strcat(output, ".");
@@ -949,7 +950,7 @@ public char * TrimLSpaces(char * string, char * output)
 {
    int c;
    for(c = 0; string[c] && string[c] == ' '; c++);
-   strcpy(output, string + c);
+   memmove(output, string + c, strlen(string+c)+1);
    return output;
 }
 
index e387574..491ab0d 100644 (file)
@@ -45,7 +45,8 @@ public dllexport void LoadTranslatedStrings(Module module, char * name)
    if(locale)
    {
       char * dot;
-      strcpy(language, locale);
+      if(language != locale)
+         strcpy(language, locale);
       dot = strstr(language, ".");
       if(dot) *dot = 0;
       locale = language;