[Asterisk-cvs] asterisk/res res_agi.c, 1.40, 1.41 res_crypto.c, 1.22, 1.23 res_indications.c, 1.12, 1.13 res_monitor.c, 1.36, 1.37 res_odbc.c, 1.16, 1.17 res_osp.c, 1.16, 1.17

russell at lists.digium.com russell at lists.digium.com
Sun Jul 10 19:13:17 CDT 2005


Update of /usr/cvsroot/asterisk/res
In directory mongoose.digium.com:/tmp/cvs-serv4589/res

Modified Files:
	res_agi.c res_crypto.c res_indications.c res_monitor.c 
	res_odbc.c res_osp.c 
Log Message:
more ast_copy_string conversions


Index: res_agi.c
===================================================================
RCS file: /usr/cvsroot/asterisk/res/res_agi.c,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -d -r1.40 -r1.41
--- res_agi.c	21 Jun 2005 01:16:18 -0000	1.40
+++ res_agi.c	10 Jul 2005 23:21:39 -0000	1.41
@@ -757,7 +757,7 @@
 
 	if (argc != 3)
 		return RESULT_SHOWUSAGE;
-	strncpy(chan->context, argv[2], sizeof(chan->context)-1);
+	ast_copy_string(chan->context, argv[2], sizeof(chan->context));
 	fdprintf(agi->fd, "200 result=0\n");
 	return RESULT_SUCCESS;
 }
@@ -766,7 +766,7 @@
 {
 	if (argc != 3)
 		return RESULT_SHOWUSAGE;
-	strncpy(chan->exten, argv[2], sizeof(chan->exten)-1);
+	ast_copy_string(chan->exten, argv[2], sizeof(chan->exten));
 	fdprintf(agi->fd, "200 result=0\n");
 	return RESULT_SUCCESS;
 }
@@ -1028,7 +1028,7 @@
 	char *l = NULL, *n = NULL;
 
 	if (argv[2]) {
-		strncpy(tmp, argv[2], sizeof(tmp) - 1);
+		ast_copy_string(tmp, argv[2], sizeof(tmp));
 		ast_callerid_parse(tmp, &n, &l);
 		if (l)
 			ast_shrink_phone_number(l);
@@ -1925,7 +1925,7 @@
 		ast_log(LOG_WARNING, "AGI requires an argument (script)\n");
 		return -1;
 	}
-	strncpy(buf, data, sizeof(buf) - 1);
+	ast_copy_string(buf, data, sizeof(buf));
 
 	memset(&agi, 0, sizeof(agi));
         while ((stringp = strsep(&tmp, "|"))) {

Index: res_crypto.c
===================================================================
RCS file: /usr/cvsroot/asterisk/res/res_crypto.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- res_crypto.c	6 Jun 2005 22:12:19 -0000	1.22
+++ res_crypto.c	10 Jul 2005 23:21:39 -0000	1.23
@@ -217,9 +217,9 @@
 	if (found)
 		ast_mutex_lock(&keylock);
 	/* First the filename */
-	strncpy(key->fn, ffname, sizeof(key->fn) - 1);
+	ast_copy_string(key->fn, ffname, sizeof(key->fn));
 	/* Then the name */
-	strncpy(key->name, fname, sizeof(key->name) - 1);
+	ast_copy_string(key->name, fname, sizeof(key->name));
 	key->ktype = ktype;
 	/* Yes, assume we're going to be deleted */
 	key->delme = 1;
@@ -529,7 +529,7 @@
 		/* Reload keys that need pass codes now */
 		if (key->ktype & KEY_NEEDS_PASSCODE) {
 			kn = key->fn + strlen(ast_config_AST_KEY_DIR) + 1;
-			strncpy(tmp, kn, sizeof(tmp) - 1);
+			ast_copy_string(tmp, kn, sizeof(tmp));
 			try_load_key((char *)ast_config_AST_KEY_DIR, tmp, fd, fd, &ign);
 		}
 		key = key->next;

Index: res_indications.c
===================================================================
RCS file: /usr/cvsroot/asterisk/res/res_indications.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- res_indications.c	6 Jun 2005 22:12:19 -0000	1.12
+++ res_indications.c	10 Jul 2005 23:21:39 -0000	1.13
@@ -90,7 +90,7 @@
 			return -1;
 		}
 		memset(tz,0,sizeof(struct tone_zone));
