Date: Mon, 14 Sep 2015 18:57:51 +0000 (UTC) From: Xin LI <delphij@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r287795 - stable/10/usr.bin/tftp Message-ID: <201509141857.t8EIvpC3017628@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: delphij Date: Mon Sep 14 18:57:50 2015 New Revision: 287795 URL: https://svnweb.freebsd.org/changeset/base/287795 Log: MFC r287320: - uri is expected to be nul-terminated (strchr used later), so use strlcpy instead of strncpy. - replace the other two cases of strncpy+\0 with strlcpy. Modified: stable/10/usr.bin/tftp/main.c Directory Properties: stable/10/ (props changed) Modified: stable/10/usr.bin/tftp/main.c ============================================================================== --- stable/10/usr.bin/tftp/main.c Mon Sep 14 18:52:41 2015 (r287794) +++ stable/10/usr.bin/tftp/main.c Mon Sep 14 18:57:50 2015 (r287795) @@ -223,7 +223,7 @@ urihandling(char *URI) char line[MAXLINE]; int i; - strncpy(uri, URI, ARG_MAX); + strlcpy(uri, URI, ARG_MAX); host = uri + 7; if ((s = strchr(host, '/')) == NULL) { @@ -320,11 +320,10 @@ setpeer0(char *host, const char *lport) /* res->ai_addr <= sizeof(peeraddr) is guaranteed */ memcpy(&peer_sock, 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?201509141857.t8EIvpC3017628>