Don't use strncpy for moving a chunk of memory to another that is overlapping.
authorRussell Bryant <russell@russellbryant.com>
Thu, 9 Aug 2007 20:07:59 +0000 (20:07 +0000)
committerRussell Bryant <russell@russellbryant.com>
Thu, 9 Aug 2007 20:07:59 +0000 (20:07 +0000)
This was found by running Asterisk under valgrind.

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@78829 65c4cc65-6c06-0410-ace0-fbb531ad65f3

apps/app_minivm.c

index 14729c8..a868bac 100644 (file)
@@ -2275,11 +2275,11 @@ static char *message_template_parse_emailbody(const char *configuration)
               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: