svn commit: r213034 - stable/7/usr.bin/tftp

Marius Strobl marius at FreeBSD.org
Wed Sep 22 21:43:49 UTC 2010


Author: marius
Date: Wed Sep 22 21:43:48 2010
New Revision: 213034
URL: http://svn.freebsd.org/changeset/base/213034

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

Modified:
  stable/7/usr.bin/tftp/main.c
Directory Properties:
  stable/7/usr.bin/tftp/   (props changed)

Modified: stable/7/usr.bin/tftp/main.c
==============================================================================
--- stable/7/usr.bin/tftp/main.c	Wed Sep 22 21:14:18 2010	(r213033)
+++ stable/7/usr.bin/tftp/main.c	Wed Sep 22 21:43:48 2010	(r213034)
@@ -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-all mailing list