From owner-svn-src-head@FreeBSD.ORG Thu Jul 23 10:45:20 2009 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BE2651065676; Thu, 23 Jul 2009 10:45:20 +0000 (UTC) (envelope-from jh@saunalahti.fi) Received: from gw02.mail.saunalahti.fi (gw02.mail.saunalahti.fi [195.197.172.116]) by mx1.freebsd.org (Postfix) with ESMTP id 7BEED8FC1D; Thu, 23 Jul 2009 10:45:20 +0000 (UTC) (envelope-from jh@saunalahti.fi) Received: from a91-153-125-115.elisa-laajakaista.fi (a91-153-125-115.elisa-laajakaista.fi [91.153.125.115]) by gw02.mail.saunalahti.fi (Postfix) with SMTP id 6657D13971E; Thu, 23 Jul 2009 13:30:15 +0300 (EEST) Date: Thu, 23 Jul 2009 13:30:15 +0300 From: Jaakko Heinonen To: John Baldwin Message-ID: <20090723103014.GA2316@a91-153-125-115.elisa-laajakaista.fi> References: <200907141945.n6EJjaMC069356@svn.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200907141945.n6EJjaMC069356@svn.freebsd.org> User-Agent: Mutt/1.5.19 (2009-01-05) 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-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Jul 2009 10:45:21 -0000 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. Before: $ locate -d /dev/null foo locate: database too small: /dev/null After: $ locate -d /dev/null foo locate: mmap ``/dev/null'': Invalid argument Here's a patch to restore the behavior. %%% Index: usr.bin/locate/locate/locate.c =================================================================== --- usr.bin/locate/locate/locate.c (revision 195811) +++ usr.bin/locate/locate/locate.c (working copy) @@ -292,6 +292,9 @@ search_mmap(db, s) err(1, "`%s'", db); len = sb.st_size; + if (len == 0) + errx(1, "database too small: %s", db); + if ((p = mmap((caddr_t)0, (size_t)len, PROT_READ, MAP_SHARED, fd, (off_t)0)) == MAP_FAILED) %%% -- Jaakko