Browse code

pv: handle s.prefixes for empty values

- avoid crash due to invalid length of result, GH #2467

Daniel-Constantin Mierla authored on 04/09/2020 08:22:52
Showing 1 changed files
... ...
@@ -909,6 +909,7 @@ int tr_eval_string(struct sip_msg *msg, tr_param_t *tp, int subtype,
909 909
 			if(!(val->flags&PV_VAL_STR))
910 910
 				val->rs.s = int2str(val->ri, &val->rs.len);
911 911
 
912
+
912 913
 			/* Set maximum prefix length */
913 914
 			max = val->rs.len;
914 915
 			if(tp!=NULL) {
... ...
@@ -947,7 +948,7 @@ int tr_eval_string(struct sip_msg *msg, tr_param_t *tp, int subtype,
947 948
 			memset(val, 0, sizeof(pv_value_t));
948 949
 			val->flags = PV_VAL_STR;
949 950
 			val->rs.s = _tr_buffer;
950
-			val->rs.len = j-1;
951
+			val->rs.len = (j>0)?(j-1):0;
951 952
 			break;
952 953
 
953 954