From owner-svn-src-stable@FreeBSD.ORG Thu Feb 10 00:20:57 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 34245106564A; Thu, 10 Feb 2011 00:20:57 +0000 (UTC) (envelope-from mlaier@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 212B78FC08; Thu, 10 Feb 2011 00:20:57 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p1A0KvRI002876; Thu, 10 Feb 2011 00:20:57 GMT (envelope-from mlaier@svn.freebsd.org) Received: (from mlaier@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p1A0KvmS002874; Thu, 10 Feb 2011 00:20:57 GMT (envelope-from mlaier@svn.freebsd.org) Message-Id: <201102100020.p1A0KvmS002874@svn.freebsd.org> From: Max Laier Date: Thu, 10 Feb 2011 00:20:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r218502 - stable/7/sys/kern X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Feb 2011 00:20:57 -0000 Author: mlaier Date: Thu Feb 10 00:20:56 2011 New Revision: 218502 URL: http://svn.freebsd.org/changeset/base/218502 Log: MFH: r180238 Use bcopy instead of strlcpy in uipc_bind and unp_connect, since soun->sun_path isn't a null-terminated string. As UNIX(4) states, "the terminating NUL is not part of the address." Since strlcpy has to return "the total length of the string [it] tried to create," it walks off the end of soun->sun_path looking for a \0. This reverts r105332. Modified: stable/7/sys/kern/uipc_usrreq.c Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/kern/uipc_usrreq.c ============================================================================== --- stable/7/sys/kern/uipc_usrreq.c Thu Feb 10 00:05:11 2011 (r218501) +++ stable/7/sys/kern/uipc_usrreq.c Thu Feb 10 00:20:56 2011 (r218502) @@ -421,7 +421,8 @@ uipc_bind(struct socket *so, struct sock UNP_PCB_UNLOCK(unp); buf = malloc(namelen + 1, M_TEMP, M_WAITOK); - strlcpy(buf, soun->sun_path, namelen + 1); + bcopy(soun->sun_path, buf, namelen); + buf[namelen] = 0; restart: vfslocked = 0; @@ -1144,7 +1145,8 @@ unp_connect(struct socket *so, struct so len = nam->sa_len - offsetof(struct sockaddr_un, sun_path); if (len <= 0) return (EINVAL); - strlcpy(buf, soun->sun_path, len + 1); + bcopy(soun->sun_path, buf, len); + buf[len] = 0; UNP_PCB_LOCK(unp); if (unp->unp_flags & UNP_CONNECTING) {