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)

Conflicts:
	modules/dispatcher/dispatch.c
  • Loading branch information
liviuchircu committed Dec 10, 2014
1 parent b2cd59c commit 0ef55ed
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions modules/dispatcher/dispatch.c
Expand Up @@ -241,6 +241,11 @@ int reindex_dests(int list_idx, int setn)

for( sp=ds_lists[list_idx] ; 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 @@ -1173,6 +1178,11 @@ int ds_select_dst(struct sip_msg *msg, int set, int alg, int mode, int max_resul
LM_ERR("destination set [%d] not found\n", set);
return -1;
}

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

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

Expand Down

0 comments on commit 0ef55ed

Please sign in to comment.