aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/locate
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2009-07-24 13:40:25 +0000
committerJohn Baldwin <jhb@FreeBSD.org>2009-07-24 13:40:25 +0000
commit29985e350dfa6d71c0a97e352d5b1019468f9e58 (patch)
tree0ecaf447bb33b2b1bdde8d4d53fead7bfeb0be83 /usr.bin/locate
parent7cf8b4b9335f3632051e32a9819e87c663ee70d2 (diff)
downloadsrc-29985e350dfa6d71c0a97e352d5b1019468f9e58.tar.gz
src-29985e350dfa6d71c0a97e352d5b1019468f9e58.zip
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. Submitted by: Jaakko Heinonen jh of saunalahti dot fi Approved by: re (kensmith) MFC after: 1 week
Notes
Notes: svn path=/head/; revision=195839
Diffstat (limited to 'usr.bin/locate')
-rw-r--r--usr.bin/locate/locate/fastfind.c3
-rw-r--r--usr.bin/locate/locate/locate.c2
2 files changed, 2 insertions, 3 deletions
diff --git a/usr.bin/locate/locate/fastfind.c b/usr.bin/locate/locate/fastfind.c
index d9ab2d0fe140..21148bc6e884 100644
--- a/usr.bin/locate/locate/fastfind.c
+++ b/usr.bin/locate/locate/fastfind.c
@@ -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++);
diff --git a/usr.bin/locate/locate/locate.c b/usr.bin/locate/locate/locate.c
index d7529fbd88a2..67a97da78202 100644
--- a/usr.bin/locate/locate/locate.c
+++ b/usr.bin/locate/locate/locate.c
@@ -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,