Module: kamailio
Branch: master
Commit: 4220c41f9a443d275cf94e1db3a33fbd3ca14d1b
URL:
https://github.com/kamailio/kamailio/commit/4220c41f9a443d275cf94e1db3a33fb…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2017-07-07T13:33:16+02:00
dispatcher: try to add sip: scheme to dst uri, if initial parse fails
- operation done when records are loaded from database or file
---
Modified: src/modules/dispatcher/dispatch.c
---
Diff:
https://github.com/kamailio/kamailio/commit/4220c41f9a443d275cf94e1db3a33fb…
Patch:
https://github.com/kamailio/kamailio/commit/4220c41f9a443d275cf94e1db3a33fb…
---
diff --git a/src/modules/dispatcher/dispatch.c b/src/modules/dispatcher/dispatch.c
index bea737f4bc..67f706388c 100644
--- a/src/modules/dispatcher/dispatch.c
+++ b/src/modules/dispatcher/dispatch.c
@@ -282,20 +282,43 @@ int ds_set_attrs(ds_dest_t *dest, str *attrs)
/**
*
*/
-ds_dest_t *pack_dest(str uri, int flags, int priority, str *attrs)
+ds_dest_t *pack_dest(str iuri, int flags, int priority, str *attrs)
{
ds_dest_t *dp = NULL;
/* For DNS-Lookups */
static char hn[256];
+ char ub[512];
struct hostent *he;
struct sip_uri puri;
str host;
int port, proto;
char c = 0;
+ str uri;
+ uri = iuri;
/* check uri */
- if(parse_uri(uri.s, uri.len, &puri) != 0 || puri.host.len > 254) {
- LM_ERR("bad uri [%.*s]\n", uri.len, uri.s);
+ if(parse_uri(uri.s, uri.len, &puri) != 0) {
+ if(iuri.len>4 && strncmp(iuri.s, "sip:", 4)!=0 &&
iuri.len<500) {
+ strncpy(ub, "sip:", 4);
+ strncpy(ub+4, iuri.s, iuri.len);
+ ub[iuri.len+4] = '\0';
+ uri.s = ub;
+ uri.len = iuri.len+4;
+ if(parse_uri(uri.s, uri.len, &puri) != 0) {
+ LM_ERR("bad uri [%.*s]\n", iuri.len, iuri.s);
+ goto err;
+ } else {
+ LM_INFO("uri without sip scheme - fixing it: %.*s\n",
+ iuri.len, iuri.s);
+ }
+ } else {
+ LM_ERR("bad uri [%.*s]\n", iuri.len, iuri.s);
+ goto err;
+ }
+ }
+
+ if(puri.host.len > 254) {
+ LM_ERR("hostname in uri is too long [%.*s]\n", uri.len, uri.s);
goto err;
}