[asterisk-addons-commits] russell: trunk r442 - in /trunk: asterisk-ooh323c/config.h chan_mobile.c

SVN commits to the Asterisk addons project asterisk-addons-commits at lists.digium.com
Fri Sep 7 21:07:45 CDT 2007


Author: russell
Date: Fri Sep  7 21:07:45 2007
New Revision: 442

URL: http://svn.digium.com/view/asterisk-addons?view=rev&rev=442
Log:
* Use sizeof() to specify the buffer size instead of a constant
* Remove a couple calls to memset before strncpy, as it is not needed
* Replace a couple uses of strncpy with ast_copy_string.  Note that one of
  these was potentially dangerous.  The length limit passed was actually the
  length of the *source* string, which had a larger buffer than the destination.

Modified:
    trunk/asterisk-ooh323c/config.h
    trunk/chan_mobile.c

Modified: trunk/asterisk-ooh323c/config.h
URL: http://svn.digium.com/view/asterisk-addons/trunk/asterisk-ooh323c/config.h?view=diff&rev=442&r1=441&r2=442
==============================================================================
--- trunk/asterisk-ooh323c/config.h (original)
+++ trunk/asterisk-ooh323c/config.h Fri Sep  7 21:07:45 2007
@@ -1,4 +1,4 @@
-/* config.h.  Generated by configure.  */
+/* config.h.  Generated from config.h.in by configure.  */
 /* config.h.in.  Generated from configure.in by autoheader.  */
 
 /* Define to 1 if you have the <arpa/inet.h> header file. */

Modified: trunk/chan_mobile.c
URL: http://svn.digium.com/view/asterisk-addons/trunk/chan_mobile.c?view=diff&rev=442&r1=441&r2=442
==============================================================================
--- trunk/chan_mobile.c (original)
+++ trunk/chan_mobile.c Fri Sep  7 21:07:45 2007
@@ -154,7 +154,7 @@
 	char ciev_callsetup_3[4];
 	char no_callsetup;
 	char has_sms;
-	char sms_txt[161];
+	char sms_txt[160];
 	struct ast_dsp *dsp;
 	struct ast_frame *dsp_fr;
 	int dtmf_skip;
@@ -452,8 +452,7 @@
 	}
 	
 	strcpy(pvt->dial_number, dest);
-	memset(pvt->sms_txt, 0x0, sizeof(pvt->sms_txt));
-	strncpy(pvt->sms_txt, message, 160);
+	ast_copy_string(pvt->sms_txt, message, sizeof(pvt->sms_txt));
 	pvt->state = MBL_STATE_OUTSMS;
 
 	return 0;
@@ -1176,7 +1175,7 @@
 	int callp = 0, callsetupp;
 	char brsf, nsmode, *p, *p1;
 	char sms_src[13];
-	char sms_txt[161];
+	char sms_txt[160];
 
 	brsf = nsmode = 0;
 
@@ -1412,8 +1411,7 @@
 						ast_log(LOG_ERROR, "Unable to start pbx on incoming sms.\n");
 					pvt->state = MBL_STATE_IDLE;
 				} else {
-					memset(sms_txt, 0x00, sizeof(sms_txt));
-					strncpy(sms_txt, buf, strlen(buf));
+					ast_copy_string(sms_txt, buf, sizeof(sms_txt));
 				}
 				break;
 			case MBL_STATE_OUTSMS:
@@ -1480,7 +1478,7 @@
 				pvt->state = MBL_STATE_OUTSMS1;
 			} else if (pvt->state == MBL_STATE_OUTSMS1) {
 				if (pvt->rfcomm_buf[0] == '>') {
-					sprintf(buf, "%s%c", pvt->sms_txt, 0x1a);
+					snprintf(buf, sizeof(buf), "%s%c", pvt->sms_txt, 0x1a);
 					rfcomm_write(pvt, buf);
 					pvt->state = MBL_STATE_OUTSMS2;
 				} else {




More information about the asterisk-addons-commits mailing list