Selaa lähdekoodia

topos: set uuid fields before checking contact/rr fields

Daniel-Constantin Mierla 7 vuotta sitten
vanhempi
commit
97532ca18f
1 muutettua tiedostoa jossa 13 lisäystä ja 11 poistoa
  1. 13 11
      src/modules/topos/tps_storage.c

+ 13 - 11
src/modules/topos/tps_storage.c

@@ -214,19 +214,10 @@ int tps_storage_fill_contact(sip_msg_t *msg, tps_data_t *td, str *uuid, int dir)
 	} else {
 		sv = td->as_contact;
 	}
-	if(sv.len<=0) {
-		/* no contact - skip */
-		return 0;
-	}
-
 	if(td->cp + 8 + (2*uuid->len) + sv.len >= td->cbuf + TPS_DATA_SIZE) {
 		LM_ERR("insufficient data buffer\n");
 		return -1;
 	}
-	if (parse_uri(sv.s, sv.len, &puri) < 0) {
-		LM_ERR("failed to parse the uri\n");
-		return -1;
-	}
 	if(dir==TPS_DIR_DOWNSTREAM) {
 		td->b_uuid.s = td->cp;
 		*td->cp = 'b';
@@ -234,8 +225,6 @@ int tps_storage_fill_contact(sip_msg_t *msg, tps_data_t *td, str *uuid, int dir)
 		memcpy(td->cp, uuid->s, uuid->len);
 		td->cp += uuid->len;
 		td->b_uuid.len = td->cp - td->b_uuid.s;
-
-		td->bs_contact.s = td->cp;
 	} else {
 		td->a_uuid.s = td->cp;
 		*td->cp = 'a';
@@ -243,7 +232,20 @@ int tps_storage_fill_contact(sip_msg_t *msg, tps_data_t *td, str *uuid, int dir)
 		memcpy(td->cp, uuid->s, uuid->len);
 		td->cp += uuid->len;
 		td->a_uuid.len = td->cp - td->a_uuid.s;
+	}
 
+	if(sv.len<=0) {
+		/* no contact - skip */
+		return 0;
+	}
+
+	if (parse_uri(sv.s, sv.len, &puri) < 0) {
+		LM_ERR("failed to parse the uri\n");
+		return -1;
+	}
+	if(dir==TPS_DIR_DOWNSTREAM) {
+		td->bs_contact.s = td->cp;
+	} else {
 		td->as_contact.s = td->cp;
 	}
 	*td->cp = '<';