Module: kamailio Branch: master Commit: 127c8cb4bbf3047c7222be7ff0fb202765dd6db1 URL: https://github.com/kamailio/kamailio/commit/127c8cb4bbf3047c7222be7ff0fb2027...
Author: Victor Seva linuxmaniac@torreviejawireless.org Committer: Victor Seva linuxmaniac@torreviejawireless.org Date: 2018-09-28T14:42:44+02:00
dmq: use memcpy() instead of strncpy()
notification_peer.c: In function 'create_IP_uri': notification_peer.c:100:3: warning: 'strncpy' output truncated before terminating nul copying 5 bytes from a string of the same length [-Wstringop-truncation] strncpy(plist, "sips:", 5); ^~~~~~~~~~~~~~~~~~~~~~~~~~ notification_peer.c:103:3: warning: 'strncpy' output truncated before terminating nul copying 4 bytes from a string of the same length [-Wstringop-truncation] strncpy(plist, "sip:", 4); ^~~~~~~~~~~~~~~~~~~~~~~~~
---
Modified: src/modules/dmq/notification_peer.c
---
Diff: https://github.com/kamailio/kamailio/commit/127c8cb4bbf3047c7222be7ff0fb2027... Patch: https://github.com/kamailio/kamailio/commit/127c8cb4bbf3047c7222be7ff0fb2027...
---
diff --git a/src/modules/dmq/notification_peer.c b/src/modules/dmq/notification_peer.c index c1deb80536..f6a3e8e478 100644 --- a/src/modules/dmq/notification_peer.c +++ b/src/modules/dmq/notification_peer.c @@ -97,18 +97,18 @@ int create_IP_uri(char **puri_list, int host_index, char *phost, int hostlen,
plist = puri_list[host_index]; if(puri->type == SIPS_URI_T) { - strncpy(plist, "sips:", 5); + memcpy(plist, "sips:", 5); pos = 5; } else { - strncpy(plist, "sip:", 4); + memcpy(plist, "sip:", 4); pos = 4; } if(puri->user.s) { - strncpy(&plist[pos], puri->user.s, puri->user.len); + memcpy(&plist[pos], puri->user.s, puri->user.len); pos += puri->user.len; if(puri->passwd.s) { plist[pos++] = ':'; - strncpy(&plist[pos], puri->passwd.s, puri->passwd.len); + memcpy(&plist[pos], puri->passwd.s, puri->passwd.len); pos += puri->passwd.len; } plist[pos++] = '@'; @@ -117,7 +117,7 @@ int create_IP_uri(char **puri_list, int host_index, char *phost, int hostlen, LM_WARN("%s", perr); return 0; } - strncpy(&plist[pos], phost, hostlen); + memcpy(&plist[pos], phost, hostlen); pos += hostlen; if(puri->port_no) { if((pos + 6) > MAXDMQURILEN) { @@ -133,7 +133,7 @@ int create_IP_uri(char **puri_list, int host_index, char *phost, int hostlen, return 0; } plist[pos++] = ';'; - strncpy(&plist[pos], puri->params.s, puri->params.len); + memcpy(&plist[pos], puri->params.s, puri->params.len); pos += puri->params.len; } plist[pos] = '\0';