Module: kamailio
Branch: 5.3
Commit: 8283d34684fda83a8f9ec610cd32fb524d09a7be
URL:
https://github.com/kamailio/kamailio/commit/8283d34684fda83a8f9ec610cd32fb5…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2020-03-19T19:20:37+01:00
pv: do not set ending '\0' for port value in pv_set_ruri_port()
- it can be a reference to a static string, ending up in a crash
- GH #2258
(cherry picked from commit 1f76bca74839f35d11f42edf758eb046cedb752c)
---
Modified: src/modules/pv/pv_core.c
---
Diff:
https://github.com/kamailio/kamailio/commit/8283d34684fda83a8f9ec610cd32fb5…
Patch:
https://github.com/kamailio/kamailio/commit/8283d34684fda83a8f9ec610cd32fb5…
---
diff --git a/src/modules/pv/pv_core.c b/src/modules/pv/pv_core.c
index 18db915cfb..9087fe01bf 100644
--- a/src/modules/pv/pv_core.c
+++ b/src/modules/pv/pv_core.c
@@ -2558,7 +2558,9 @@ int pv_set_ruri_port(struct sip_msg* msg, pv_param_t *param,
act.val[0].type = STRING_ST;
act.val[0].u.string = val->rs.s;
backup = val->rs.s[val->rs.len];
- val->rs.s[val->rs.len] = '\0';
+ if(backup != '\0') {
+ val->rs.s[val->rs.len] = '\0';
+ }
act.type = SET_PORT_T;
init_run_actions_ctx(&h);
if (do_action(&h, &act, msg)<0)
@@ -2567,7 +2569,9 @@ int pv_set_ruri_port(struct sip_msg* msg, pv_param_t *param,
val->rs.s[val->rs.len] = backup;
goto error;
}
- val->rs.s[val->rs.len] = backup;
+ if(backup != '\0') {
+ val->rs.s[val->rs.len] = backup;
+ }
return 0;
error: