[sr-dev] git:master:85bcf011: modules/ims_usrloc_scscf: put checks to ensure shm_str_dup not called on empty strings

jaybeepee jason.penton at gmail.com
Mon Sep 19 17:11:08 CEST 2016


Module: kamailio
Branch: master
Commit: 85bcf011063772936ea75f7c332788241f09f590
URL: https://github.com/kamailio/kamailio/commit/85bcf011063772936ea75f7c332788241f09f590

Author: jaybeepee <jason.penton at gmail.com>
Committer: jaybeepee <jason.penton at gmail.com>
Date: 2016-09-19T17:10:08+02:00

modules/ims_usrloc_scscf: put checks to ensure shm_str_dup not called on empty strings

---

Modified: modules/ims_usrloc_scscf/ucontact.c

---

Diff:  https://github.com/kamailio/kamailio/commit/85bcf011063772936ea75f7c332788241f09f590.diff
Patch: https://github.com/kamailio/kamailio/commit/85bcf011063772936ea75f7c332788241f09f590.patch

---

diff --git a/modules/ims_usrloc_scscf/ucontact.c b/modules/ims_usrloc_scscf/ucontact.c
index ac18d15..2d882b5 100644
--- a/modules/ims_usrloc_scscf/ucontact.c
+++ b/modules/ims_usrloc_scscf/ucontact.c
@@ -123,8 +123,18 @@ ucontact_t* new_ucontact(str* _dom, str* _aor, str* _contact, ucontact_info_t* _
 	curr->len = param->len;
 	curr->type = param->type;
 	curr->next = 0;
-	if (shm_str_dup(&curr->body, &param->body) < 0) goto error;
-	if (shm_str_dup(&curr->name, &param->name) < 0) goto error;
+	if (param->body.len > 0 && param->body.s) {
+		if (shm_str_dup(&curr->body, &param->body) < 0) goto error;
+	} else {
+		curr->body.s = 0;
+		curr->body.len = 0;
+	}
+	if (param->name.len > 0 && param->name.s) {
+		if (shm_str_dup(&curr->name, &param->name) < 0) goto error;
+	} else {
+		curr->name.s = 0;
+		curr->name.len = 0;
+	}
 	
 	if(first) {
 	    c->params = curr;
@@ -138,15 +148,24 @@ ucontact_t* new_ucontact(str* _dom, str* _aor, str* _contact, ucontact_info_t* _
     }
     
     if (shm_str_dup(&c->c, _contact) < 0) goto error;
-    if (shm_str_dup(&c->callid, _ci->callid) < 0) goto error;
-    if (shm_str_dup(&c->user_agent, _ci->user_agent) < 0) goto error;
-    if (shm_str_dup(&c->aor, _aor) < 0) goto error;
-    if (shm_str_dup(&c->domain, _dom) < 0) goto error;
+	
+	if (_ci->callid && _ci->callid->len > 0) {
+		if (shm_str_dup(&c->callid, _ci->callid) < 0) goto error;
+	}
+	if (_ci->user_agent && _ci->user_agent->len > 0) {
+		if (shm_str_dup(&c->user_agent, _ci->user_agent) < 0) goto error;
+	}
+	if (_aor && _aor->len > 0) {
+		if (shm_str_dup(&c->aor, _aor) < 0) goto error;
+	}
+	if (_dom && _dom->len > 0) {
+		if (shm_str_dup(&c->domain, _dom) < 0) goto error;
+	}
     
-    if (_ci->received.s && _ci->received.len) {
+    if (_ci->received.len > 0) {
         if (shm_str_dup(&c->received, &_ci->received) < 0) goto error;
     }
-    if (_ci->path && _ci->path->len) {
+    if (_ci->path && _ci->path->len > 0) {
         if (shm_str_dup(&c->path, _ci->path) < 0) goto error;
     }
     




More information about the sr-dev mailing list