Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 22 Sep 2010 21:43:48 +0000 (UTC)
From:      Marius Strobl <marius@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org
Subject:   svn commit: r213034 - stable/7/usr.bin/tftp
Message-ID:  <201009222143.o8MLhma0044577@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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;
 	}
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201009222143.o8MLhma0044577>