Module: kamailio
Branch: master
Commit: 9e13c9512b48ab9522f508465c6031e7b4a96086
URL:
https://github.com/kamailio/kamailio/commit/9e13c9512b48ab9522f508465c6031e…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2018-09-20T16:56:04+02:00
core: use memcpy() instead of strncpy()
- avoid gcc 8.2 warning: âstrncpyâ output truncated before terminating nul
---
Modified: src/core/dset.c
Modified: src/core/select_core.c
---
Diff:
https://github.com/kamailio/kamailio/commit/9e13c9512b48ab9522f508465c6031e…
Patch:
https://github.com/kamailio/kamailio/commit/9e13c9512b48ab9522f508465c6031e…
---
diff --git a/src/core/dset.c b/src/core/dset.c
index 1a10f2af9a..ff40c192ad 100644
--- a/src/core/dset.c
+++ b/src/core/dset.c
@@ -877,18 +877,18 @@ int uri_restore_rcv_alias(str *uri, str *nuri, str *suri)
nuri->len = p - nuri->s;
p = suri->s;
- strncpy(p, "sip:", 4);
+ memcpy(p, "sip:", 4);
p += 4;
- strncpy(p, ip.s, ip.len);
+ memcpy(p, ip.s, ip.len);
p += ip.len;
*p++ = ':';
- strncpy(p, port.s, port.len);
+ memcpy(p, port.s, port.len);
p += port.len;
proto_type_to_str((unsigned short)proto, &sproto);
if(sproto.len>0 && proto!=PROTO_UDP) {
- strncpy(p, ";transport=", 11);
+ memcpy(p, ";transport=", 11);
p += 11;
- strncpy(p, sproto.s, sproto.len);
+ memcpy(p, sproto.s, sproto.len);
p += sproto.len;
}
suri->len = p - suri->s;
diff --git a/src/core/select_core.c b/src/core/select_core.c
index 112dee489e..c96db61104 100644
--- a/src/core/select_core.c
+++ b/src/core/select_core.c
@@ -827,7 +827,7 @@ int select_uri_hostport(str* res, select_t* s, struct sip_msg* msg)
{
char* p;
int size;
-
+
if (select_uri_p == NULL) {
if (parse_uri(res->s, res->len, &uri)<0)
return -1;
@@ -836,27 +836,27 @@ int select_uri_hostport(str* res, select_t* s, struct sip_msg* msg)
if (!select_uri_p->host.len)
return -1;
-
+
if (select_uri_p->port.len) {
res->s=select_uri_p->host.s;
res->len=select_uri_p->host.len+select_uri_p->port.len+1;
return 0;
}
-
+
size=select_uri_p->host.len+5;
if (!(p = get_static_buffer(size)))
return -1;
-
- strncpy(p, select_uri_p->host.s, select_uri_p->host.len);
+
+ memcpy(p, select_uri_p->host.s, select_uri_p->host.len);
switch (select_uri_p->type) {
case SIPS_URI_T:
case TELS_URI_T:
- strncpy(p+select_uri_p->host.len, ":5061", 5);
+ memcpy(p+select_uri_p->host.len, ":5061", 5);
break;
case SIP_URI_T:
case TEL_URI_T:
case URN_URI_T:
- strncpy(p+select_uri_p->host.len, ":5060", 5);
+ memcpy(p+select_uri_p->host.len, ":5060", 5);
break;
case ERROR_URI_T:
return -1;