]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
fix bounds check issue
authorMichael Jerris <mike@jerris.com>
Wed, 21 May 2008 16:48:19 +0000 (16:48 +0000)
committerMichael Jerris <mike@jerris.com>
Wed, 21 May 2008 16:48:19 +0000 (16:48 +0000)
git-svn-id: http://svn.openzap.org/svn/openzap/trunk@480 a93c3328-9c30-0410-af19-c9cd2b2d52af

libs/openzap/src/zap_io.c
libs/openzap/src/zap_isdn.c

index 5bce48dc56c655c82a44ac5c53233cf1557df142..5bdb83f3df3f1905d8379697db640e0442721731 100644 (file)
@@ -718,6 +718,12 @@ zap_status_t zap_channel_open_any(uint32_t span_id, zap_direction_t direction, z
        uint32_t span_max;
 
        if (span_id) {
+               if (span_id >= ZAP_MAX_SPANS_INTERFACE) {
+                       zap_log(ZAP_LOG_CRIT, "SPAN NOT DEFINED!\n");
+                       *zchan = NULL;
+            return ZAP_FAIL;
+               }
+
                if (globals.spans[span_id].active_count >= globals.spans[span_id].chan_count) {
                        zap_log(ZAP_LOG_CRIT, "All circuits are busy.\n");
                        *zchan = NULL;
@@ -907,14 +913,14 @@ zap_status_t zap_channel_open(uint32_t span_id, uint32_t chan_id, zap_channel_t
 
        zap_mutex_lock(globals.mutex);
 
-       if (span_id && globals.spans[span_id].channel_request) {
-               zap_log(ZAP_LOG_ERROR, "Individual channel selection not implemented on this span.\n");
-               goto done;
-       }
-
        if (span_id < ZAP_MAX_SPANS_INTERFACE && chan_id < ZAP_MAX_CHANNELS_SPAN) {
                zap_channel_t *check;
 
+               if (globals.spans[span_id].channel_request) {
+                       zap_log(ZAP_LOG_ERROR, "Individual channel selection not implemented on this span.\n");
+                       goto done;
+               }
+               
                check = &globals.spans[span_id].channels[chan_id];
 
                if (zap_test_flag(check, ZAP_CHANNEL_SUSPENDED) || 
index 28093cae5d413ee5554f980d7323f14edee6e34e..80a3c8475e6608451e9cb7c1085b23c698584ef6 100644 (file)
@@ -813,6 +813,7 @@ static void *zap_isdn_run(zap_thread_t *me, void *obj)
                                zap_log(ZAP_LOG_ERROR, "D-Chan Read Error!\n");
                                snprintf(span->last_error, sizeof(span->last_error), "D-Chan Read Error!");
                                if (++errs == 10) {
+                                       isdn_data->dchan->state = ZAP_CHANNEL_STATE_UP;
                                        goto done;
                                }
                        }
@@ -913,6 +914,7 @@ zap_status_t zap_isdn_configure_span(zap_span_t *span, Q921NetUser_t mode, Q931D
                        } else {
                                if (zap_channel_open(span->span_id, i, &dchans[x]) == ZAP_SUCCESS) {
                                        zap_log(ZAP_LOG_DEBUG, "opening d-channel #%d %d:%d\n", x, dchans[x]->span_id, dchans[x]->chan_id);
+                                       dchans[x]->state = ZAP_CHANNEL_STATE_UP;
                                        x++;
                                }
                        }