[asterisk-addons-commits] qwell: trunk r583 - /trunk/channels/chan_mobile.c

SVN commits to the Asterisk addons project asterisk-addons-commits at lists.digium.com
Fri May 2 12:49:15 CDT 2008


Author: qwell
Date: Fri May  2 12:49:14 2008
New Revision: 583

URL: http://svn.digium.com/view/asterisk-addons?view=rev&rev=583
Log:
Expand ciev_call (and ciev_callsetup) buffers to allow for longer responses in +CIEV.
Also switch a bunch of (all of) sprintf calls to snprintf.

(closes issue #12568)
Reported by: Shkoder

Modified:
    trunk/channels/chan_mobile.c

Modified: trunk/channels/chan_mobile.c
URL: http://svn.digium.com/view/asterisk-addons/trunk/channels/chan_mobile.c?view=diff&rev=583&r1=582&r2=583
==============================================================================
--- trunk/channels/chan_mobile.c (original)
+++ trunk/channels/chan_mobile.c Fri May  2 12:49:14 2008
@@ -148,12 +148,12 @@
 	pthread_t monitor_thread;			/* monitor thread handle */
 	char dial_number[AST_MAX_EXTENSION];		/* number for the monitor thread to dial */
 	int dial_timeout;
-	char ciev_call_0[4];				/* dynamically built reponse strings */
-	char ciev_call_1[4];
-	char ciev_callsetup_0[4];
-	char ciev_callsetup_1[4];
-	char ciev_callsetup_2[4];
-	char ciev_callsetup_3[4];
+	char ciev_call_0[5];				/* dynamically built reponse strings */
+	char ciev_call_1[5];
+	char ciev_callsetup_0[5];
+	char ciev_callsetup_1[5];
+	char ciev_callsetup_2[5];
+	char ciev_callsetup_3[5];
 	unsigned int no_callsetup:1;
 	unsigned int has_sms:1;
 	unsigned int sent_answer:1;
@@ -427,7 +427,7 @@
 			stat = 3;
 	}
 
-	sprintf(status, "%d", stat);
+	snprintf(status, sizeof(status), "%d", stat);
 	pbx_builtin_setvar_helper(ast, args.variable, status);
 
 	return 0;
@@ -741,7 +741,7 @@
 	case '9':
 	case '*':
 	case '#':
-		sprintf(buf, "AT+VTS=%c\r", digit);
+		snprintf(buf, sizeof(buf), "AT+VTS=%c\r", digit);
 		rfcomm_write(pvt, buf);
 		break;
 	default:
@@ -1357,12 +1357,12 @@
 						if (strstr(buf+i, "\"callsetup\""))
 							callsetupp = group2;
 					}
-					sprintf(pvt->ciev_call_0, "%d,0", callp);
-					sprintf(pvt->ciev_call_1, "%d,1", callp);
-					sprintf(pvt->ciev_callsetup_0, "%d,0", callsetupp);
-					sprintf(pvt->ciev_callsetup_1, "%d,1", callsetupp);
-					sprintf(pvt->ciev_callsetup_2, "%d,2", callsetupp);
-					sprintf(pvt->ciev_callsetup_3, "%d,3", callsetupp);
+					snprintf(pvt->ciev_call_0, sizeof(pvt->ciev_call_0), "%d,0", callp);
+					snprintf(pvt->ciev_call_1, sizeof(pvt->ciev_call_1), "%d,1", callp);
+					snprintf(pvt->ciev_callsetup_0, sizeof(pvt->ciev_callsetup_0), "%d,0", callsetupp);
+					snprintf(pvt->ciev_callsetup_1, sizeof(pvt->ciev_callsetup_1), "%d,1", callsetupp);
+					snprintf(pvt->ciev_callsetup_2, sizeof(pvt->ciev_callsetup_2), "%d,2", callsetupp);
+					snprintf(pvt->ciev_callsetup_3, sizeof(pvt->ciev_callsetup_3), "%d,3", callsetupp);
 					if (callsetupp == 0) /* This phone has no call setup indication!! ... */
 						pvt->no_callsetup = 1;
 					ast_debug(1, "CIEV_CALL=%d CIEV_CALLSETUP=%d\n", callp, callsetupp);
@@ -1566,7 +1566,7 @@
 					p++;
 					smsi = atoi(p);
 					if (smsi > 0) {
-						sprintf(buf, "AT+CMGR=%d\r", smsi);
+						snprintf(buf, sizeof(buf), "AT+CMGR=%d\r", smsi);
 						rfcomm_write(pvt, buf);
 						pvt->state = MBL_STATE_INSMS;
 					}
@@ -1585,7 +1585,7 @@
 				ast_verbose(VERBOSE_PREFIX_3 "Bluetooth Device %s initialised and ready.\n", pvt->id);
 				pvt->state = MBL_STATE_IDLE;
 			} else if (pvt->state == MBL_STATE_DIAL) {
-				sprintf(buf, "ATD%s;\r", pvt->dial_number);
+				snprintf(buf, sizeof(buf), "ATD%s;\r", pvt->dial_number);
 				if (!rfcomm_write(pvt, buf)) {
 					ast_log(LOG_ERROR, "Dial failed on %s state %d\n", pvt->owner->name, pvt->state);
 					ast_queue_control(pvt->owner, AST_CONTROL_CONGESTION);
@@ -1611,7 +1611,7 @@
 				} else
 					pvt->state = MBL_STATE_IDLE;
 			} else if (pvt->state == MBL_STATE_OUTSMS) {
-				sprintf(buf, "AT+CMGS=\"%s\"\r", pvt->dial_number);
+				snprintf(buf, sizeof(buf), "AT+CMGS=\"%s\"\r", pvt->dial_number);
 				rfcomm_write(pvt, buf);
 				pvt->state = MBL_STATE_OUTSMS1;
 			} else if (pvt->state == MBL_STATE_OUTSMS1) {




More information about the asterisk-addons-commits mailing list