Module: kamailio
Branch: master
Commit: 6feb28266210a8210d31d7dac49cf3ea3da06164
URL:
https://github.com/kamailio/kamailio/commit/6feb28266210a8210d31d7dac49cf3e…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2018-01-16T16:00:37+01:00
tm: handle rpc tm.t_uac_start only with From and To headers
- reported by GH #1393
---
Modified: src/modules/tm/rpc_uac.c
---
Diff:
https://github.com/kamailio/kamailio/commit/6feb28266210a8210d31d7dac49cf3e…
Patch:
https://github.com/kamailio/kamailio/commit/6feb28266210a8210d31d7dac49cf3e…
---
diff --git a/src/modules/tm/rpc_uac.c b/src/modules/tm/rpc_uac.c
index 2247c043d9..ec81f69450 100644
--- a/src/modules/tm/rpc_uac.c
+++ b/src/modules/tm/rpc_uac.c
@@ -133,8 +133,8 @@ static int rpc_uac_check_msg(rpc_t *rpc, void* c,
* @return pkg_malloc'ed header block on success (with *l set to its length),
* 0 on error.
*/
-static char *get_hfblock(str *uri, struct hdr_field *hf, int proto,
- struct socket_info* ssock, int* l)
+static int get_hfblock(str *uri, struct hdr_field *hf, int proto,
+ struct socket_info* ssock, str* hout)
{
struct str_list sl, *last, *i, *foo;
int p, frag_len, total_len;
@@ -142,6 +142,8 @@ static char *get_hfblock(str *uri, struct hdr_field *hf, int proto,
str *sock_name, *portname;
struct dest_info di;
+ hout->s = NULL;
+ hout->len = 0;
ret = 0; /* pessimist: assume failure */
total_len = 0;
last = &sl;
@@ -209,7 +211,7 @@ static char *get_hfblock(str *uri, struct hdr_field *hf, int proto,
if(total_len==0) {
LM_DBG("empty result for headers block\n");
- goto error;
+ return 1;;
}
/* construct a single header block now */
@@ -227,8 +229,9 @@ static char *get_hfblock(str *uri, struct hdr_field *hf, int proto,
dst += foo->s.len;
pkg_free(foo);
}
- *l = total_len;
- return ret;
+ hout->len = total_len;
+ hout->s = ret;
+ return 0;
error:
i = sl.next;
@@ -237,8 +240,7 @@ static char *get_hfblock(str *uri, struct hdr_field *hf, int proto,
i = i->next;
pkg_free(foo);
}
- *l = 0;
- return 0;
+ return -1;
}
@@ -500,10 +502,9 @@ static void rpc_t_uac(rpc_t* rpc, void* c, int reply_wait)
if (rpc_uac_check_msg(rpc, c, &faked_msg, &method, &body, &fromtag,
&cseq_is, &cseq, &callid)<0)
goto error;
- hfb.s=get_hfblock(nexthop.len? &nexthop: &ruri, faked_msg.headers,
- PROTO_NONE, ssock, &hfb.len);
- if (hfb.s==0){
- rpc->fault(c, 500, "out of memory");
+ if(get_hfblock(nexthop.len? &nexthop: &ruri, faked_msg.headers,
+ PROTO_NONE, ssock, &hfb)<0) {
+ rpc->fault(c, 500, "Failed to build headers block");
goto error;
}
/* proceed to transaction creation */
@@ -534,7 +535,7 @@ static void rpc_t_uac(rpc_t* rpc, void* c, int reply_wait)
memset(&uac_req, 0, sizeof(uac_req));
uac_req.method=&method;
- uac_req.headers=&hfb;
+ if(hfb.s!=NULL && hfb.len>0) uac_req.headers=&hfb;
uac_req.body=body.len?&body:0;
uac_req.dialog=&dlg;
if (reply_wait){
@@ -732,10 +733,9 @@ int t_uac_send(str *method, str *ruri, str *nexthop, str
*send_socket,
LM_ERR("checking values failed\n");
goto error;
}
- hfb.s=get_hfblock(nexthop->len? nexthop: ruri, faked_msg.headers,
- PROTO_NONE, ssock, &hfb.len);
- if (hfb.s==0){
- LM_ERR("out of memory");
+ if(get_hfblock(nexthop->len? nexthop: ruri, faked_msg.headers,
+ PROTO_NONE, ssock, &hfb)<0) {
+ LM_ERR("failed to get the block of headers");
goto error;
}
/* proceed to transaction creation */
@@ -766,7 +766,7 @@ int t_uac_send(str *method, str *ruri, str *nexthop, str
*send_socket,
memset(&uac_req, 0, sizeof(uac_req));
uac_req.method=method;
- uac_req.headers=&hfb;
+ if(hfb.s!=NULL && hfb.len>0) uac_req.headers=&hfb;
uac_req.body=body->len?body:0;
uac_req.dialog=&dlg;