[sr-dev] git:master:35d2d50c: topos: handle return code for parse_headers()

Daniel-Constantin Mierla miconda at gmail.com
Thu Jul 20 16:26:17 CEST 2017


Module: kamailio
Branch: master
Commit: 35d2d50ca5a170bb6518c45bec482a8cd7625177
URL: https://github.com/kamailio/kamailio/commit/35d2d50ca5a170bb6518c45bec482a8cd7625177

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2017-07-20T16:25:42+02:00

topos: handle return code for parse_headers()

---

Modified: src/modules/topos/topos_mod.c
Modified: src/modules/topos/tps_msg.c

---

Diff:  https://github.com/kamailio/kamailio/commit/35d2d50ca5a170bb6518c45bec482a8cd7625177.diff
Patch: https://github.com/kamailio/kamailio/commit/35d2d50ca5a170bb6518c45bec482a8cd7625177.patch

---

diff --git a/src/modules/topos/topos_mod.c b/src/modules/topos/topos_mod.c
index dfa8a7736f..0141c0f2c3 100644
--- a/src/modules/topos/topos_mod.c
+++ b/src/modules/topos/topos_mod.c
@@ -240,19 +240,21 @@ int tps_prepare_msg(sip_msg_t *msg)
 		return 1;
 	}
 
-	if (parse_headers(msg, HDR_EOH_F, 0)==-1) {
-		LM_DBG("parsing headers failed [[%.*s]]\n",
-				msg->len, msg->buf);
-		return 2;
+	if(parse_headers(msg, HDR_VIA2_F, 0)<0) {
+		LM_DBG("no via2 has been parsed\n");
 	}
 
-	parse_headers(msg, HDR_VIA2_F, 0);
-
 	if(parse_headers(msg, HDR_CSEQ_F, 0)!=0 || msg->cseq==NULL) {
 		LM_ERR("cannot parse cseq header\n");
 		return -1;
 	}
 
+	if (parse_headers(msg, HDR_EOH_F, 0)==-1) {
+		LM_DBG("parsing headers failed [[%.*s]]\n",
+				msg->len, msg->buf);
+		return 2;
+	}
+
 	if(parse_from_header(msg)<0) {
 		LM_ERR("cannot parse FROM header\n");
 		return 3;
diff --git a/src/modules/topos/tps_msg.c b/src/modules/topos/tps_msg.c
index 09eda9e1b3..37b075ae94 100644
--- a/src/modules/topos/tps_msg.c
+++ b/src/modules/topos/tps_msg.c
@@ -115,7 +115,10 @@ int tps_remove_headers(sip_msg_t *msg, uint32_t hdr)
 	struct hdr_field *hf;
 	struct lump* l;
 
-	parse_headers(msg, HDR_EOH_F, 0);
+	if(parse_headers(msg, HDR_EOH_F, 0)<0) {
+		LM_ERR("failed to parse headers\n");
+		return -1;
+	}
 	for (hf=msg->headers; hf; hf=hf->next) {
 		if (hdr!=hf->type)
 			continue;
@@ -139,7 +142,11 @@ int tps_add_headers(sip_msg_t *msg, str *hname, str *hbody, int hpos)
 	if(hname==NULL || hname->len<=0 || hbody==NULL || hbody->len<=0)
 		return 0;
 
-	parse_headers(msg, HDR_EOH_F, 0);
+	if(parse_headers(msg, HDR_EOH_F, 0)<0) {
+		LM_ERR("failed to parse headers\n");
+		return -1;
+	}
+
 	if(hpos == 0) { /* append */
 		/* after last header */
 		anchor = anchor_lump(msg, msg->unparsed - msg->buf, 0, 0);




More information about the sr-dev mailing list