Skip to content

Commit

Permalink
fix bin crash if no listener defined
Browse files Browse the repository at this point in the history
When using usrloc and dialog replication, if no bin_listen is defined,
OpenSIPS crashes. This fix ensures that if there are any replication
destinations defined, the binary listener exists.

Thanks go to Stas Kobzar for reporting this
Closes #652
  • Loading branch information
razvancrainea committed May 26, 2016
1 parent 9c66491 commit 8f46c2f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
5 changes: 5 additions & 0 deletions bin_interface.c
Expand Up @@ -257,6 +257,11 @@ int bin_send(union sockaddr_union *dest)
int rc, destlen;
str st;

if (!bin) {
LM_ERR("binary listener not defined - cannot replicate!\n");
return -1;
}

if (!dest)
return 0;

Expand Down
6 changes: 6 additions & 0 deletions modules/dialog/dialog.c
Expand Up @@ -889,6 +889,12 @@ static int mod_init(void)
mark_dlg_loaded_callbacks_run();
destroy_cachedb(0);

if (replication_dests && !bin) {
LM_ERR("You are using dialog replication, but there "
"is no bin_listen parameter defined!\n");
return -1;
}

return 0;
}

Expand Down
6 changes: 6 additions & 0 deletions modules/usrloc/ul_mod.c
Expand Up @@ -348,6 +348,12 @@ static int mod_init(void)
return -1;
}

if (replication_dests && !bin) {
LM_ERR("You are using contacts replication, but there "
"is no bin_listen parameter defined!\n");
return -1;
}

init_flag = 1;

return 0;
Expand Down

0 comments on commit 8f46c2f

Please sign in to comment.