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;
        }
 
_______________________________________________
[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