Module: kamailio Branch: 5.1 Commit: e2aa0e44b3e8d283b6be87c8858e384b40fe63db URL: https://github.com/kamailio/kamailio/commit/e2aa0e44b3e8d283b6be87c8858e384b...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: 2018-06-21T08:30:37+02:00
tm: t_serial - safety checks for xavp search result
(cherry picked from commit 67d5aac30d7e44f0d19e41df88fce39f67192483)
---
Modified: src/modules/tm/t_serial.c
---
Diff: https://github.com/kamailio/kamailio/commit/e2aa0e44b3e8d283b6be87c8858e384b... Patch: https://github.com/kamailio/kamailio/commit/e2aa0e44b3e8d283b6be87c8858e384b...
---
diff --git a/src/modules/tm/t_serial.c b/src/modules/tm/t_serial.c index 019b35dbb4..8f8ee0646d 100644 --- a/src/modules/tm/t_serial.c +++ b/src/modules/tm/t_serial.c @@ -642,7 +642,11 @@ int ki_t_next_contacts(struct sip_msg* msg) }
vavp = xavp_get(&flags_name, xavp->val.v.xavp); - flags = vavp->val.v.i; + if (vavp != NULL) { + flags = vavp->val.v.i; + } else { + flags = 0; + }
vavp = xavp_get(&ruid_name, xavp->val.v.xavp); if (vavp != NULL) { @@ -774,8 +778,7 @@ int ki_t_next_contact_flow(struct sip_msg* msg) /* Load Request-URI and branches */ t_get_this_branch_instance(msg, &this_instance);
- if (this_instance.len == 0) - { + if (this_instance.len == 0) { LM_DBG("No instance on this branch\n"); return -2; } @@ -792,13 +795,10 @@ int ki_t_next_contact_flow(struct sip_msg* msg) next_xavp = xavp_get_next(xavp);
vavp = xavp_get(&instance_name, xavp->val.v.xavp); - if (vavp == NULL) - { + if (vavp == NULL) { /* Does not match this instance */ goto next_xavp; - } - else - { + } else { instance = vavp->val.v.s; if ((instance.len != this_instance.len) || (strncmp(instance.s, this_instance.s, instance.len) != 0)) @@ -807,7 +807,11 @@ int ki_t_next_contact_flow(struct sip_msg* msg) }
vavp = xavp_get(&uri_name, xavp->val.v.xavp); - uri = vavp->val.v.s; + if (vavp == NULL) { + goto next_xavp; + } else { + uri = vavp->val.v.s; + }
vavp = xavp_get(&dst_uri_name, xavp->val.v.xavp); if (vavp != NULL) { @@ -842,13 +846,27 @@ int ki_t_next_contact_flow(struct sip_msg* msg) }
vavp = xavp_get(&flags_name, xavp->val.v.xavp); - flags = vavp->val.v.i; + if (vavp != NULL) { + flags = vavp->val.v.i; + } else { + flags = 0; + }
vavp = xavp_get(&ruid_name, xavp->val.v.xavp); - ruid = vavp->val.v.s; + if (vavp != NULL) { + ruid = vavp->val.v.s; + } else { + ruid.s = ""; + ruid.len = 0; + }
vavp = xavp_get(&ua_name, xavp->val.v.xavp); - location_ua = vavp->val.v.s; + if (vavp != NULL) { + location_ua = vavp->val.v.s; + } else { + location_ua.s = ""; + location_ua.len = 0; + }
LM_DBG("Appending branch uri-'%.*s' dst-'%.*s' path-'%.*s'" " inst-'%.*s' ruid-'%.*s' location_ua-'%.*s'\n",