Module: kamailio
Branch: 5.2
Commit: 41a9d81e63bd4a3e44fcd00d2cf2c2855079b41b
URL:
https://github.com/kamailio/kamailio/commit/41a9d81e63bd4a3e44fcd00d2cf2c28…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2020-09-04T10:45:38+02:00
pv: handle s.prefixes for empty values
- avoid crash due to invalid length of result, GH #2467
(cherry picked from commit e74b06c32bc2b090937350858f655af4ab89ff63)
(cherry picked from commit ad14b61155686aead27e7ac5f3fb6b1aa90b6840)
(cherry picked from commit 8fcbfc697eaa7df91e84bfbf484ed51a49fc0e2e)
---
Modified: src/modules/pv/pv_trans.c
---
Diff:
https://github.com/kamailio/kamailio/commit/41a9d81e63bd4a3e44fcd00d2cf2c28…
Patch:
https://github.com/kamailio/kamailio/commit/41a9d81e63bd4a3e44fcd00d2cf2c28…
---
diff --git a/src/modules/pv/pv_trans.c b/src/modules/pv/pv_trans.c
index 8ab46d328f..9b512e860f 100644
--- a/src/modules/pv/pv_trans.c
+++ b/src/modules/pv/pv_trans.c
@@ -837,6 +837,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) {
@@ -875,7 +876,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;