From owner-svn-src-all@FreeBSD.ORG Fri Jun 5 08:52:11 2009 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C8789106564A; Fri, 5 Jun 2009 08:52:11 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail02.syd.optusnet.com.au (mail02.syd.optusnet.com.au [211.29.132.183]) by mx1.freebsd.org (Postfix) with ESMTP id 60A0F8FC0C; Fri, 5 Jun 2009 08:52:11 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from c122-106-151-9.carlnfd1.nsw.optusnet.com.au (c122-106-151-9.carlnfd1.nsw.optusnet.com.au [122.106.151.9]) by mail02.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id n558q7Ze012649 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 5 Jun 2009 18:52:08 +1000 Date: Fri, 5 Jun 2009 18:52:07 +1000 (EST) From: Bruce Evans X-X-Sender: bde@delplex.bde.org To: Stanislav Sedov In-Reply-To: <20090605102431.4769115f.stas@FreeBSD.org> Message-ID: <20090605182104.S15688@delplex.bde.org> References: <200906042343.n54Nh8c5008164@svn.freebsd.org> <20090605102431.4769115f.stas@FreeBSD.org> 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, Benno Rice Subject: Re: svn commit: r193475 - head/sbin/kldload X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 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, 05 Jun 2009 08:52:12 -0000 On Fri, 5 Jun 2009, Stanislav Sedov wrote: > On Thu, 4 Jun 2009 23:43:08 +0000 (UTC) > Benno Rice mentioned: >> [... not quoted] The broken pathname lookup and broken path separator should be in the BUGS section (also in kld syscall manpages). The namespace for the `file' parameter of kldload(2) is completely undocumented in kldload.2. It seems to be the same as the usual namespace for files, except for large complications and undocumentations from having the pathname search and the file extension magic in the kernel. >> + if (path == NULL) { >> + err(1, "allocating %lu bytes for the path", >> + (unsigned long)pathlen + 1); > ^^^^^^^^^^^^^^^^^^^^^^ > Why convert pathlen to unsigned long here? The pathlen variable is > of size_t type which is already unsigned and we have the special 'z' prefix > in printf(3) to print those. Well, %z might be wrong since only the pathlen variable is of type size_t. The expression `pathlen + 1' has type: __binarypromoteof(__typeof(pathlen), int)), so if size_t is smaller than int then the promotions are non-null and give a type larger than size_t, and %z is wrong. To use %z, the expression should be written as (size_t)(pathlen + 1). OTOH, the committed version has no type mismatch, since __binarypromoteof(unsigned long, int)) = unsigned long, and all versions should have no problems with overflow in the addition or in the cast since pathlen should be small (even if unsigned long is smaller than size_t, pathlen should be < ULONG_MAX - 1 so that everything fits). Bruce