Module: kamailio
Branch: master
Commit: e74b06c32bc2b090937350858f655af4ab89ff63
URL:
https://github.com/kamailio/kamailio/commit/e74b06c32bc2b090937350858f655af…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2020-09-04T10:22:52+02:00
pv: handle s.prefixes for empty values
- avoid crash due to invalid length of result, GH #2467
---
Modified: src/modules/pv/pv_trans.c
---
Diff:
https://github.com/kamailio/kamailio/commit/e74b06c32bc2b090937350858f655af…
Patch:
https://github.com/kamailio/kamailio/commit/e74b06c32bc2b090937350858f655af…
---
diff --git a/src/modules/pv/pv_trans.c b/src/modules/pv/pv_trans.c
index 4de9849165..437e3b2e74 100644
--- a/src/modules/pv/pv_trans.c
+++ b/src/modules/pv/pv_trans.c
@@ -909,6 +909,7 @@ int tr_eval_string(struct sip_msg *msg, tr_param_t *tp, int subtype,
if(!(val->flags&PV_VAL_STR))
val->rs.s = int2str(val->ri, &val->rs.len);
+
/* Set maximum prefix length */
max = val->rs.len;
if(tp!=NULL) {
@@ -947,7 +948,7 @@ int tr_eval_string(struct sip_msg *msg, tr_param_t *tp, int subtype,
memset(val, 0, sizeof(pv_value_t));
val->flags = PV_VAL_STR;
val->rs.s = _tr_buffer;
- val->rs.len = j-1;
+ val->rs.len = (j>0)?(j-1):0;
break;