Date: Mon, 13 Oct 2008 22:50:38 +0000 (UTC) From: Xin LI <delphij@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r183857 - head/usr.bin/tftp Message-ID: <200810132250.m9DMocb1088816@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
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; }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200810132250.m9DMocb1088816>