-		strncpy(tz->country,argv[2],sizeof(tz->country)-1);
+		ast_copy_string(tz->country,argv[2],sizeof(tz->country));
 		if (ast_register_indication_country(tz)) {
 			ast_log(LOG_WARNING, "Unable to register new country\n");
 			free(tz);
@@ -176,7 +176,7 @@
 					j += snprintf(buf+j,sizeof(buf)-j,"%d,",tz->ringcadance[i]);
 				}
 				if (tz->nrringcadance) j--;
-				strncpy(buf+j,"\n",sizeof(buf)-j-1);
+				ast_copy_string(buf+j,"\n",sizeof(buf)-j);
 				ast_cli(fd,buf);
 				for (ts=tz->tones; ts; ts=ts->next)
 					ast_cli(fd,"%-7.7s %-15.15s %s\n",tz->country,ts->name,ts->data);
@@ -254,12 +254,12 @@
 			return -1;
 		}
 		memset(tones,0,sizeof(struct tone_zone));
-		strncpy(tones->country,cxt,sizeof(tones->country) - 1);
+		ast_copy_string(tones->country,cxt,sizeof(tones->country));
 
 		v = ast_variable_browse(cfg, cxt);
 		while(v) {
 			if (!strcasecmp(v->name, "description")) {
-				strncpy(tones->description, v->value, sizeof(tones->description)-1);
+				ast_copy_string(tones->description, v->value, sizeof(tones->description));
 			} else if (!strcasecmp(v->name,"ringcadance")) {
 				char *ring,*rings = ast_strdupa(v->value);
 				c = rings;
@@ -295,8 +295,8 @@
 						return -1;
 					}
 					memset(azone,0,sizeof(struct tone_zone));
-					strncpy(azone->country, country, sizeof(azone->country) - 1);
-					strncpy(azone->alias, cxt, sizeof(azone->alias)-1);
+					ast_copy_string(azone->country, country, sizeof(azone->country));
+					ast_copy_string(azone->alias, cxt, sizeof(azone->alias));
 					if (ast_register_indication_country(azone)) {
 						ast_log(LOG_WARNING, "Unable to register indication alias at line %d.\n",v->lineno);
 						free(tones);

Index: res_monitor.c
===================================================================
RCS file: /usr/cvsroot/asterisk/res/res_monitor.c,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -d -r1.36 -r1.37
--- res_monitor.c	6 Jun 2005 22:12:19 -0000	1.36
+++ res_monitor.c	10 Jul 2005 23:21:39 -0000	1.37
@@ -124,7 +124,7 @@
 						directory ? "" : ast_config_AST_MONITOR_DIR, fname_base);
 			snprintf(monitor->write_filename, FILENAME_MAX, "%s/%s-out",
 						directory ? "" : ast_config_AST_MONITOR_DIR, fname_base);
-			strncpy(monitor->filename_base, fname_base, sizeof(monitor->filename_base) - 1);
+			ast_copy_string(monitor->filename_base, fname_base, sizeof(monitor->filename_base));
 		} else {
 			ast_mutex_lock(&monitorlock);
 			snprintf(monitor->read_filename, FILENAME_MAX, "%s/audio-in-%ld",
@@ -264,7 +264,7 @@
 			snprintf(tmp, sizeof(tmp), "%s \"%s/%s-in.%s\" \"%s/%s-out.%s\" \"%s/%s.%s\" %s &", execute, dir, name, format, dir, name, format, dir, name, format,execute_args);
 			if (delfiles) {
 				snprintf(tmp2,sizeof(tmp2), "( %s& rm -f \"%s/%s-\"* ) &",tmp, dir ,name); /* remove legs when done mixing */
-				strncpy(tmp, tmp2, sizeof(tmp) - 1);
+				ast_copy_string(tmp, tmp2, sizeof(tmp));
 			}
 			ast_log(LOG_DEBUG,"monitor executing %s\n",tmp);
 			if (ast_safe_system(tmp) == -1)
@@ -440,7 +440,7 @@
 			return 0;
 		}
 		memset(fname, 0, FILENAME_MAX);
-		strncpy(fname, c->name, FILENAME_MAX-1);
+		ast_copy_string(fname, c->name, FILENAME_MAX);
 		/* Channels have the format technology/channel_name - have to replace that /  */
 		if ((d=strchr(fname, '/'))) *d='-';
 	}

