Commit 533d6dbf authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Use strlcpy()

parent 83d33207
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
#include <vlc/vlc.h> #include <vlc/vlc.h>
#include <stddef.h> /* size_t */ #include <stddef.h> /* size_t */
#include <string.h> /* strncpy(), strlen(), memcpy(), memset(), strchr() */ #include <string.h> /* strlen(), memcpy(), memset(), strchr() */
#include <stdlib.h> /* malloc(), free(), strtoul() */ #include <stdlib.h> /* malloc(), free(), strtoul() */
#include <errno.h> #include <errno.h>
...@@ -175,8 +175,7 @@ __getnameinfo( const struct sockaddr *sa, socklen_t salen, ...@@ -175,8 +175,7 @@ __getnameinfo( const struct sockaddr *sa, socklen_t salen,
if (hent != NULL) if (hent != NULL)
{ {
strncpy (host, hent->h_name, hostlen); strlcpy (host, hent->h_name, hostlen);
host[hostlen - 1] = '\0';
/* /*
* only keep first part of hostname * only keep first part of hostname
...@@ -199,11 +198,8 @@ __getnameinfo( const struct sockaddr *sa, socklen_t salen, ...@@ -199,11 +198,8 @@ __getnameinfo( const struct sockaddr *sa, socklen_t salen,
} }
if (!solved) if (!solved)
{
/* inet_ntoa() can't fail */ /* inet_ntoa() can't fail */
strncpy (host, inet_ntoa (addr->sin_addr), hostlen); strlcpy (host, inet_ntoa (addr->sin_addr), hostlen);
host[hostlen - 1] = '\0';
}
} }
if (serv != NULL) if (serv != NULL)
...@@ -222,8 +218,7 @@ __getnameinfo( const struct sockaddr *sa, socklen_t salen, ...@@ -222,8 +218,7 @@ __getnameinfo( const struct sockaddr *sa, socklen_t salen,
? "udp" : "tcp"); ? "udp" : "tcp");
if (sent != NULL) if (sent != NULL)
{ {
strncpy (serv, sent->s_name, servlen); strlcpy (serv, sent->s_name, servlen);
serv[servlen - 1] = 0;
solved = 1; solved = 1;
} }
} }
...@@ -636,8 +631,7 @@ int vlc_getaddrinfo( vlc_object_t *p_this, const char *node, ...@@ -636,8 +631,7 @@ int vlc_getaddrinfo( vlc_object_t *p_this, const char *node,
} }
else else
{ {
strncpy( psz_buf, node, NI_MAXHOST ); strlcpy( psz_buf, node, NI_MAXHOST );
psz_buf[NI_MAXHOST - 1] = '\0';
psz_node = psz_buf; psz_node = psz_buf;
......
...@@ -602,8 +602,7 @@ static char *SDPGenerate( sap_handler_t *p_sap, ...@@ -602,8 +602,7 @@ static char *SDPGenerate( sap_handler_t *p_sap,
{ {
char *ptr; char *ptr;
strncpy( psz_uribuf, p_session->psz_uri + 1, sizeof( psz_uribuf ) ); strlcpy( psz_uribuf, p_session->psz_uri + 1, sizeof( psz_uribuf ) );
psz_uribuf[sizeof( psz_uribuf ) - 1] = '\0';
ptr = strchr( psz_uribuf, '%' ); ptr = strchr( psz_uribuf, '%' );
if( ptr != NULL) if( ptr != NULL)
*ptr = '\0'; *ptr = '\0';
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment