strncpy to ast_copy_string
authorRussell Bryant <russell@russellbryant.com>
Thu, 27 Oct 2005 02:42:05 +0000 (02:42 +0000)
committerRussell Bryant <russell@russellbryant.com>
Thu, 27 Oct 2005 02:42:05 +0000 (02:42 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@6867 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/iax2-parser.c

index bf93f46..f0721c4 100755 (executable)
@@ -77,7 +77,7 @@ static void dump_string(char *output, int maxlen, void *value, int len)
        maxlen--;
        if (maxlen > len)
                maxlen = len;
        maxlen--;
        if (maxlen > len)
                maxlen = len;
-       strncpy(output,value, maxlen);
+       ast_copy_string(output, value, maxlen);
        output[maxlen] = '\0';
 }
 
        output[maxlen] = '\0';
 }
 
@@ -92,7 +92,7 @@ static void dump_prefs(char *output, int maxlen, void *value, int len)
        if (maxlen > len)
                maxlen = len;
 
        if (maxlen > len)
                maxlen = len;
 
-       strncpy(output,value, maxlen);
+       ast_copy_string(output, value, maxlen);
        output[maxlen] = '\0';
        
        ast_codec_pref_convert(&pref, output, total_len, 0);
        output[maxlen] = '\0';
        
        ast_codec_pref_convert(&pref, output, total_len, 0);
@@ -312,7 +312,7 @@ static void dump_prov_ies(char *output, int maxlen, unsigned char *iedata, int l
                                if (prov_ies[x].dump) {
                                        prov_ies[x].dump(interp, (int)sizeof(interp), iedata + 2, ielen);
                                        snprintf(tmp, (int)sizeof(tmp), "       %-15.15s : %s\n", prov_ies[x].name, interp);
                                if (prov_ies[x].dump) {
                                        prov_ies[x].dump(interp, (int)sizeof(interp), iedata + 2, ielen);
                                        snprintf(tmp, (int)sizeof(tmp), "       %-15.15s : %s\n", prov_ies[x].name, interp);
-                                       strncpy(output, tmp, maxlen - 1);
+                                       ast_copy_string(output, tmp, maxlen);
                                        maxlen -= strlen(output); output += strlen(output);
                                } else {
                                        if (ielen)
                                        maxlen -= strlen(output); output += strlen(output);
                                } else {
                                        if (ielen)
@@ -320,7 +320,7 @@ static void dump_prov_ies(char *output, int maxlen, unsigned char *iedata, int l
                                        else
                                                strcpy(interp, "Present");
                                        snprintf(tmp, (int)sizeof(tmp), "       %-15.15s : %s\n", prov_ies[x].name, interp);
                                        else
                                                strcpy(interp, "Present");
                                        snprintf(tmp, (int)sizeof(tmp), "       %-15.15s : %s\n", prov_ies[x].name, interp);
-                                       strncpy(output, tmp, maxlen - 1);
+                                       ast_copy_string(output, tmp, maxlen);
                                        maxlen -= strlen(output); output += strlen(output);
                                }
                                found++;
                                        maxlen -= strlen(output); output += strlen(output);
                                }
                                found++;
@@ -328,7 +328,7 @@ static void dump_prov_ies(char *output, int maxlen, unsigned char *iedata, int l
                }
                if (!found) {
                        snprintf(tmp, (int)sizeof(tmp), "       Unknown Prov IE %03d  : Present\n", ie);
                }
                if (!found) {
                        snprintf(tmp, (int)sizeof(tmp), "       Unknown Prov IE %03d  : Present\n", ie);
-                       strncpy(output, tmp, maxlen - 1);
+                       ast_copy_string(output, tmp, maxlen);
                        maxlen -= strlen(output); output += strlen(output);
                }
                iedata += (2 + ielen);
                        maxlen -= strlen(output); output += strlen(output);
                }
                iedata += (2 + ielen);