Module: kamailio
Branch: 5.4
Commit: ad14b61155686aead27e7ac5f3fb6b1aa90b6840
URL:
https://github.com/kamailio/kamailio/commit/ad14b61155686aead27e7ac5f3fb6b1…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2020-09-04T10:32:34+02:00
pv: handle s.prefixes for empty values
- avoid crash due to invalid length of result, GH #2467
(cherry picked from commit e74b06c32bc2b090937350858f655af4ab89ff63)
---
Modified: src/modules/pv/pv_trans.c
---
Diff:
https://github.com/kamailio/kamailio/commit/ad14b61155686aead27e7ac5f3fb6b1…
Patch:
https://github.com/kamailio/kamailio/commit/ad14b61155686aead27e7ac5f3fb6b1…
---
diff --git a/src/modules/pv/pv_trans.c b/src/modules/pv/pv_trans.c
index d07e55e719..cdfcd3ddf3 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;