Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 24 Jul 2009 18:45:01 +0100 (BST)
From:      Robert Watson <rwatson@FreeBSD.org>
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: r195839 - head/usr.bin/locate/locate
Message-ID:  <alpine.BSF.2.00.0907241843580.5967@fledge.watson.org>
In-Reply-To: <200907241340.n6ODeP2B011222@svn.freebsd.org>
References:  <200907241340.n6ODeP2B011222@svn.freebsd.org>

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

On Fri, 24 Jul 2009, John Baldwin wrote:

>  Move the check to ensure the locate database has the minimum required size
>  when using mmap() before invoking mmap().  This avoids a confusing error
>  message when locate is invoked against a zero-size database after the
>  recent change to make mmap() fail requests to map 0 bytes.

Does this mean we should anticipate other possible application compatibility 
problems?  And I guess that means a 7.2 userspace (i.e., jail) on an 8.0 
kernel won't support locate?

Robert

>
>  Submitted by:	Jaakko Heinonen  jh of saunalahti dot fi
>  Approved by:	re (kensmith)
>  MFC after:	1 week
>
> Modified:
>  head/usr.bin/locate/locate/fastfind.c
>  head/usr.bin/locate/locate/locate.c
>
> Modified: head/usr.bin/locate/locate/fastfind.c
> ==============================================================================
> --- head/usr.bin/locate/locate/fastfind.c	Thu Jul 23 21:12:21 2009	(r195838)
> +++ head/usr.bin/locate/locate/fastfind.c	Fri Jul 24 13:40:25 2009	(r195839)
> @@ -154,9 +154,6 @@ fastfind
>
> 	/* 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++);
>
> Modified: head/usr.bin/locate/locate/locate.c
> ==============================================================================
> --- head/usr.bin/locate/locate/locate.c	Thu Jul 23 21:12:21 2009	(r195838)
> +++ head/usr.bin/locate/locate/locate.c	Fri Jul 24 13:40:25 2009	(r195839)
> @@ -291,6 +291,8 @@ search_mmap(db, s)
> 	    fstat(fd, &sb) == -1)
> 		err(1, "`%s'", db);
> 	len = sb.st_size;
> +	if (len < (2*NBG))
> +		errx(1, "database too small: %s", db);
>
> 	if ((p = mmap((caddr_t)0, (size_t)len,
> 		      PROT_READ, MAP_SHARED,
>



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