[sr-dev] git:master: tm: safety checks inside t_next_contacts()

Daniel-Constantin Mierla miconda at gmail.com
Sat Dec 7 13:36:20 CET 2013


Module: sip-router
Branch: master
Commit: 21027d0c17558f3a1a4797049448cbbdfe50554f
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=21027d0c17558f3a1a4797049448cbbdfe50554f

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date:   Sat Dec  7 13:35:45 2013 +0100

tm: safety checks inside t_next_contacts()

---

 modules/tm/t_serial.c |   34 ++++++++++++++++++++++++++++------
 1 files changed, 28 insertions(+), 6 deletions(-)

diff --git a/modules/tm/t_serial.c b/modules/tm/t_serial.c
index 93c7480..62200ad 100644
--- a/modules/tm/t_serial.c
+++ b/modules/tm/t_serial.c
@@ -488,14 +488,24 @@ int t_next_contacts(struct sip_msg* msg, char* key, char* value)
 		il->next = (struct instance_list *)0;
 		set_instance(msg, &instance);
 	} else {
+		instance.s = 0;
 		instance.len = 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 = 0;
+		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 = 0;
+		location_ua.len = 0;
+	}
 
 	/* Rewrite Request-URI */
 	rewrite_uri(msg, &uri);
@@ -582,10 +592,20 @@ int t_next_contacts(struct sip_msg* msg, char* key, char* value)
 		flags = vavp->val.v.i;
 
 		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 = 0;
+			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 = 0;
+			location_ua.len = 0;
+		}
 
 		vavp = xavp_get(&instance_name, xavp->val.v.xavp);
 		if (vavp != NULL) {
@@ -623,6 +643,7 @@ int t_next_contacts(struct sip_msg* msg, char* key, char* value)
 				il = ilp;
 			}
 		} else {
+			instance.s = 0;
 			instance.len = 0;
 		}
 
@@ -632,7 +653,8 @@ int t_next_contacts(struct sip_msg* msg, char* key, char* value)
 				dst_uri.len, (dst_uri.len > 0)?dst_uri.s:"",
 				path.len, (path.len>0)?path.s:"",
 				instance.len, (instance.len>0)?instance.s:"",
-				ruid.len, ruid.s, location_ua.len, location_ua.s);
+				ruid.len, (ruid.len>0)?ruid.s:"",
+				location_ua.len, (location_ua.len>0)?location_ua.s:"");
 		if (append_branch(msg, &uri, &dst_uri, &path, 0, flags, sock, &instance, 0,
 					&ruid, &location_ua) != 1) {
 			LM_ERR("appending branch failed\n");




More information about the sr-dev mailing list