svn commit: r183857 - head/usr.bin/tftp

Xin LI delphij at FreeBSD.org
Mon Oct 13 22:50:38 UTC 2008


Author: delphij
Date: Mon Oct 13 22:50:38 2008
New Revision: 183857
URL: http://svn.freebsd.org/changeset/base/183857

Log:
  Use strlcpy() instead of strncpy() when we want the string to be
  NUL-terminated.

Modified:
  head/usr.bin/tftp/main.c

Modified: head/usr.bin/tftp/main.c
==============================================================================
--- head/usr.bin/tftp/main.c	Mon Oct 13 22:04:41 2008	(r183856)
+++ head/usr.bin/tftp/main.c	Mon Oct 13 22:50:38 2008	(r183857)
@@ -233,11 +233,10 @@ setpeer0(host, port)
 		/* res->ai_addr <= sizeof(peeraddr) is guaranteed */
 		memcpy(&peeraddr, 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;
 	}
 


More information about the svn-src-head mailing list