Bladeren bron

* Fix some overlapping strcpy() calls and replace with memmove()

Bryan Drewery 17 jaren geleden
bovenliggende
commit
3c67f7c79e
2 gewijzigde bestanden met toevoegingen van 3 en 5 verwijderingen
  1. 2 4
      src/botcmd.c
  2. 1 1
      src/net.c

+ 2 - 4
src/botcmd.c

@@ -75,8 +75,7 @@ static void bot_chan2(int idx, char *msg)
   /* Strip annoying control chars */
   for (p = from; *p;) {
     if ((*p < 32) || (*p == 127))
-/* FIXME: overlap      strcpy(p, p + 1); */
-      simple_sprintf(p, "%s", p + 1);
+      memmove(p, p + 1, strlen(p));
     else
       p++;
   }
@@ -250,8 +249,7 @@ static void bot_actchan(int idx, char *par)
   chan = base64_to_int(p);
   for (p = from; *p;) {
     if ((*p < 32) || (*p == 127))
-      simple_sprintf(p, "%s", p + 1);
-/* FIXME: overlap      strcpy(p, p + 1); */
+      memmove(p, p + 1, strlen(p));
     else
       p++;
   }

+ 1 - 1
src/net.c

@@ -1284,7 +1284,7 @@ int sockgets(char *s, int *len)
 	  /* Split up into chunks of SGRAB bytes. */
 	  *len = SGRAB;
 	  egg_memcpy(s, socklist[i].inbuf, *len);
-	  egg_memcpy(socklist[i].inbuf, socklist[i].inbuf + *len, *len);
+	  memmove(socklist[i].inbuf, socklist[i].inbuf + *len, *len);
 	  socklist[i].inbuflen -= *len;
 	  socklist[i].inbuf = (char *) my_realloc(socklist[i].inbuf, socklist[i].inbuflen);
 	}