- uri is expected to be nul-terminated (strchr used later),
so use strlcpy instead of strncpy. - unroll the other two cases of strncpy+\0 to strlcpy. MFC after: 2 weeks
This commit is contained in:
parent
7e8aee6f07
commit
12dcab665d
@ -223,7 +223,7 @@ urihandling(char *URI)
|
|||||||
char line[MAXLINE];
|
char line[MAXLINE];
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
strncpy(uri, URI, ARG_MAX);
|
strlcpy(uri, URI, ARG_MAX);
|
||||||
host = uri + 7;
|
host = uri + 7;
|
||||||
|
|
||||||
if ((s = strchr(host, '/')) == NULL) {
|
if ((s = strchr(host, '/')) == NULL) {
|
||||||
@ -320,11 +320,10 @@ setpeer0(char *host, const char *lport)
|
|||||||
/* res->ai_addr <= sizeof(peeraddr) is guaranteed */
|
/* res->ai_addr <= sizeof(peeraddr) is guaranteed */
|
||||||
memcpy(&peer_sock, res->ai_addr, res->ai_addrlen);
|
memcpy(&peer_sock, res->ai_addr, res->ai_addrlen);
|
||||||
if (res->ai_canonname) {
|
if (res->ai_canonname) {
|
||||||
(void) strncpy(hostname, res->ai_canonname,
|
(void) strlcpy(hostname, res->ai_canonname,
|
||||||
sizeof(hostname));
|
sizeof(hostname));
|
||||||
} else
|
} else
|
||||||
(void) strncpy(hostname, host, sizeof(hostname));
|
(void) strlcpy(hostname, host, sizeof(hostname));
|
||||||
hostname[sizeof(hostname)-1] = 0;
|
|
||||||
connected = 1;
|
connected = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user