delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/04/11/10:47:10

Date: Wed, 11 Apr 2001 17:42:52 +0300
From: "Eli Zaretskii" <eliz AT is DOT elta DOT co DOT il>
Sender: halo1 AT zahav DOT net DOT il
To: Daniel Taupin <taupin AT lps DOT u-psud DOT fr>
Message-Id: <6137-Wed11Apr2001174250+0300-eliz@is.elta.co.il>
X-Mailer: Emacs 20.6 (via feedmail 8.3.emacs20_6 I) and Blat ver 1.8.9
CC: djgpp AT delorie DOT com
In-reply-to: <3AD3CA93.4DA31C76@lps.u-psud.fr> (message from Daniel Taupin on
Tue, 10 Apr 2001 20:08:03 -0700)
Subject: Re: locate.exe
References: <3AD3CA93 DOT 4DA31C76 AT lps DOT u-psud DOT fr>
Reply-To: djgpp AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

> Date: Tue, 10 Apr 2001 20:08:03 -0700
> From: Daniel Taupin <taupin AT lps DOT u-psud DOT fr>
> 
>  Finally, I find out thet locate.exe works perfectly... when the
> database is not too big. In fact, when I run
> 
> updatedb c:/     (where c: is a 34 Gigabyte disk with a lot of files)
> 
> then locate crashes with a page fault. But, when I run updatedb on a
> limited number of files, it runs OK. I shall look whether I'm able to
> correct that.

Running `locate' under GDB reveals the problem.  It has nothing to do
with the size of the data base; it's a simple bug in `locate'.

The bug is that `locate' doesn't handle correctly negative
offset-differential counts which are less than -127, and which thus
require more than one byte to store in the data base.  (If this
doesn't make sense, read the locatedb.5 man page which comes with
Findutils, where it describes how file names are recorded in the data
base.)  It so happens that your locatedb.dat file includes exactly one
such negative count, and that's where `locate' crashes.  The
probability to see such large negative counts is very low, but very
long file names sometimes cause that to happen.  And your disk has a
couple of extremely long file names which approach the Windows limit
of 260 characters.

The simple patch below solves the problem.  I think this is a known
bug in Findutils 4.1; the latest pretest of the next version of
Findutils (which someone should consider porting to DJGPP) probably
already corrects it.

--- locate/locate.c~0	Sat Apr  6 21:09:06 1996
+++ locate/locate.c	Wed Apr 11 17:10:02 2001
@@ -272,7 +272,13 @@ locate (pathpart, dbfile)
       else
 	{
 	  if (c == LOCATEDB_ESCAPE)
-	    count += get_short (fp);
+	    {
+	      int c2 = get_short (fp);
+
+	      if (c2 > 32767)
+		c2 -= 65536;
+	      count += c2;
+	    }
 	  else if (c > 127)
 	    count += c - 256;
 	  else

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019