Don't allow more than 10 seconds of audio for callerid (bug #2920)
authorMark Spencer <markster@digium.com>
Mon, 22 Nov 2004 18:59:19 +0000 (18:59 +0000)
committerMark Spencer <markster@digium.com>
Mon, 22 Nov 2004 18:59:19 +0000 (18:59 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@4315 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_zap.c

index 3486d5a..6227dd0 100755 (executable)
@@ -4700,6 +4700,7 @@ static void *ss_thread(void *data)
        int receivedRingT;
        int counter1;
        int counter;
+       int samples = 0;
 
        int flags;
        int i;
@@ -5296,6 +5297,7 @@ static void *ss_thread(void *data)
                        } else if (p->cid_signalling == CID_SIG_V23) {
                                cs = callerid_new(cid_signalling);
                                if (cs) {
+                                       samples = 0;
 #if 1
                                        bump_gains(p);
 #endif                         
@@ -5327,12 +5329,15 @@ static void *ss_thread(void *data)
                                                                }
                                                                break;
                                                        }
+                                                       samples += res;
                                                        res = callerid_feed(cs, buf, res, AST_LAW(p));
                                                        if (res < 0) {
                                                                ast_log(LOG_WARNING, "CallerID feed failed: %s\n", strerror(errno));
                                                                break;
                                                        } else if (res)
                                                                break;
+                                                       else if (samples > (8000 * 10))
+                                                               break;
                                                }
                                        }
                                        if (res == 1) {
@@ -5466,6 +5471,7 @@ static void *ss_thread(void *data)
 #if 1
                                bump_gains(p);
 #endif                         
+                               samples = 0;
                                len = 0;
                                distMatches = 0;
                                /* Clear the current ring data array so we dont have old data in it. */
@@ -5520,12 +5526,15 @@ static void *ss_thread(void *data)
                                                        res = -1;
                                                        break;
                                                }
+                                               samples += res;
                                                res = callerid_feed(cs, buf, res, AST_LAW(p));
                                                if (res < 0) {
                                                        ast_log(LOG_WARNING, "CallerID feed failed: %s\n", strerror(errno));
                                                        break;
                                                } else if (res)
                                                        break;
+                                               else if (samples > (8000 * 10))
+                                                       break;
                                        }
                                }
                                if (p->usedistinctiveringdetection == 1) {