From owner-svn-src-all@FreeBSD.ORG Fri Jan 4 20:38:37 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 3397914E; Fri, 4 Jan 2013 20:38:37 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42]) by mx1.freebsd.org (Postfix) with ESMTP id F0D71805; Fri, 4 Jan 2013 20:38:36 +0000 (UTC) Received: from fledge.watson.org (fledge.watson.org [65.122.17.41]) by cyrus.watson.org (Postfix) with ESMTPS id B6F9D46B3C; Fri, 4 Jan 2013 15:38:32 -0500 (EST) Date: Fri, 4 Jan 2013 20:38:32 +0000 (GMT) From: Robert Watson X-X-Sender: robert@fledge.watson.org To: Mateusz Guzik Subject: Re: svn commit: r245036 - head/sys/kern In-Reply-To: <20130104113354.GB26239@dft-labs.eu> Message-ID: References: <201301041111.r04BBDjZ013380@svn.freebsd.org> <20130104113354.GB26239@dft-labs.eu> User-Agent: Alpine 2.00 (BSF 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, David Xu X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 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, 04 Jan 2013 20:38:37 -0000 On Fri, 4 Jan 2013, Mateusz Guzik wrote: > On Fri, Jan 04, 2013 at 11:11:13AM +0000, David Xu wrote: >> Author: davidxu >> Date: Fri Jan 4 11:11:12 2013 >> New Revision: 245036 >> URL: http://svnweb.freebsd.org/changeset/base/245036 >> >> Log: >> Revert revision 244760 because strncpy pads trailing space with zero, >> this prevents kernel data from being leaked. > > I think it would be better to teach strlcpy to zero-pad as well. I'd rather we created new functions with new names that add the non-portable zeroing behaviour -- perhaps strlpcpy() and strnpcpy(), or something equally incomprehensible. This semantic may actually trigger bugs in code that is correct (albeit badly written) using strncpy() and strlcpy() in a way that never fully fills the buffer (due to some external invariant) and has an incorrect bounds check -- and potentially trigger performance problems when target buffers are much larger than the copied data. Robert