Browse code

textops: handle return code for parse_headers()

(cherry picked from commit a4da385baf396a3ef123f3a19ec314126d6f4822)

Daniel-Constantin Mierla authored on 07/11/2016 16:22:27
Showing 1 changed files
... ...
@@ -13,8 +13,8 @@
13 13
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 14
  * GNU General Public License for more details.
15 15
  *
16
- * You should have received a copy of the GNU General Public License 
17
- * along with this program; if not, write to the Free Software 
16
+ * You should have received a copy of the GNU General Public License
17
+ * along with this program; if not, write to the Free Software
18 18
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
19 19
  *
20 20
  *
... ...
@@ -1012,10 +1012,13 @@ int remove_hf_f(struct sip_msg* msg, char* str_hf, char* foo)
1012 1012
 	cnt=0;
1013 1013
 
1014 1014
 	/* we need to be sure we have seen all HFs */
1015
-	parse_headers(msg, HDR_EOH_F, 0);
1015
+	if(parse_headers(msg, HDR_EOH_F, 0)<0) {
1016
+		LM_ERR("error while parsing message headers\n");
1017
+		return -1;
1018
+	}
1016 1019
 	for (hf=msg->headers; hf; hf=hf->next) {
1017
-		/* for well known header names str_hf->s will be set to NULL 
1018
-		   during parsing of kamailio.cfg and str_hf->len contains 
1020
+		/* for well known header names str_hf->s will be set to NULL
1021
+		   during parsing of kamailio.cfg and str_hf->len contains
1019 1022
 		   the header type */
1020 1023
 		if(gp->type==GPARAM_TYPE_INT)
1021 1024
 		{
... ...
@@ -1050,7 +1053,10 @@ static int remove_hf_re_f(struct sip_msg* msg, char* key, char* foo)
1050 1053
 	cnt=0;
1051 1054
 
1052 1055
 	/* we need to be sure we have seen all HFs */
1053
-	parse_headers(msg, HDR_EOH_F, 0);
1056
+	if(parse_headers(msg, HDR_EOH_F, 0)<0) {
1057
+		LM_ERR("error while parsing message headers\n");
1058
+		return -1;
1059
+	}
1054 1060
 	for (hf=msg->headers; hf; hf=hf->next)
1055 1061
 	{
1056 1062
 		c = hf->name.s[hf->name.len];
... ...
@@ -1081,7 +1087,10 @@ static int is_present_hf_f(struct sip_msg* msg, char* str_hf, char* foo)
1081 1087
 	gp = (gparam_p)str_hf;
1082 1088
 
1083 1089
 	/* we need to be sure we have seen all HFs */
1084
-	parse_headers(msg, HDR_EOH_F, 0);
1090
+	if(parse_headers(msg, HDR_EOH_F, 0)<0) {
1091
+		LM_ERR("error while parsing message headers\n");
1092
+		return -1;
1093
+	}
1085 1094
 	for (hf=msg->headers; hf; hf=hf->next) {
1086 1095
 		if(gp->type==GPARAM_TYPE_INT)
1087 1096
 		{
... ...
@@ -1108,7 +1117,10 @@ static int is_present_hf_re_f(struct sip_msg* msg, char* key, char* foo)
1108 1117
 	re = (regex_t*)key;
1109 1118
 
1110 1119
 	/* we need to be sure we have seen all HFs */
1111
-	parse_headers(msg, HDR_EOH_F, 0);
1120
+	if(parse_headers(msg, HDR_EOH_F, 0)<0) {
1121
+		LM_ERR("error while parsing message headers\n");
1122
+		return -1;
1123
+	}
1112 1124
 	for (hf=msg->headers; hf; hf=hf->next)
1113 1125
 	{
1114 1126
 		c = hf->name.s[hf->name.len];
... ...
@@ -2214,7 +2226,7 @@ int add_hf_helper(struct sip_msg* msg, str *str1, str *str2,
2214 2226
 		LM_ERR("error while parsing message\n");
2215 2227
 		return -1;
2216 2228
 	}
2217
-	
2229
+
2218 2230
 	hf = 0;
2219 2231
 	if(hfanc!=NULL) {
2220 2232
 		for (hf=msg->headers; hf; hf=hf->next) {
... ...
@@ -2265,7 +2277,7 @@ int add_hf_helper(struct sip_msg* msg, str *str1, str *str2,
2265 2277
 			s0.s   = 0;
2266 2278
 		}
2267 2279
 	}
2268
-		
2280
+
2269 2281
 	len=s0.len;
2270 2282
 	if (str2) len+= str2->len + REQ_LINE(msg).uri.len;
2271 2283
 
... ...
@@ -2899,7 +2911,10 @@ static int search_hf_f(struct sip_msg* msg, char* str_hf, char* re, char *flags)
2899 2911
 	gp = (gparam_t*)str_hf;
2900 2912
 
2901 2913
 	/* we need to be sure we have seen all HFs */
2902
-	parse_headers(msg, HDR_EOH_F, 0);
2914
+	if(parse_headers(msg, HDR_EOH_F, 0)<0) {
2915
+		LM_ERR("error while parsing message headers\n");
2916
+		return -1;
2917
+	}
2903 2918
 	for (hf=msg->headers; hf; hf=hf->next) {
2904 2919
 		if(gp->type==GPARAM_TYPE_INT)
2905 2920
 		{
... ...
@@ -2980,7 +2995,10 @@ static int subst_hf_f(struct sip_msg *msg, char *str_hf, char *subst, char *flag
2980 2995
 	se=(struct subst_expr*)subst;
2981 2996
 
2982 2997
 	/* we need to be sure we have seen all HFs */
2983
-	parse_headers(msg, HDR_EOH_F, 0);
2998
+	if(parse_headers(msg, HDR_EOH_F, 0)<0) {
2999
+		LM_ERR("error while parsing message headers\n");
3000
+		return -1;
3001
+	}
2984 3002
 	for (hf=msg->headers; hf; hf=hf->next) {
2985 3003
 		if(gp->type==GPARAM_TYPE_INT)
2986 3004
 		{
... ...
@@ -3020,7 +3038,7 @@ static int subst_hf_f(struct sip_msg *msg, char *str_hf, char *subst, char *flag
3020 3038
 					ret=-1;
3021 3039
 					goto error;
3022 3040
 				}
3023
-				/* hack to avoid re-copying rpl, possible because both 
3041
+				/* hack to avoid re-copying rpl, possible because both
3024 3042
 				 * replace_lst & lumps use pkg_malloc */
3025 3043
 				if (insert_new_lump_after(l, rpl->rpl.s, rpl->rpl.len, 0)==0)
3026 3044
 				{