[asterisk-commits] trunk r22015 - /trunk/enum.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Fri Apr 21 10:47:46 MST 2006


Author: rizzo
Date: Fri Apr 21 12:47:44 2006
New Revision: 22015

URL: http://svn.digium.com/view/asterisk?rev=22015&view=rev
Log:
replace strncpy with ast_copy_string and fix the -1 offset which
is not needed now.


Modified:
    trunk/enum.c

Modified: trunk/enum.c
URL: http://svn.digium.com/view/asterisk/trunk/enum.c?rev=22015&r1=22014&r2=22015&view=diff
==============================================================================
--- trunk/enum.c (original)
+++ trunk/enum.c Fri Apr 21 12:47:44 2006
@@ -412,11 +412,7 @@
 	int i = 0;
 	int z = 0;
 
-	if (number[0] == 'n') {
-		strncpy(naptrinput, number+1, sizeof(naptrinput));
-	} else {
-		strncpy(naptrinput, number, sizeof(naptrinput));
-	}
+	ast_copy_string(naptrinput, number[0] == 'n' ? number+1 : number, sizeof(naptrinput));
 
 	context.naptrinput = naptrinput;	/* The number */
 	context.dst = dst;			/* Return string */
@@ -487,11 +483,7 @@
 		} else {
 			s = s->next;
 		}
-		if (suffix != NULL) {
-			strncpy(tmp + newpos, suffix, sizeof(tmp) - newpos - 1);
-		} else if (s) {
-			strncpy(tmp + newpos, s->toplev, sizeof(tmp) - newpos - 1);
-		}
+		ast_copy_string(tmp + newpos, suffix ? suffix : s->toplev, sizeof(tmp) - newpos);
 		ast_mutex_unlock(&enumlock);
 		if (!s)
 			break;
@@ -600,7 +592,7 @@
 			s = s->next;
 		}
 		if (s) {
-			strncpy(tmp + newpos, s->toplev, sizeof(tmp) - newpos - 1);
+			ast_copy_string(tmp + newpos, s->toplev, sizeof(tmp) - newpos);
 		}
 		ast_mutex_unlock(&enumlock);
 		if (!s)



More information about the asterisk-commits mailing list