Skip to content

Commit

Permalink
ims_ipsec_pcscf: null terminate dst_uri fields
Browse files Browse the repository at this point in the history
(cherry picked from commit a8be245)
  • Loading branch information
miconda committed Jan 8, 2020
1 parent 99f51cb commit 6f26ff8
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/modules/ims_ipsec_pcscf/cmd.c
Expand Up @@ -753,13 +753,14 @@ int ipsec_forward(struct sip_msg* m, udomain_t* d)

int buf_len = snprintf(buf, sizeof(buf) - 1, "sip:%.*s:%d", ci.via_host.len, ci.via_host.s, dst_port);

if((m->dst_uri.s = pkg_malloc(buf_len)) == NULL) {
if((m->dst_uri.s = pkg_malloc(buf_len + 1)) == NULL) {
LM_ERR("Error allocating memory for dst_uri\n");
goto cleanup;
}

memcpy(m->dst_uri.s, buf, buf_len);
m->dst_uri.len = buf_len;
m->dst_uri.s[m->dst_uri.len] = '\0';

// Set send socket
struct socket_info * client_sock = grep_sock_info(via_host.af == AF_INET ? &ipsec_listen_addr : &ipsec_listen_addr6, src_port, dst_proto);
Expand Down

0 comments on commit 6f26ff8

Please sign in to comment.