Index: res_odbc.c
===================================================================
RCS file: /usr/cvsroot/asterisk/res/res_odbc.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- res_odbc.c	8 Jul 2005 17:06:54 -0000	1.16
+++ res_odbc.c	10 Jul 2005 23:21:39 -0000	1.17
@@ -67,7 +67,7 @@
 	int x = 0;
 	for (x = 0; x < MAX_ODBC_HANDLES; x++) {
 		if (!registry[x].used) {
-			strncpy(registry[x].name, name, sizeof(registry[x].name) - 1);
+			ast_copy_string(registry[x].name, name, sizeof(registry[x].name));
 			registry[x].obj = obj;
 			registry[x].used = 1;
 			return 1;

Index: res_osp.c
===================================================================
RCS file: /usr/cvsroot/asterisk/res/res_osp.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- res_osp.c	20 Jun 2005 17:46:54 -0000	1.16
+++ res_osp.c	10 Jul 2005 23:21:39 -0000	1.17
@@ -116,7 +116,7 @@
 		memset(osp, 0, sizeof(struct osp_provider));
 		osp->handle = -1;
 	}
-	strncpy(osp->name, cat, sizeof(osp->name) - 1);
+	ast_copy_string(osp->name, cat, sizeof(osp->name));
 	snprintf(osp->localpvtkey, sizeof(osp->localpvtkey) ,"%s/%s-privatekey.pem", ast_config_AST_KEY_DIR, cat);
 	snprintf(osp->localcert, sizeof(osp->localpvtkey), "%s/%s-localcert.pem", ast_config_AST_KEY_DIR, cat);
 	osp->maxconnections=OSP_DEFAULT_MAX_CONNECTIONS;
@@ -129,18 +129,18 @@
 	while(v) {
 		if (!strcasecmp(v->name, "privatekey")) {
 			if (v->value[0] == '/')
-				strncpy(osp->localpvtkey, v->value, sizeof(osp->localpvtkey) - 1);
+				ast_copy_string(osp->localpvtkey, v->value, sizeof(osp->localpvtkey));
 			else
 				snprintf(osp->localpvtkey, sizeof(osp->localpvtkey), "%s/%s", ast_config_AST_KEY_DIR , v->value);
 		} else if (!strcasecmp(v->name, "localcert")) {
 			if (v->value[0] == '/')
-				strncpy(osp->localcert, v->value, sizeof(osp->localcert) - 1);
+				ast_copy_string(osp->localcert, v->value, sizeof(osp->localcert));
 			else
 				snprintf(osp->localcert, sizeof(osp->localcert), "%s/%s", ast_config_AST_KEY_DIR, v->value);
 		} else if (!strcasecmp(v->name, "cacert")) {
 			if (osp->cacount < MAX_CERTS) {
 				if (v->value[0] == '/')
-					strncpy(osp->cacerts[osp->cacount], v->value, sizeof(osp->cacerts[0]) - 1);
+					ast_copy_string(osp->cacerts[osp->cacount], v->value, sizeof(osp->cacerts[0]));
 				else
 					snprintf(osp->cacerts[osp->cacount], sizeof(osp->cacerts[0]), "%s/%s", ast_config_AST_KEY_DIR, v->value);
 				osp->cacount++;
@@ -148,7 +148,7 @@
 				ast_log(LOG_WARNING, "Too many CA Certificates at line %d\n", v->lineno);
 		} else if (!strcasecmp(v->name, "servicepoint")) {
 			if (osp->spcount < MAX_SERVICEPOINTS) {
-				strncpy(osp->servicepoints[osp->spcount], v->value, sizeof(osp->servicepoints[0]) - 1);
+				ast_copy_string(osp->servicepoints[osp->spcount], v->value, sizeof(osp->servicepoints[0]));
 				osp->spcount++;
 			} else
 				ast_log(LOG_WARNING, "Too many Service points at line %d\n", v->lineno);
@@ -173,7 +173,7 @@
 			} else
 				ast_log(LOG_WARNING, "timeout should be an integer from 200 to 10000, not '%s' at line %d\n", v->value, v->lineno);
 		} else if (!strcasecmp(v->name, "source")) {
-			strncpy(osp->source, v->value, sizeof(osp->source) - 1);
+			ast_copy_string(osp->source, v->value, sizeof(osp->source));
 		}
 		v = v->next;
 	}
@@ -445,7 +445,7 @@
 	*handle = -1;
 	if (!callerid)
 		callerid = "";
-	strncpy(tmp, callerid, sizeof(tmp) - 1);
+	ast_copy_string(tmp, callerid, sizeof(tmp));
 	ast_callerid_parse(tmp, &n, &l);
 	if (!l)
 		l = "";
@@ -463,7 +463,7 @@
 			if (OSPPTransactionNew(osp->handle, handle)) {
 				ast_log(LOG_WARNING, "Unable to create OSP Transaction handle!\n");
 			} else {
-				strncpy(source, osp->source, sizeof(source) - 1);
+				ast_copy_string(source, osp->source, sizeof(source));
 				res = 1;
 			}
 			break;
@@ -516,7 +516,7 @@
 
 	if (!callerid)
 		callerid = "";
-	strncpy(tmp, callerid, sizeof(tmp) - 1);
+	ast_copy_string(tmp, callerid, sizeof(tmp));
 	ast_callerid_parse(tmp, &n, &l);
 	if (!l)
 		l = "";
@@ -528,7 +528,7 @@
 	callerid = l;
 
 	if (chan) {
-		strncpy(uniqueid, chan->uniqueid, sizeof(uniqueid) - 1);
+		ast_copy_string(uniqueid, chan->uniqueid, sizeof(uniqueid));
 		cres = ast_autoservice_start(chan);
 		if (cres < 0)
 			return cres;
@@ -540,7 +540,7 @@
 			if (OSPPTransactionNew(osp->handle, &result->handle)) {
 				ast_log(LOG_WARNING, "Unable to create OSP Transaction handle!\n");
 			} else {
-				strncpy(source, osp->source, sizeof(source) - 1);
+				ast_copy_string(source, osp->source, sizeof(source));
 				res = 1;
 			}
 			break;
@@ -573,15 +573,15 @@
 								destination[strlen(destination) - 1] = '\0';
 								switch(prot) {
 								case OSPE_DEST_PROT_H323_SETUP:
-									strncpy(result->tech, "H323", sizeof(result->tech) - 1);
+									ast_copy_string(result->tech, "H323", sizeof(result->tech));
 									snprintf(result->dest, sizeof(result->dest), "%s@%s", callednum, destination + 1);
 									break;
 								case OSPE_DEST_PROT_SIP:
-									strncpy(result->tech, "SIP", sizeof(result->tech) - 1);
+									ast_copy_string(result->tech, "SIP", sizeof(result->tech));
 									snprintf(result->dest, sizeof(result->dest), "%s@%s", callednum, destination + 1);
 									break;
 								case OSPE_DEST_PROT_IAX:
-									strncpy(result->tech, "IAX", sizeof(result->tech) - 1);
+									ast_copy_string(result->tech, "IAX", sizeof(result->tech));
 									snprintf(result->dest, sizeof(result->dest), "%s@%s", callednum, destination + 1);
 									break;
 								default:
@@ -656,15 +656,15 @@
 						destination[strlen(destination) - 1] = '\0';
 						switch(prot) {
 						case OSPE_DEST_PROT_H323_SETUP:
-							strncpy(result->tech, "H323", sizeof(result->tech) - 1);
+							ast_copy_string(result->tech, "H323", sizeof(result->tech));
 							snprintf(result->dest, sizeof(result->dest), "%s@%s", callednum, destination + 1);
 							break;
 						case OSPE_DEST_PROT_SIP:
-							strncpy(result->tech, "SIP", sizeof(result->tech) - 1);
+							ast_copy_string(result->tech, "SIP", sizeof(result->tech));
 							snprintf(result->dest, sizeof(result->dest), "%s@%s", callednum, destination + 1);
 							break;
 						case OSPE_DEST_PROT_IAX:
-							strncpy(result->tech, "IAX", sizeof(result->tech) - 1);
+							ast_copy_string(result->tech, "IAX", sizeof(result->tech));
 							snprintf(result->dest, sizeof(result->dest), "%s@%s", callednum, destination + 1);
 							break;
 						default:




More information about the svn-commits mailing list