Module: kamailio
Branch: master
Commit: 6aa2b91b581d7e0f138a9a19f61d848caeb61a19
URL:
https://github.com/kamailio/kamailio/commit/6aa2b91b581d7e0f138a9a19f61d848…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2017-04-07T17:05:44+02:00
core: use buffers instead of static empty string
- if code tries to write in, results in a crash
- reported by Juha Heinanen
---
Modified: src/core/lvalue.c
Modified: src/core/parser/parse_uri.c
---
Diff:
https://github.com/kamailio/kamailio/commit/6aa2b91b581d7e0f138a9a19f61d848…
Patch:
https://github.com/kamailio/kamailio/commit/6aa2b91b581d7e0f138a9a19f61d848…
---
diff --git a/src/core/lvalue.c b/src/core/lvalue.c
index b348b53..99fbc27 100644
--- a/src/core/lvalue.c
+++ b/src/core/lvalue.c
@@ -25,6 +25,9 @@
#include "dprint.h"
#include "route.h"
+static char _lval_empty_buf[2] = {0};
+static str _lval_empty = { _lval_empty_buf, 0 };
+
/* callback to log assign actions */
static log_assign_action_f _log_assign_action = NULL;
@@ -124,8 +127,7 @@ inline static int lval_avp_assign(struct run_act_ctx* h, struct
sip_msg* msg,
flags=avp->type|AVP_VAL_STR;
v=run_select(&value.s, &rv->v.sel, msg);
if (unlikely(v!=0)){
- value.s.s="";
- value.s.len=0;
+ value.s = _lval_empty;
if (v<0){
ret=-1;
break;
@@ -302,8 +304,7 @@ inline static int lval_pvar_assign(struct run_act_ctx* h, struct
sip_msg* msg,
v=run_select(&pval.rs, &rv->v.sel, msg);
if (unlikely(v!=0)){
pval.flags|=PV_VAL_EMPTY;
- pval.rs.s="";
- pval.rs.len=0;
+ pval.rs = _lval_empty;
if (v<0){
ret=-1;
break;
diff --git a/src/core/parser/parse_uri.c b/src/core/parser/parse_uri.c
index 4e0be0f..71d56f5 100644
--- a/src/core/parser/parse_uri.c
+++ b/src/core/parser/parse_uri.c
@@ -34,6 +34,9 @@
#include "../error.h"
#include "../core_stats.h"
+static char _sr_uri_empty_buf[2] = {0};
+static str _sr_uri_empty = { _sr_uri_empty_buf, 0 };
+
/* buf= pointer to begining of uri (sip:x@foo.bar:5060;a=b?h=i)
* len= len of uri
* returns: fills uri & returns <0 on error or 0 if ok
@@ -1191,8 +1194,7 @@ int parse_uri(char* buf, int len, struct sip_uri* uri)
case TELS_URI_T:
/* fix tel uris, move the number in uri and empty the host */
uri->user=uri->host;
- uri->host.s="";
- uri->host.len=0;
+ uri->host=_sr_uri_empty;
break;
/* urn: do nothing */
case URN_URI_T: