[svn-commits] jpeeler: branch 1.6.0 r132426 - in /branches/1.6.0: ./ channels/chan_dahdi.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Mon Jul 21 10:34:21 CDT 2008


Author: jpeeler
Date: Mon Jul 21 10:34:21 2008
New Revision: 132426

URL: http://svn.digium.com/view/asterisk?view=rev&rev=132426
Log:
Merged revisions 132425 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/trunk

........
r132425 | jpeeler | 2008-07-21 10:33:13 -0500 (Mon, 21 Jul 2008) | 2 lines

make buffers config option (chan_dahdi.conf) parsing safer and added logging in case of failure

........

Modified:
    branches/1.6.0/   (props changed)
    branches/1.6.0/channels/chan_dahdi.c

Propchange: branches/1.6.0/
------------------------------------------------------------------------------
Binary property 'trunk-merged' - no diff available.

Modified: branches/1.6.0/channels/chan_dahdi.c
URL: http://svn.digium.com/view/asterisk/branches/1.6.0/channels/chan_dahdi.c?view=diff&rev=132426&r1=132425&r2=132426
==============================================================================
--- branches/1.6.0/channels/chan_dahdi.c (original)
+++ branches/1.6.0/channels/chan_dahdi.c Mon Jul 21 10:34:21 2008
@@ -13583,7 +13583,6 @@
 static int process_dahdi(struct dahdi_chan_conf *confp, struct ast_variable *v, int reload, int skipchannels)
 {
 	struct dahdi_pvt *tmp;
-	const char *tempstr; /* temporary string for parsing the dring number, buffers policy */
 	int y;
 	int found_pseudo = 0;
         char dahdichan[MAX_CHANLIST_LEN] = {};
@@ -13605,17 +13604,24 @@
  			if (build_channels(confp, iscrv, v->value, reload, v->lineno, &found_pseudo))
  					return -1;
 		} else if (!strcasecmp(v->name, "buffers")) {
-			char policy[8];
-			tempstr = v->value;
-			sscanf(tempstr, "%d,%s", &confp->chan.buf_no, policy);
+			int res;
+			char policy[8] = "";
+			res = sscanf(v->value, "%d,%s", &confp->chan.buf_no, policy);
+			if (res != 2) {
+				ast_log(LOG_WARNING, "Parsing buffers option data failed, using defaults.\n");
+				confp->chan.buf_no = numbufs;
+				continue;
+			}
 			if (confp->chan.buf_no < 0)
 				confp->chan.buf_no = numbufs;
 			if (!strcasecmp(policy, "full")) {
 				confp->chan.buf_policy = DAHDI_POLICY_WHEN_FULL;
 			} else if (!strcasecmp(policy, "half")) {
 				confp->chan.buf_policy = DAHDI_POLICY_IMMEDIATE /*HALF_FULL*/;
+			} else if (!strcasecmp(policy, "immediate")) {
+				confp->chan.buf_policy = DAHDI_POLICY_IMMEDIATE;
 			} else {
-				confp->chan.buf_policy = DAHDI_POLICY_IMMEDIATE;
+				ast_log(LOG_WARNING, "Invalid policy name given (%s).\n", policy);
 			}
  		} else if (!strcasecmp(v->name, "dahdichan")) {
  			ast_copy_string(dahdichan, v->value, sizeof(dahdichan));
@@ -13636,14 +13642,11 @@
 		} else if (!strcasecmp(v->name, "dring3range")) {
 			confp->chan.drings.ringnum[2].range = atoi(v->value);
 		} else if (!strcasecmp(v->name, "dring1")) {
-			tempstr = v->value;
-			sscanf(tempstr, "%d,%d,%d", &confp->chan.drings.ringnum[0].ring[0], &confp->chan.drings.ringnum[0].ring[1], &confp->chan.drings.ringnum[0].ring[2]);
+			sscanf(v->value, "%d,%d,%d", &confp->chan.drings.ringnum[0].ring[0], &confp->chan.drings.ringnum[0].ring[1], &confp->chan.drings.ringnum[0].ring[2]);
 		} else if (!strcasecmp(v->name, "dring2")) {
-			tempstr = v->value;
-			sscanf(tempstr,"%d,%d,%d", &confp->chan.drings.ringnum[1].ring[0], &confp->chan.drings.ringnum[1].ring[1], &confp->chan.drings.ringnum[1].ring[2]);
+			sscanf(v->value,"%d,%d,%d", &confp->chan.drings.ringnum[1].ring[0], &confp->chan.drings.ringnum[1].ring[1], &confp->chan.drings.ringnum[1].ring[2]);
 		} else if (!strcasecmp(v->name, "dring3")) {
-			tempstr = v->value;
-			sscanf(tempstr, "%d,%d,%d", &confp->chan.drings.ringnum[2].ring[0], &confp->chan.drings.ringnum[2].ring[1], &confp->chan.drings.ringnum[2].ring[2]);
+			sscanf(v->value, "%d,%d,%d", &confp->chan.drings.ringnum[2].ring[0], &confp->chan.drings.ringnum[2].ring[1], &confp->chan.drings.ringnum[2].ring[2]);
 		} else if (!strcasecmp(v->name, "usecallerid")) {
 			confp->chan.use_callerid = ast_true(v->value);
 		} else if (!strcasecmp(v->name, "cidsignalling")) {




More information about the svn-commits mailing list