NetBSD Problem Report #987

From gnats  Mon Apr 24 11:02:27 1995
Received: from eunet.fi (eunet.fi [192.26.119.1]) by sun-lamp.cs.berkeley.edu (8.6.10/8.6.10) with SMTP id LAA00424 for <gnats-bugs@sun-lamp.cs.berkeley.edu>; Mon, 24 Apr 1995 11:02:20 -0700
Message-Id: <199504231409.RAA00936@araneus.pp.fi>
Date: Sun, 23 Apr 1995 17:09:59 +0300
From: Andreas Gustafsson <gson@araneus.pp.fi>
Reply-To: gson@araneus.pp.fi
To: gnats-bugs@sun-lamp.cs.berkeley.edu
Subject: locate database corruption when file names contain 8-bit chars
X-Send-Pr-Version: 3.2

>Number:         987
>Category:       bin
>Synopsis:       locate database corruption when file names contain 8-bit chars
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Apr 24 11:05:06 +0000 1995
>Closed-Date:    Fri May 05 23:39:16 +0000 1995
>Last-Modified:  Tue Sep 04 23:25:08 +0000 2001
>Originator:     Andreas Gustafsson
>Release:        NetBSD-current snapshot of around March 17, 1995
>Organization:
Araneus Information Systems Oy
>Environment:

System: NetBSD araneus.pp.fi 1.0A NetBSD 1.0A (GUANO) #3: Wed Apr 12 17:21:06 EET DST 1995 gson@araneus.pp.fi:/usr/src/sys/arch/i386/compile/GUANO i386

>Description:

When locate.updatedb is used to index a file system where some
file names contain characters whose character code is in the range
0x80 - 0x9F, it will build a corrupted /var/db/locate.database.

>How-To-Repeat:

1. Create a file with a funny enough name, e.g. using

    awk 'BEGIN { s = sprintf("foo%cbar", 132); print > s }' </dev/null

2. Run locate.updatedb

3. Try to find some other files using locate and watch it fail to 
   find some of them and/or print garbage pathnames (depending 
   on the relative positions of the files in the database, in 
   a rather unpredictable manner).

>Fix:

Not one, but two.  First, a minimal fix which I think reflects the
intent of the original programmer:

*** locate.code.c.orig	Thu Dec 22 14:35:10 1994
--- locate.code.c	Sun Apr 23 16:35:59 1995
***************
*** 144,150 ****
  		for (cp = path; *cp != NULL; cp++) {
  			if ((u_char)*cp >= PARITY)
  				*cp &= PARITY-1;
! 			else if (*cp <= SWITCH)
  				*cp = '?';
  		}

--- 144,150 ----
  		for (cp = path; *cp != NULL; cp++) {
  			if ((u_char)*cp >= PARITY)
  				*cp &= PARITY-1;
! 			if (*cp <= SWITCH)
  				*cp = '?';
  		}


Second, an alternative fix which I personally prefer due to its simple
and consistent treatment of both kinds of illegal characters.


*** locate.code.c.orig	Thu Dec 22 14:35:10 1994
--- locate.code.c	Sun Apr 23 16:49:08 1995
***************
*** 142,150 ****

  		/* Squelch characters that would botch the decoding. */
  		for (cp = path; *cp != NULL; cp++) {
! 			if ((u_char)*cp >= PARITY)
! 				*cp &= PARITY-1;
! 			else if (*cp <= SWITCH)
  				*cp = '?';
  		}

--- 142,148 ----

  		/* Squelch characters that would botch the decoding. */
  		for (cp = path; *cp != NULL; cp++) {
! 			if ((u_char)*cp >= PARITY || (u_char)*cp <= SWITCH)
  				*cp = '?';
  		}

>Release-Note:
>Audit-Trail:

State-Changed-From-To: open->closed
State-Changed-By: jtc
State-Changed-When: Fri May  5 23:39:16 1995
State-Changed-Why:
Applied fix similar, but not identical to, the first patch.
>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.