[sr-dev] git:master:cb2705f2: textops: check for HDR_ERROR_T after header name parsing

Daniel-Constantin Mierla miconda at gmail.com
Wed Jun 2 21:23:38 CEST 2021


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

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2021-06-02T21:21:59+02:00

textops: check for HDR_ERROR_T after header name parsing

---

Modified: src/modules/textops/textops.c

---

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

---

diff --git a/src/modules/textops/textops.c b/src/modules/textops/textops.c
index 40ea02c273..e93bc82bf2 100644
--- a/src/modules/textops/textops.c
+++ b/src/modules/textops/textops.c
@@ -1816,7 +1816,8 @@ static int ki_remove_hf_idx(sip_msg_t* msg, str* hname, int idx)
 		return -1;
 	}
 
-	if(parse_hname2_str(hname, &hfm)==NULL) {
+	parse_hname2_str(hname, &hfm);
+	if(hfm.type==HDR_ERROR_T) {
 		LM_ERR("failed to parse header name [%.*s]\n", hname->len, hname->s);
 		return -1;
 	}
@@ -2098,12 +2099,13 @@ static int ki_hname_gparam(str *hname, gparam_t *gp)
 
 	gp->v.str = *hname;
 
-	if (parse_hname2_short(hbuf, hbuf + gp->v.str.len + 1, &hdr)==0) {
+	parse_hname2_short(hbuf, hbuf + gp->v.str.len + 1, &hdr);
+	if(hdr.type==HDR_ERROR_T) {
 		LM_ERR("error parsing header name: %.*s\n", hname->len, hname->s);
 		return -1;
 	}
 
-	if (hdr.type!=HDR_OTHER_T && hdr.type!=HDR_ERROR_T) {
+	if (hdr.type!=HDR_OTHER_T) {
 		LM_DBG("using hdr type (%d) instead of <%.*s>\n",
 				hdr.type, gp->v.str.len, gp->v.str.s);
 		gp->v.str.s = NULL;
@@ -3713,17 +3715,19 @@ static int hname_fixup(void** param, int param_no)
 	gp->v.str.s[gp->v.str.len] = ':';
 	gp->v.str.len++;
 
-	if (parse_hname2_short(gp->v.str.s, gp->v.str.s + gp->v.str.len, &hdr)==0)
+	parse_hname2_short(gp->v.str.s, gp->v.str.s + gp->v.str.len, &hdr);
+
+	gp->v.str.len--;
+	gp->v.str.s[gp->v.str.len] = c;
+
+	if(hdr.type==HDR_ERROR_T)
 	{
 		LM_ERR("error parsing header name\n");
 		pkg_free(gp);
 		return E_UNSPEC;
 	}
 
-	gp->v.str.len--;
-	gp->v.str.s[gp->v.str.len] = c;
-
-	if (hdr.type!=HDR_OTHER_T && hdr.type!=HDR_ERROR_T)
+	if (hdr.type!=HDR_OTHER_T)
 	{
 		LM_DBG("using hdr type (%d) instead of <%.*s>\n",
 				hdr.type, gp->v.str.len, gp->v.str.s);




More information about the sr-dev mailing list