From owner-svn-src-all@freebsd.org Fri Feb 24 11:30:29 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id DE427CEA50B; Fri, 24 Feb 2017 11:30:29 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A7D0C149C; Fri, 24 Feb 2017 11:30:29 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v1OBUSNH017887; Fri, 24 Feb 2017 11:30:28 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v1OBUS3G017886; Fri, 24 Feb 2017 11:30:28 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201702241130.v1OBUS3G017886@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Fri, 24 Feb 2017 11:30:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r314201 - stable/10/sys/fs/nfsclient X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 24 Feb 2017 11:30:30 -0000 Author: kib Date: Fri Feb 24 11:30:28 2017 New Revision: 314201 URL: https://svnweb.freebsd.org/changeset/base/314201 Log: MFC r313800: Do not access memory past the buffer end. Do not accept and silently truncate too long hostname. Modified: stable/10/sys/fs/nfsclient/nfs_clvfsops.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/fs/nfsclient/nfs_clvfsops.c ============================================================================== --- stable/10/sys/fs/nfsclient/nfs_clvfsops.c Fri Feb 24 11:25:32 2017 (r314200) +++ stable/10/sys/fs/nfsclient/nfs_clvfsops.c Fri Feb 24 11:30:28 2017 (r314201) @@ -1149,8 +1149,13 @@ nfs_mount(struct mount *mp) error = EINVAL; goto out; } - bcopy(args.hostname, hst, MNAMELEN); - hst[MNAMELEN - 1] = '\0'; + if (len >= MNAMELEN) { + vfs_mount_error(mp, "Hostname too long"); + error = EINVAL; + goto out; + } + bcopy(args.hostname, hst, len); + hst[len] = '\0'; } if (vfs_getopt(mp->mnt_optnew, "principal", (void **)&name, NULL) == 0)