From owner-svn-src-all@FreeBSD.ORG Thu Jul 23 12:45:33 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 0512A1065677; Thu, 23 Jul 2009 12:45:33 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42]) by mx1.freebsd.org (Postfix) with ESMTP id C9F7C8FC08; Thu, 23 Jul 2009 12:45:32 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from bigwig.baldwin.cx (66.111.2.69.static.nyinternet.net [66.111.2.69]) by cyrus.watson.org (Postfix) with ESMTPSA id 84BDE46B51; Thu, 23 Jul 2009 08:45:32 -0400 (EDT) Received: from jhbbsd.hudson-trading.com (unknown [209.249.190.8]) by bigwig.baldwin.cx (Postfix) with ESMTPA id A539B8A0A2; Thu, 23 Jul 2009 08:45:31 -0400 (EDT) From: John Baldwin To: Jaakko Heinonen Date: Thu, 23 Jul 2009 08:45:20 -0400 User-Agent: KMail/1.9.7 References: <200907141945.n6EJjaMC069356@svn.freebsd.org> <20090723103014.GA2316@a91-153-125-115.elisa-laajakaista.fi> In-Reply-To: <20090723103014.GA2316@a91-153-125-115.elisa-laajakaista.fi> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200907230845.21147.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.0.1 (bigwig.baldwin.cx); Thu, 23 Jul 2009 08:45:31 -0400 (EDT) X-Virus-Scanned: clamav-milter 0.95.1 at bigwig.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-2.5 required=4.2 tests=AWL,BAYES_00,RDNS_NONE autolearn=no version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on bigwig.baldwin.cx Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r195693 - in head: lib/libc/sys sys/vm 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: Thu, 23 Jul 2009 12:45:33 -0000 On Thursday 23 July 2009 6:30:15 am Jaakko Heinonen wrote: > > Hi, > > On 2009-07-14, John Baldwin wrote: > > - Change mmap() to fail requests with EINVAL that pass a length of 0. This > > behavior is mandated by POSIX. > > After this change locate(1) gives an obscure error message for empty > database files. Ah, odd. Perhaps it would be best to just move the original "too small" check earlier: Index: fastfind.c =================================================================== --- fastfind.c (revision 195818) +++ fastfind.c (working copy) @@ -154,9 +154,6 @@ /* init bigram table */ #ifdef FF_MMAP - if (len < (2*NBG)) - errx(1, "database too small: %s", database); - for (c = 0, p = bigram1, s = bigram2; c < NBG; c++, len-= 2) { p[c] = check_bigram_char(*paddr++); s[c] = check_bigram_char(*paddr++); Index: locate.c =================================================================== --- locate.c (revision 195818) +++ locate.c (working copy) @@ -291,6 +291,8 @@ fstat(fd, &sb) == -1) err(1, "`%s'", db); len = sb.st_size; + if (len < (2*NBG)) + errx(1, "database too small: %s", database); if ((p = mmap((caddr_t)0, (size_t)len, PROT_READ, MAP_SHARED, This should be functionally identical. -- John Baldwin