From owner-svn-src-stable@FreeBSD.ORG Thu Aug 13 15:00:18 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id ED65710656EE; Thu, 13 Aug 2009 15:00:18 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id DA5EF8FC43; Thu, 13 Aug 2009 15:00:18 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n7DF0IHa004401; Thu, 13 Aug 2009 15:00:18 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n7DF0Iaf004398; Thu, 13 Aug 2009 15:00:18 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <200908131500.n7DF0Iaf004398@svn.freebsd.org> From: John Baldwin Date: Thu, 13 Aug 2009 15:00:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196186 - in stable/7/usr.bin/locate: . locate X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Aug 2009 15:00:20 -0000 Author: jhb Date: Thu Aug 13 15:00:18 2009 New Revision: 196186 URL: http://svn.freebsd.org/changeset/base/196186 Log: MFC: Move the check to ensure the locate database has the minimum required size when using mmap() before invoking mmap(). Modified: stable/7/usr.bin/locate/ (props changed) stable/7/usr.bin/locate/locate/fastfind.c stable/7/usr.bin/locate/locate/locate.c Modified: stable/7/usr.bin/locate/locate/fastfind.c ============================================================================== --- stable/7/usr.bin/locate/locate/fastfind.c Thu Aug 13 14:59:04 2009 (r196185) +++ stable/7/usr.bin/locate/locate/fastfind.c Thu Aug 13 15:00:18 2009 (r196186) @@ -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: stable/7/usr.bin/locate/locate/locate.c ============================================================================== --- stable/7/usr.bin/locate/locate/locate.c Thu Aug 13 14:59:04 2009 (r196185) +++ stable/7/usr.bin/locate/locate/locate.c Thu Aug 13 15:00:18 2009 (r196186) @@ -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,