[asterisk-commits] russell: branch 1.2 r39081 -
/branches/1.2/channels/chan_zap.c
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Sun Aug 6 18:28:30 MST 2006
Author: russell
Date: Sun Aug 6 20:28:29 2006
New Revision: 39081
URL: http://svn.digium.com/view/asterisk?rev=39081&view=rev
Log:
Fix a crash reported to me by hads on IRC. This crash would occur with the use
of the "distinctiveringaftercid" option. Also, on this user's system, the crash
would only occur when built without optimizations. This is because the bug is
that the code would write past the end of an array that was allocated on the
stack, and the structure of the stack is different with or without optimizations
enabled.
Modified:
branches/1.2/channels/chan_zap.c
Modified: branches/1.2/channels/chan_zap.c
URL: http://svn.digium.com/view/asterisk/branches/1.2/channels/chan_zap.c?rev=39081&r1=39080&r2=39081&view=diff
==============================================================================
--- branches/1.2/channels/chan_zap.c (original)
+++ branches/1.2/channels/chan_zap.c Sun Aug 6 20:28:29 2006
@@ -759,8 +759,6 @@
{ { 125, 125, 125, 125, 125, 4000 } }, /*!< Three short bursts */
{ { 1000, 500, 2500, 5000 } }, /*!< Long ring */
};
-
-int receivedRingT; /*!< Used to find out what ringtone we are on */
/*! \brief cidrings says in which pause to transmit the cid information, where the first pause
* is 1, the second pause is 2 and so on.
@@ -5946,9 +5944,8 @@
len = 0;
distMatches = 0;
/* Clear the current ring data array so we dont have old data in it. */
- for (receivedRingT=0; receivedRingT < 3; receivedRingT++) {
+ for (receivedRingT=0; receivedRingT < (sizeof(curRingData) / sizeof(curRingData[0])); receivedRingT++)
curRingData[receivedRingT] = 0;
- }
receivedRingT = 0;
counter = 0;
counter1 = 0;
@@ -5976,8 +5973,10 @@
if (p->ringt < p->ringt_base/2)
break;
- ++receivedRingT; /* Increment the ringT counter so we can match it against
- values in zapata.conf for distinctive ring */
+ /* Increment the ringT counter so we can match it against
+ values in zapata.conf for distinctive ring */
+ if (++receivedRingT == (sizeof(curRingData) / sizeof(curRingData[0])))
+ break;
} else if (i & ZT_IOMUX_READ) {
res = read(p->subs[index].zfd, buf, sizeof(buf));
if (res < 0) {
@@ -6048,9 +6047,8 @@
len = 0;
distMatches = 0;
/* Clear the current ring data array so we dont have old data in it. */
- for (receivedRingT=0; receivedRingT < 3; receivedRingT++) {
+ for (receivedRingT=0; receivedRingT < (sizeof(curRingData) / sizeof(curRingData[0])); receivedRingT++)
curRingData[receivedRingT] = 0;
- }
receivedRingT = 0;
counter = 0;
counter1 = 0;
@@ -6080,8 +6078,10 @@
if (p->ringt < p->ringt_base/2)
break;
- ++receivedRingT; /* Increment the ringT counter so we can match it against
- values in zapata.conf for distinctive ring */
+ /* Increment the ringT counter so we can match it against
+ values in zapata.conf for distinctive ring */
+ if (++receivedRingT == (sizeof(curRingData) / sizeof(curRingData[0])))
+ break;
} else if (i & ZT_IOMUX_READ) {
res = read(p->subs[index].zfd, buf, sizeof(buf));
if (res < 0) {
More information about the asterisk-commits
mailing list