[asterisk-commits] russell: trunk r78829 - /trunk/apps/app_minivm.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Aug 9 15:08:00 CDT 2007


Author: russell
Date: Thu Aug  9 15:07:59 2007
New Revision: 78829

URL: http://svn.digium.com/view/asterisk?view=rev&rev=78829
Log:
Don't use strncpy for moving a chunk of memory to another that is overlapping.
This was found by running Asterisk under valgrind.

Modified:
    trunk/apps/app_minivm.c

Modified: trunk/apps/app_minivm.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_minivm.c?view=diff&rev=78829&r1=78828&r2=78829
==============================================================================
--- trunk/apps/app_minivm.c (original)
+++ trunk/apps/app_minivm.c Thu Aug  9 15:07:59 2007
@@ -2275,11 +2275,11 @@
 	       int len = strlen("\n");
 	       switch (tmpwrite[1]) {
 	       case 'n':
-		      strncpy(tmpwrite+len, tmpwrite+2, strlen(tmpwrite+2)+1);
+		      memmove(tmpwrite + len, tmpwrite + 2, strlen(tmpwrite + 2) + 1);
 		      strncpy(tmpwrite, "\n", len);
 		      break;
 	       case 't':
-		      strncpy(tmpwrite+len, tmpwrite+2, strlen(tmpwrite+2)+1);
+		      memmove(tmpwrite + len, tmpwrite + 2, strlen(tmpwrite + 2) + 1);
 		      strncpy(tmpwrite, "\t", len);
 		      break;
 	       default:




More information about the asterisk-commits mailing list