From ca546d35c326666c6389c84ce45214bd2fc5c147 Mon Sep 17 00:00:00 2001 From: Daniel-Constantin Mierla Date: Wed, 20 Nov 2019 18:06:22 +0100 Subject: [PATCH] core: make dst_uri null terminated --- src/core/parser/msg_parser.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/core/parser/msg_parser.c b/src/core/parser/msg_parser.c index 281c8ad7830..91095bf5741 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; }