Browse code

textops: check for HDR_ERROR_T after header name parsing

Daniel-Constantin Mierla authored on 02/06/2021 19:21:59
Showing 1 changed files
... ...
@@ -1816,7 +1816,8 @@ static int ki_remove_hf_idx(sip_msg_t* msg, str* hname, int idx)
1816 1816
 		return -1;
1817 1817
 	}
1818 1818
 
1819
-	if(parse_hname2_str(hname, &hfm)==NULL) {
1819
+	parse_hname2_str(hname, &hfm);
1820
+	if(hfm.type==HDR_ERROR_T) {
1820 1821
 		LM_ERR("failed to parse header name [%.*s]\n", hname->len, hname->s);
1821 1822
 		return -1;
1822 1823
 	}
... ...
@@ -2098,12 +2099,13 @@ static int ki_hname_gparam(str *hname, gparam_t *gp)
2098 2099
 
2099 2100
 	gp->v.str = *hname;
2100 2101
 
2101
-	if (parse_hname2_short(hbuf, hbuf + gp->v.str.len + 1, &hdr)==0) {
2102
+	parse_hname2_short(hbuf, hbuf + gp->v.str.len + 1, &hdr);
2103
+	if(hdr.type==HDR_ERROR_T) {
2102 2104
 		LM_ERR("error parsing header name: %.*s\n", hname->len, hname->s);
2103 2105
 		return -1;
2104 2106
 	}
2105 2107
 
2106
-	if (hdr.type!=HDR_OTHER_T && hdr.type!=HDR_ERROR_T) {
2108
+	if (hdr.type!=HDR_OTHER_T) {
2107 2109
 		LM_DBG("using hdr type (%d) instead of <%.*s>\n",
2108 2110
 				hdr.type, gp->v.str.len, gp->v.str.s);
2109 2111
 		gp->v.str.s = NULL;
... ...
@@ -3713,17 +3715,19 @@ static int hname_fixup(void** param, int param_no)
3713 3715
 	gp->v.str.s[gp->v.str.len] = ':';
3714 3716
 	gp->v.str.len++;
3715 3717
 
3716
-	if (parse_hname2_short(gp->v.str.s, gp->v.str.s + gp->v.str.len, &hdr)==0)
3718
+	parse_hname2_short(gp->v.str.s, gp->v.str.s + gp->v.str.len, &hdr);
3719
+
3720
+	gp->v.str.len--;
3721
+	gp->v.str.s[gp->v.str.len] = c;
3722
+
3723
+	if(hdr.type==HDR_ERROR_T)
3717 3724
 	{
3718 3725
 		LM_ERR("error parsing header name\n");
3719 3726
 		pkg_free(gp);
3720 3727
 		return E_UNSPEC;
3721 3728
 	}
3722 3729
 
3723
-	gp->v.str.len--;
3724
-	gp->v.str.s[gp->v.str.len] = c;
3725
-
3726
-	if (hdr.type!=HDR_OTHER_T && hdr.type!=HDR_ERROR_T)
3730
+	if (hdr.type!=HDR_OTHER_T)
3727 3731
 	{
3728 3732
 		LM_DBG("using hdr type (%d) instead of <%.*s>\n",
3729 3733
 				hdr.type, gp->v.str.len, gp->v.str.s);