diff options
author | delphij <delphij@FreeBSD.org> | 2015-09-14 18:57:50 +0000 |
---|---|---|
committer | delphij <delphij@FreeBSD.org> | 2015-09-14 18:57:50 +0000 |
commit | 9a0c37807b682e26999788441b1803bb5916fd0a (patch) | |
tree | dfda9cdfc2c58ab039faeb9c59b160a9d4fb9e7e /usr.bin/tftp | |
parent | 3908360148557bd45707eb4f4eba0d4a78d72f64 (diff) | |
download | FreeBSD-src-9a0c37807b682e26999788441b1803bb5916fd0a.zip FreeBSD-src-9a0c37807b682e26999788441b1803bb5916fd0a.tar.gz |
MFC r287320:
- uri is expected to be nul-terminated (strchr used later),
so use strlcpy instead of strncpy.
- replace the other two cases of strncpy+\0 with strlcpy.
Diffstat (limited to 'usr.bin/tftp')
-rw-r--r-- | usr.bin/tftp/main.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/usr.bin/tftp/main.c b/usr.bin/tftp/main.c index c0f5088..49bd62a 100644 --- a/usr.bin/tftp/main.c +++ b/usr.bin/tftp/main.c @@ -223,7 +223,7 @@ urihandling(char *URI) char line[MAXLINE]; int i; - strncpy(uri, URI, ARG_MAX); + strlcpy(uri, URI, ARG_MAX); host = uri + 7; if ((s = strchr(host, '/')) == NULL) { @@ -320,11 +320,10 @@ setpeer0(char *host, const char *lport) /* res->ai_addr <= sizeof(peeraddr) is guaranteed */ memcpy(&peer_sock, res->ai_addr, res->ai_addrlen); if (res->ai_canonname) { - (void) strncpy(hostname, res->ai_canonname, + (void) strlcpy(hostname, res->ai_canonname, sizeof(hostname)); } else - (void) strncpy(hostname, host, sizeof(hostname)); - hostname[sizeof(hostname)-1] = 0; + (void) strlcpy(hostname, host, sizeof(hostname)); connected = 1; } |