Browse code

dialog: keep route block index as signed int

- otherwise it can be broken value when route block doesn't exit and
kemi callback should be executed
- reported by David Escartin

Daniel-Constantin Mierla authored on 13/02/2020 16:01:49
Showing 2 changed files
... ...
@@ -114,7 +114,7 @@ typedef struct dlg_cell
114 114
 	unsigned int         dflags;		/*!< internal dialog memory flags */
115 115
 	unsigned int         iflags;		/*!< internal dialog persistent flags */
116 116
 	unsigned int         sflags;		/*!< script dialog persistent flags */
117
-	unsigned int         toroute;		/*!< index of route that is executed on timeout */
117
+	int                  toroute;		/*!< index of route that is executed on timeout */
118 118
 	str                  toroute_name;	/*!< name of route that is executed on timeout */
119 119
 	unsigned int         from_rr_nb;	/*!< information from record routing */
120 120
 	struct dlg_tl        tl;			/*!< dialog timer list */
... ...
@@ -478,8 +478,8 @@ int pv_get_dlg_ctx(struct sip_msg *msg,  pv_param_t *param,
478 478
 			return pv_get_uintval(msg, param, res,
479 479
 					(unsigned int)_dlg_ctx.dir);
480 480
 		case 7:
481
-			return pv_get_uintval(msg, param, res,
482
-					(unsigned int)_dlg_ctx.to_route);
481
+			return pv_get_sintval(msg, param, res,
482
+					_dlg_ctx.to_route);
483 483
 		default:
484 484
 			return pv_get_uintval(msg, param, res,
485 485
 					(unsigned int)_dlg_ctx.on);
... ...
@@ -601,6 +601,7 @@ int pv_get_dlg(struct sip_msg *msg, pv_param_t *param,
601 601
 	int res_type = 0;
602 602
 	str sv = { 0 };
603 603
 	unsigned int ui = 0;
604
+	int si = 0;
604 605
 
605 606
 	if(param==NULL)
606 607
 		return -1;
... ...
@@ -683,8 +684,8 @@ int pv_get_dlg(struct sip_msg *msg, pv_param_t *param,
683 683
 			sv.s[sv.len] = '\0';
684 684
 			break;
685 685
 		case 9:
686
-			res_type = 1;
687
-			ui = (unsigned int)dlg->toroute;
686
+			res_type = 3;
687
+			si = dlg->toroute;
688 688
 			break;
689 689
 		case 10:
690 690
 			if(dlg->cseq[DLG_CALLEE_LEG].s==NULL
... ...
@@ -817,6 +818,8 @@ done:
817 817
 			return pv_get_uintval(msg, param, res, ui);
818 818
 		case 2:
819 819
 			return pv_get_strval(msg, param, res, &sv);
820
+		case 3:
821
+			return pv_get_sintval(msg, param, res, si);
820 822
 		default:
821 823
 			return pv_get_null(msg, param, res);
822 824
 	}