[sr-dev] git:master:ca546d35: core: make dst_uri null terminated

Daniel-Constantin Mierla miconda at gmail.com
Wed Nov 20 18:08:23 CET 2019


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

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2019-11-20T18:06:22+01:00

core: make dst_uri null terminated

---

Modified: src/core/parser/msg_parser.c

---

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

---

diff --git a/src/core/parser/msg_parser.c b/src/core/parser/msg_parser.c
index 281c8ad783..91095bf574 100644
--- a/src/core/parser/msg_parser.c
+++ b/src/core/parser/msg_parser.c
@@ -749,7 +749,7 @@ int set_dst_uri(struct sip_msg* const msg, const str* const uri)
 		memcpy(msg->dst_uri.s, uri->s, uri->len);
 		msg->dst_uri.len = uri->len;
 	} else {
-		ptr = (char*)pkg_malloc(uri->len);
+		ptr = (char*)pkg_malloc(uri->len + 1);
 		if (!ptr) {
 			PKG_MEM_ERROR;
 			return -1;
@@ -759,6 +759,7 @@ int set_dst_uri(struct sip_msg* const msg, const str* const uri)
 		if (msg->dst_uri.s) pkg_free(msg->dst_uri.s);
 		msg->dst_uri.s = ptr;
 		msg->dst_uri.len = uri->len;
+		msg->dst_uri.s[msg->dst_uri.len] = '\0';
 	}
 	return 0;
 }




More information about the sr-dev mailing list