Skip to content

Commit

Permalink
dispatcher: fix several issues with empty destination sets
Browse files Browse the repository at this point in the history
Upon (re)load, a dispatching set may be empty if none of its destinations
can be resolved. This patch fixes a couple of crashes which are directly
related to empty destination sets:

    * fix a bug in reindex_dests() where a single bogus destination
      would be allocated for each empty set
    * prevent ds_select_dst() from routing to empty sets

(cherry picked from commit 127b456)
  • Loading branch information
liviuchircu committed Dec 10, 2014
1 parent 44afe25 commit a64765c
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions modules/dispatcher/dispatch.c
Expand Up @@ -291,6 +291,11 @@ int reindex_dests( ds_data_t *d_data)

for( sp=d_data->sets ; sp!= NULL ; sp->dlist=dp0, sp=sp->next )
{
if (sp->nr == 0) {
dp0 = NULL;
continue;
}

dp0 = (ds_dest_p)shm_malloc(sp->nr*sizeof(ds_dest_t));
if(dp0==NULL)
{
Expand Down Expand Up @@ -1292,6 +1297,11 @@ int ds_select_dst(struct sip_msg *msg, ds_select_ctl_p ds_select_ctl)
goto error;
}

if (idx->nr == 0) {
LM_DBG("destination set [%d] is empty!\n", idx->id);
goto error;
}

LM_DBG("set [%d]\n", ds_select_ctl->set);

ds_hash = 0;
Expand Down

0 comments on commit a64765c

Please sign in to comment.