[Asterisk-cvs] asterisk/res res_adsi.c,1.8,1.9 res_config_odbc.c,1.6,1.7 res_crypto.c,1.10,1.11 res_indications.c,1.6,1.7 res_musiconhold.c,1.34,1.35 res_odbc.c,1.4,1.5 res_osp.c,1.6,1.7

markster at lists.digium.com markster at lists.digium.com
Wed Jul 14 10:11:31 CDT 2004


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

Modified Files:
	res_adsi.c res_config_odbc.c res_crypto.c res_indications.c 
	res_musiconhold.c res_odbc.c res_osp.c 
Log Message:
Merge remaining audit patch (save dlfcn.c)


Index: res_adsi.c
===================================================================
RCS file: /usr/cvsroot/asterisk/res/res_adsi.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- res_adsi.c	29 Jun 2004 04:42:19 -0000	1.8
+++ res_adsi.c	14 Jul 2004 13:57:15 -0000	1.9
@@ -1006,13 +1006,13 @@
 
 	for (x=0;x<ADSI_MAX_INTRO;x++)
 		aligns[x] = ADSI_JUST_CENT;
-	strcpy(intro[0], "Welcome to the");
-	strcpy(intro[1], "Asterisk");
-	strcpy(intro[2], "Open Source PBX");
+	strncpy(intro[0], "Welcome to the", sizeof(intro[0]) - 1);
+	strncpy(intro[1], "Asterisk", sizeof(intro[1]) - 1);
+	strncpy(intro[2], "Open Source PBX", sizeof(intro[2]) - 1);
 	total = 3;
 	speeds = 0;
 	for (x=3;x<ADSI_MAX_INTRO;x++)
-		strcpy(intro[x], "");
+		intro[x][0] = '\0';
 	memset(speeddial, 0, sizeof(speeddial));
 	alignment = ADSI_JUST_CENT;
 }
