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;
        }
 
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "[email protected]"

Reply via email to