Module: kamailio
Branch: master
Commit: ca546d35c326666c6389c84ce45214bd2fc5c147
URL:
https://github.com/kamailio/kamailio/commit/ca546d35c326666c6389c84ce45214b…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)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/ca546d35c326666c6389c84ce45214b…
Patch:
https://github.com/kamailio/kamailio/commit/ca546d35c326666c6389c84ce45214b…
---
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;
}