summaryrefslogtreecommitdiffstats
path: root/usr.bin/tftp
diff options
context:
space:
mode:
authordelphij <delphij@FreeBSD.org>2015-08-31 06:11:39 +0000
committerdelphij <delphij@FreeBSD.org>2015-08-31 06:11:39 +0000
commit12dcab665d5b5bd29c665ef247cac3dd2235fae0 (patch)
treedf1e33e4a303db28af370ea492baf8de87700688 /usr.bin/tftp
parent7e8aee6f078850c495107305a3bc47878520c5e6 (diff)
downloadFreeBSD-src-12dcab665d5b5bd29c665ef247cac3dd2235fae0.zip
FreeBSD-src-12dcab665d5b5bd29c665ef247cac3dd2235fae0.tar.gz
- 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
Diffstat (limited to 'usr.bin/tftp')
-rw-r--r--usr.bin/tftp/main.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/usr.bin/tftp/main.c b/usr.bin/tftp/main.c
index 7db7818..7d97a75 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;
}
OpenPOWER on IntegriCloud