@@ -1034,7 +1034,8 @@
 			else if (!strcasecmp(v->name, "greeting")) {
 				if (x < ADSI_MAX_INTRO) {
 					aligns[x] = alignment;
-					strncpy(intro[x], v->value, 20);
+					strncpy(intro[x], v->value, sizeof(intro[x]) - 1);
+					intro[x][sizeof(intro[x]) - 1] = '\0';
 					x++;
 				}
 			} else if (!strcasecmp(v->name, "maxretries")) {
@@ -1056,7 +1057,7 @@
 				sname = name;
 			if (x < ADSI_MAX_SPEED_DIAL) {
 				/* Up to 20 digits */
-				strncpy(speeddial[x][0], v->name, 20);
+				strncpy(speeddial[x][0], v->name, sizeof(speeddial[x][0]) - 1);
 				strncpy(speeddial[x][1], name, 18);
 				strncpy(speeddial[x][2], sname, 7);
 				x++;

Index: res_config_odbc.c
===================================================================
RCS file: /usr/cvsroot/asterisk/res/res_config_odbc.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- res_config_odbc.c	13 Jul 2004 22:53:17 -0000	1.6
+++ res_config_odbc.c	14 Jul 2004 13:57:15 -0000	1.7
@@ -38,16 +38,16 @@
 	struct ast_config *config, *new;
 	struct ast_variable *v, *cur_v, *new_v;
 	struct ast_category *cur_cat, *new_cat;
-	char table[128];
-	char connection[128];
+	char table[128] = "";
+	char connection[128] = "";
 	int configured = 0, res = 0;
 	odbc_obj *obj;
 	SQLINTEGER err=0, commented=0, cat_metric=0, var_metric=0, last_cat_metric=0;
 	SQLBIGINT id;
-	char sql[255], filename[128], category[128], var_name[128], var_val[128];
+	char sql[255] = "", filename[128], category[128], var_name[128], var_val[128];
 	SQLSMALLINT rowcount=0;
 	SQLHSTMT stmt;
-	char last[80];
+	char last[80] = "";
 	int cat_started = 0;
 	int var_started = 0;
 
@@ -68,10 +68,10 @@
 	if (config) {
 		for (v = ast_variable_browse (config, "settings"); v; v = v->next) {
 			if (!strcmp (v->name, "table")) {
-				strncpy (table, v->value, sizeof (table));
+				strncpy(table, v->value, sizeof(table) - 1);
 				configured++;
 			} else if (!strcmp (v->name, "connection")) {
-				strncpy (connection, v->value, sizeof (connection));
+				strncpy(connection, v->value, sizeof(connection) - 1);
 				configured++;
 			}
 		}
@@ -96,7 +96,7 @@
 	SQLBindCol (stmt, 7, SQL_C_CHAR, &var_name, sizeof (var_name), &err);
 	SQLBindCol (stmt, 8, SQL_C_CHAR, &var_val, sizeof (var_val), &err);
 
-	sprintf (sql, "select * from %s where filename='%s' and commented=0 order by filename,cat_metric desc,var_metric asc,id", table, file);
+	snprintf(sql, sizeof(sql), "select * from %s where filename='%s' and commented=0 order by filename,cat_metric desc,var_metric asc,id", table, file);
 	res = SQLExecDirect (stmt, sql, SQL_NTS);
 
 	if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {
@@ -133,7 +133,7 @@
 				);
 			} else {
 				if (strcmp (last, category) || last_cat_metric != cat_metric) {
-					strcpy (last, category);
+					strncpy(last, category, sizeof(last) - 1);
 					last_cat_metric	= cat_metric;
 					new_cat = (struct ast_category *) ast_new_category (category);
 
@@ -184,7 +184,7 @@
 int load_module (void)
 {
 	memset (&reg1, 0, sizeof (struct ast_config_reg));
-	strcpy (reg1.name, "odbc");
+	strncpy(reg1.name, "odbc", sizeof(reg1.name) - 1);
 	reg1.func = config_odbc;
 	ast_cust_config_register (&reg1);
 	ast_log (LOG_NOTICE, "res_config_odbc loaded.\n");

Index: res_crypto.c
===================================================================
RCS file: /usr/cvsroot/asterisk/res/res_crypto.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- res_crypto.c	25 Jun 2004 03:59:07 -0000	1.10
+++ res_crypto.c	14 Jul 2004 13:57:15 -0000	1.11
@@ -213,9 +213,9 @@
 	if (found)
 		ast_mutex_lock(&keylock);
 	/* First the filename */
-	strncpy(key->fn, ffname, sizeof(key->fn));
+	strncpy(key->fn, ffname, sizeof(key->fn) - 1);
 	/* Then the name */
-	strncpy(key->name, fname, sizeof(key->name));
+	strncpy(key->name, fname, sizeof(key->name) - 1);
 	key->ktype = ktype;
 	/* Yes, assume we're going to be deleted */
 	key->delme = 1;
@@ -444,14 +444,14 @@
 	struct ast_key *key;
 	int ign;
 	char *kn;
-	char tmp[256];
+	char tmp[256] = "";
 
 	key = keys;
 	while(key) {
 		/* 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));
+			strncpy(tmp, kn, sizeof(tmp) - 1);
 			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.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- res_indications.c	22 Jun 2004 18:49:00 -0000	1.6
+++ res_indications.c	14 Jul 2004 13:57:15 -0000	1.7
@@ -163,7 +163,7 @@
 					j += snprintf(buf+j,sizeof(buf)-j,"%d,",tz->ringcadance[i]);
 				}
 				if (tz->nrringcadance) j--;
-				strncpy(buf+j,"\n",sizeof(buf)-j);
+				strncpy(buf+j,"\n",sizeof(buf)-j-1);
 				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);
@@ -241,7 +241,7 @@
 			return -1;
 		}
 		memset(tones,0,sizeof(struct tone_zone));
-		strncpy(tones->country,cxt,sizeof(tones->country));
+		strncpy(tones->country,cxt,sizeof(tones->country) - 1);
 
 		v = ast_variable_browse(cfg, cxt);
 		while(v) {
@@ -282,7 +282,7 @@
 						return -1;
 					}
 					memset(azone,0,sizeof(struct tone_zone));
-					strncpy(azone->country,country,sizeof(azone->country));
+					strncpy(azone->country, country, sizeof(azone->country) - 1);
 					strncpy(azone->alias, cxt, sizeof(azone->alias)-1);
 					if (ast_register_indication_country(azone)) {
 						ast_log(LOG_WARNING, "Unable to register indication alias at line %d.\n",v->lineno);

Index: res_musiconhold.c
===================================================================
RCS file: /usr/cvsroot/asterisk/res/res_musiconhold.c,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- res_musiconhold.c	2 Jul 2004 23:11:14 -0000	1.34
+++ res_musiconhold.c	14 Jul 2004 13:57:15 -0000	1.35
@@ -153,7 +153,7 @@
 	files = 0;
 	while((de = readdir(dir)) && (files < MAX_MP3S)) {
 		if ((strlen(de->d_name) > 3) && !strcasecmp(de->d_name + strlen(de->d_name) - 4, ".mp3")) {
-			strncpy(fns[files], de->d_name, sizeof(fns[files]));
+			strncpy(fns[files], de->d_name, sizeof(fns[files]) - 1);
 			argv[argc++] = fns[files];
 			files++;
 		}
@@ -340,7 +340,7 @@
 		ast_log(LOG_WARNING, "SetMusicOnHold requires an argument (class)\n");
 		return -1;
 	}
-	strncpy(chan->musicclass, data, sizeof(chan->musicclass));
+	strncpy(chan->musicclass, data, sizeof(chan->musicclass) - 1);
 	return 0;
 }
 

Index: res_odbc.c
===================================================================
RCS file: /usr/cvsroot/asterisk/res/res_odbc.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- res_odbc.c	8 Jul 2004 19:58:26 -0000	1.4
+++ res_odbc.c	14 Jul 2004 13:57:15 -0000	1.5
@@ -61,7 +61,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));
+			strncpy(registry[x].name, name, sizeof(registry[x].name) - 1);
 			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.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- res_osp.c	30 Jun 2004 16:56:51 -0000	1.6
+++ res_osp.c	14 Jul 2004 13:57:15 -0000	1.7
@@ -121,7 +121,7 @@
 	osp->retrydelay = OSP_DEFAULT_RETRY_DELAY;
 	osp->retrylimit = OSP_DEFAULT_RETRY_LIMIT;
 	osp->timeout = OSP_DEFAULT_TIMEOUT;
-	strcpy(osp->source, "");
+	osp->source[0] = '\0';
 	ast_log(LOG_DEBUG, "Building OSP Provider '%s'\n", cat);
 	v = ast_variable_browse(cfg, cat);
 	while(v) {
@@ -138,7 +138,7 @@
 		} 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]));
+					strncpy(osp->cacerts[osp->cacount], v->value, sizeof(osp->cacerts[0]) - 1);
 				else
 					snprintf(osp->cacerts[osp->cacount], sizeof(osp->cacerts[0]), AST_KEY_DIR "/%s", v->value);
 				osp->cacount++;
@@ -146,7 +146,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]));
+				strncpy(osp->servicepoints[osp->spcount], v->value, sizeof(osp->servicepoints[0]) - 1);
 				osp->spcount++;
 			} else
 				ast_log(LOG_WARNING, "Too many Service points at line %d\n", v->lineno);
@@ -424,7 +424,7 @@
 {
 	char tmp[256]="", *l, *n;
 	char iabuf[INET_ADDRSTRLEN];
-	char source[OSP_MAX]; /* Same length as osp->source */
+	char source[OSP_MAX] = ""; /* Same length as osp->source */
 	char *token2;
 	int tokenlen;
 	struct osp_provider *osp;
@@ -459,7 +459,7 @@
 			if (OSPPTransactionNew(osp->handle, handle)) {
 				ast_log(LOG_WARNING, "Unable to create OSP Transaction handle!\n");
 			} else {
-				strcpy(source, osp->source);
+				strncpy(source, osp->source, sizeof(source) - 1);
 				res = 1;
 			}
 			break;
@@ -491,7 +491,7 @@
 	unsigned int timelimit;
 	unsigned int callidlen;
 	struct osp_provider *osp;
-	char source[OSP_MAX]; /* Same length as osp->source */
+	char source[OSP_MAX] = ""; /* Same length as osp->source */
 	char uniqueid[32] = "";
 	char callednum[2048]="";
 	char destination[2048]="";
@@ -502,9 +502,9 @@
 
 	result->handle = -1;
 	result->numresults = 0;
-	strcpy(result->tech, "");
-	strcpy(result->dest, "");
-	strcpy(result->token, "");
+	result->tech[0] = '\0';
+	result->dest[0] = '\0';
+	result->token[0] = '\0';
 
 	if (!provider || !strlen(provider))
 		provider = "default";
@@ -535,7 +535,7 @@
 			if (OSPPTransactionNew(osp->handle, &result->handle)) {
 				ast_log(LOG_WARNING, "Unable to create OSP Transaction handle!\n");
 			} else {
-				strcpy(source, osp->source);
+				strncpy(source, osp->source, sizeof(source) - 1);
 				res = 1;
 			}
 			break;
@@ -568,11 +568,11 @@
 								destination[strlen(destination) - 1] = '\0';
 								switch(prot) {
 								case OSPE_DEST_PROT_H323_SETUP:
-									strcpy(result->tech, "H323");
+									strncpy(result->tech, "H323", sizeof(result->tech) - 1);
 									snprintf(result->dest, sizeof(result->dest), "%s@%s", callednum, destination + 1);
 									break;
 								case OSPE_DEST_PROT_SIP:
-									strcpy(result->tech, "SIP");
+									strncpy(result->tech, "SIP", sizeof(result->tech) - 1);
 									snprintf(result->dest, sizeof(result->dest), "%s@%s", callednum, destination + 1);
 									break;
 								default:
@@ -626,9 +626,9 @@
 	char token[2000];
 	OSPE_DEST_PROT prot;
 
-	strcpy(result->tech, "");
-	strcpy(result->dest, "");
-	strcpy(result->token, "");
+	result->tech[0] = '\0';
+	result->dest[0] = '\0';
+	result->token[0] = '\0';
 
 	if (result->handle > -1) {
 		dummy = 0;
@@ -646,11 +646,11 @@
 						destination[strlen(destination) - 1] = '\0';
 						switch(prot) {
 						case OSPE_DEST_PROT_H323_SETUP:
-							strcpy(result->tech, "H323");
+							strncpy(result->tech, "H323", sizeof(result->tech) - 1);
 							snprintf(result->dest, sizeof(result->dest), "%s@%s", callednum, destination + 1);
 							break;
 						case OSPE_DEST_PROT_SIP:
-							strcpy(result->tech, "SIP");
+							strncpy(result->tech, "SIP", sizeof(result->tech) - 1);
 							snprintf(result->dest, sizeof(result->dest), "%s@%s", callednum, destination + 1);
 							break;
 						default:




More information about the svn-commits mailing list