Przeglądaj źródła

tm: t_serial - safety checks for xavp search result

(cherry picked from commit 67d5aac30d7e44f0d19e41df88fce39f67192483)
(cherry picked from commit e2aa0e44b3e8d283b6be87c8858e384b40fe63db)
Daniel-Constantin Mierla 7 lat temu
rodzic
commit
b8ab414948
1 zmienionych plików z 30 dodań i 12 usunięć
  1. 30 12
      src/modules/tm/t_serial.c

+ 30 - 12
src/modules/tm/t_serial.c

@@ -635,7 +635,11 @@ int t_next_contacts(struct sip_msg* msg, char* key, char* value)
 		}
 
 		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) {
@@ -762,8 +766,7 @@ int t_next_contact_flow(struct sip_msg* msg, char* key, char* value)
 	/* 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;
 	}
@@ -780,13 +783,10 @@ int t_next_contact_flow(struct sip_msg* msg, char* key, char* value)
 		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))
@@ -795,7 +795,11 @@ int t_next_contact_flow(struct sip_msg* msg, char* key, char* value)
 		}
 
 		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) {
@@ -830,13 +834,27 @@ int t_next_contact_flow(struct sip_msg* msg, char* key, char* value)
 		}
 
 		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",