[asterisk-commits] rmudgett: branch 1.4 r203036 - /branches/1.4/channels/chan_dahdi.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Jun 24 16:01:48 CDT 2009


Author: rmudgett
Date: Wed Jun 24 16:01:43 2009
New Revision: 203036

URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=203036
Log:
Improved chan_dahdi.conf pritimer error checking.

Valid format is: pritimer=timer_name,timer_value

*  Fixed segfault if the ',' is missing.
*  Completely check the range returned by pri_timer2idx() to prevent
possible access outside array bounds.

Modified:
    branches/1.4/channels/chan_dahdi.c

Modified: branches/1.4/channels/chan_dahdi.c
URL: http://svn.asterisk.org/svn-view/asterisk/branches/1.4/channels/chan_dahdi.c?view=diff&rev=203036&r1=203035&r2=203036
==============================================================================
--- branches/1.4/channels/chan_dahdi.c (original)
+++ branches/1.4/channels/chan_dahdi.c Wed Jun 24 16:01:43 2009
@@ -11823,26 +11823,37 @@
 #endif
 			} else if (!strcasecmp(v->name, "pritimer")) {
 #ifdef PRI_GETSET_TIMERS
-				char *timerc, *c;
-				int timer, timeridx;
-				c = v->value;
+				char tmp[20];
+				char *timerc;
+				char *c;
+				int timer;
+				int timeridx;
+
+				ast_copy_string(tmp, v->value, sizeof(tmp));
+				c = tmp;
 				timerc = strsep(&c, ",");
-				if (timerc) {
+				if (!ast_strlen_zero(timerc) && !ast_strlen_zero(c)) {
+					timeridx = pri_timer2idx(timerc);
 					timer = atoi(c);
-					if (!timer)
-						ast_log(LOG_WARNING, "'%s' is not a valid value for an ISDN timer\n", timerc);
-					else {
-						if ((timeridx = pri_timer2idx(timerc)) >= 0)
-							pritimers[timeridx] = timer;
-						else
-							ast_log(LOG_WARNING, "'%s' is not a valid ISDN timer\n", timerc);
+					if (timeridx < 0 || PRI_MAX_TIMERS <= timeridx) {
+						ast_log(LOG_WARNING,
+							"'%s' is not a valid ISDN timer at line %d.\n", timerc,
+							v->lineno);
+					} else if (!timer) {
+						ast_log(LOG_WARNING,
+							"'%s' is not a valid value for ISDN timer '%s' at line %d.\n",
+							c, timerc, v->lineno);
+					} else {
+						pritimers[timeridx] = timer;
 					}
-				} else
-					ast_log(LOG_WARNING, "'%s' is not a valid ISDN timer configuration string\n", v->value);
-
+				} else {
+					ast_log(LOG_WARNING,
+						"'%s' is not a valid ISDN timer configuration string at line %d.\n",
+						v->value, v->lineno);
+				}
+#endif /* PRI_GETSET_TIMERS */
 			} else if (!strcasecmp(v->name, "facilityenable")) {
 				confp->pri.facilityenable = ast_true(v->value);
-#endif /* PRI_GETSET_TIMERS */
 #endif /* HAVE_PRI */
 			} else if (!strcasecmp(v->name, "cadence")) {
 				/* setup to scan our argument */




More information about the asterisk-commits mailing list