Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 23 Jul 2009 08:45:20 -0400
From:      John Baldwin <jhb@freebsd.org>
To:        Jaakko Heinonen <jh@saunalahti.fi>
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:  <200907230845.21147.jhb@freebsd.org>
In-Reply-To: <20090723103014.GA2316@a91-153-125-115.elisa-laajakaista.fi>
References:  <200907141945.n6EJjaMC069356@svn.freebsd.org> <20090723103014.GA2316@a91-153-125-115.elisa-laajakaista.fi>

next in thread | previous in thread | raw e-mail | index | archive | help
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



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