[sr-dev] git:master: pv(k): Remove read-only empty strings that might be attempted to be written to

Richard Fuchs rfuchs at sipwise.com
Wed Jan 9 18:35:50 CET 2013


Module: sip-router
Branch: master
Commit: 70ca23583a136f2a401ce57d4b9f110e2f4db1fe
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=70ca23583a136f2a401ce57d4b9f110e2f4db1fe

Author: Richard Fuchs <rfuchs at sipwise.com>
Committer: Richard Fuchs <rfuchs at sipwise.com>
Date:   Wed Jan  9 12:34:27 2013 -0500

pv(k): Remove read-only empty strings that might be attempted to be written to

---

 modules_k/pv/pv_core.c  |    5 +++--
 modules_k/pv/pv_trans.c |   17 ++++++++---------
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/modules_k/pv/pv_core.c b/modules_k/pv/pv_core.c
index d67278f..c4eba97 100644
--- a/modules_k/pv/pv_core.c
+++ b/modules_k/pv/pv_core.c
@@ -59,6 +59,7 @@ static str pv_uri_scheme[] = {
 		{ "urn",  3 },
 		{ 0, 0 }
 	};
+static char _empty_str[] = "";
 
 static str pv_af_list[] = {
 		{ "IPv4",  4 },
@@ -1872,7 +1873,7 @@ int pv_set_ruri_user(struct sip_msg* msg, pv_param_t *param,
 		memset(&act, 0, sizeof(act));
 		act.type = SET_USER_T;
 		act.val[0].type = STRING_ST;
-		act.val[0].u.string = "";
+		act.val[0].u.string = _empty_str;
 		init_run_actions_ctx(&h);
 		if (do_action(&h, &act, msg)<0)
 		{
@@ -1965,7 +1966,7 @@ int pv_set_ruri_port(struct sip_msg* msg, pv_param_t *param,
 		memset(&act, 0, sizeof(act));
 		act.type = SET_PORT_T;
 		act.val[0].type = STRING_ST;
-		act.val[0].u.string = "";
+		act.val[0].u.string = _empty_str;
 		init_run_actions_ctx(&h);
 		if (do_action(&h, &act, msg)<0)
 		{
diff --git a/modules_k/pv/pv_trans.c b/modules_k/pv/pv_trans.c
index 995d25a..fc9597b 100644
--- a/modules_k/pv/pv_trans.c
+++ b/modules_k/pv/pv_trans.c
@@ -49,6 +49,12 @@
 #include "pv_trans.h"
 
 
+static char _empty_str[] = "";
+static str _tr_empty = { _empty_str, 0 };
+static str _tr_uri = {0, 0};
+static struct sip_uri _tr_parsed_uri;
+static param_t* _tr_uri_params = NULL;
+
 /*! transformation buffer size */
 #define TR_BUFFER_SIZE 65536
 #define TR_BUFFER_SLOTS	4
@@ -384,8 +390,7 @@ int tr_eval_string(struct sip_msg *msg, tr_param_t *tp, int subtype,
 					val->rs.s = p+1;
 					val->rs.len = s-p;
 				} else {
-					val->rs.s = "";
-					val->rs.len = 0;
+					val->rs = _tr_empty;
 				}
 			} else {
 				s = val->rs.s;
@@ -406,8 +411,7 @@ int tr_eval_string(struct sip_msg *msg, tr_param_t *tp, int subtype,
 					val->rs.s = s;
 					val->rs.len = p-s;
 				} else {
-					val->rs.s = "";
-					val->rs.len = 0;
+					val->rs = _tr_empty;
 				}
 			}
 			break;
@@ -789,11 +793,6 @@ int tr_eval_string(struct sip_msg *msg, tr_param_t *tp, int subtype,
 	return 0;
 }
 
-static str _tr_empty = { "", 0 };
-static str _tr_uri = {0, 0};
-static struct sip_uri _tr_parsed_uri;
-static param_t* _tr_uri_params = NULL;
-
 
 /*!
  * \brief Evaluate URI transformations




More information about the sr-dev mailing list