Browse code

tmx: safety check of expected route blocks for using $T_*() variables

- related to GH #2479

Daniel-Constantin Mierla authored on 17/09/2020 12:21:30
Showing 1 changed files
... ...
@@ -305,6 +305,11 @@ int pv_get_t_var_req(struct sip_msg *msg,  pv_param_t *param,
305 305
 {
306 306
 	pv_spec_t *pv=NULL;
307 307
 
308
+	if(!is_route_type(CORE_ONREPLY_ROUTE|TM_ONREPLY_ROUTE)) {
309
+		LM_DBG("used in unsupported route block - type %d\n", get_route_type());
310
+		return pv_get_null(msg, param, res);
311
+	}
312
+
308 313
 	if(pv_t_update_req(msg))
309 314
 		return pv_get_null(msg, param, res);
310 315
 
... ...
@@ -320,6 +325,11 @@ int pv_get_t_var_rpl(struct sip_msg *msg,  pv_param_t *param,
320 325
 {
321 326
 	pv_spec_t *pv=NULL;
322 327
 
328
+	if(!is_route_type(FAILURE_ROUTE|BRANCH_FAILURE_ROUTE)) {
329
+		LM_DBG("used in unsupported route block - type %d\n", get_route_type());
330
+		return pv_get_null(msg, param, res);
331
+	}
332
+
323 333
 	if(pv_t_update_rpl(msg))
324 334
 		return pv_get_null(msg, param, res);
325 335
 
... ...
@@ -335,6 +345,11 @@ int pv_get_t_var_branch(struct sip_msg *msg,  pv_param_t *param,
335 345
 {
336 346
 	pv_spec_t *pv=NULL;
337 347
 
348
+	if(!is_route_type(FAILURE_ROUTE|BRANCH_FAILURE_ROUTE|TM_ONREPLY_ROUTE)) {
349
+		LM_DBG("used in unsupported route block - type %d\n", get_route_type());
350
+		return pv_get_null(msg, param, res);
351
+	}
352
+
338 353
 	if(pv_t_update_rpl(msg))
339 354
 		return pv_get_null(msg, param, res);
340 355
 
... ...
@@ -350,6 +365,11 @@ int pv_get_t_var_inv(struct sip_msg *msg,  pv_param_t *param,
350 365
 {
351 366
 	pv_spec_t *pv=NULL;
352 367
 
368
+	if(!is_route_type(REQUEST_ROUTE)) {
369
+		LM_DBG("used in unsupported route block - type %d\n", get_route_type());
370
+		return pv_get_null(msg, param, res);
371
+	}
372
+
353 373
 	if(pv_t_update_inv(msg))
354 374
 		return pv_get_null(msg, param, res);
355 375