Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 23 Jul 2009 13:30:15 +0300
From:      Jaakko Heinonen <jh@saunalahti.fi>
To:        John Baldwin <jhb@FreeBSD.org>
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
Message-ID:  <20090723103014.GA2316@a91-153-125-115.elisa-laajakaista.fi>
In-Reply-To: <200907141945.n6EJjaMC069356@svn.freebsd.org>
References:  <200907141945.n6EJjaMC069356@svn.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help

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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20090723103014.GA2316>