History log of /openbsd-current/usr.bin/locate/locate/fastfind.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.17 28-Apr-2023 tb

Make LLVM 15 happier by changing from K&R to ANSI prototypes


Revision tags: OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE OPENBSD_7_1_BASE OPENBSD_7_2_BASE OPENBSD_7_3_BASE
# 1.16 17-Jan-2019 tedu

delete some historic $Id that have been chewed on by cvs
ok millert mpi


# 1.15 14-Jan-2019 schwarze

Untimely spring cleaning:
* Garbage collect useless hand-rolled lookup tables.
* Merge one-line helper functions into callers.
* Garbage collect obfuscating macros.
* Fix one format string error (%d used for u_int).
* Garbage collect setlocale(3) and <locale.h>.
* Garbage collect several unused constants.
* Minus 45 LOC, no functional change.

As noticed by tedu@, the lookup table "table" was used uninitialized.
But since it was only used as a pre-matching optimization and the real
string comparison is done further down the line, that bug probably did
not cause wrong results but merely ruined -i performance.

Code review triggered by a naive question from Jan Stary.
OK deraadt@ tedu@


Revision tags: OPENBSD_6_3_BASE OPENBSD_6_4_BASE
# 1.14 08-Dec-2017 millert

Add missing length checks to make sure we don't dereference a pointer
past the mmap(2)'d buffer. Otherwise, locate will read a single
byte past the end of the buffer. This is often harmless, but if
the length of the buffer is an even multiple of the page size,
locate will crash. OK tb@ espie@ deraadt@


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE
# 1.13 23-Oct-2015 tedu

mmap is the default. it's effectively the only tested codepath. so burn down
the stdio code path.
pros: everything is simpler. how can anyone read code this heavily spliced
with ifdef?
cons: you can't pipe a database into locate. who does this???
ok deraadt


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.12 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.11 25-Oct-2010 millert

Add missing FNM_CASEFOLD flag to fnmatch() when locate is run in case
insensitive mode. From Geoff Steckel. OK deraadt@


Revision tags: OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE
# 1.10 04-Jun-2009 espie

error out if count gets out of bounds. Happens with corrupted databases,
better than a buffer underflow and a segfault.
okay millert@


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE
# 1.9 26-Jul-2008 pyr

Add -b switch for matching on the last part of the path only.

ok landry@, otto liked the idea and the original diff, ``do it'' deraadt@


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE OPENBSD_3_7_BASE OPENBSD_3_8_BASE OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.8 29-Sep-2003 deraadt

knf


Revision tags: OPENBSD_3_4_BASE
# 1.7 03-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_3_1_BASE OPENBSD_3_2_BASE OPENBSD_3_3_BASE
# 1.6 19-Nov-2001 mpech

kill more registers

millert@ ok


Revision tags: OPENBSD_2_4_BASE OPENBSD_2_5_BASE OPENBSD_2_6_BASE OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE OPENBSD_3_0_BASE
# 1.5 24-Jul-1998 deraadt

fix spelling; aaron@ug.cs.dal.ca


Revision tags: OPENBSD_2_1_BASE OPENBSD_2_2_BASE OPENBSD_2_3_BASE
# 1.4 17-Jan-1997 millert

r?index -> strr?chr


# 1.3 20-Oct-1996 michaels

8-Bit character support. From wosch@freebsd.


# 1.2 10-Oct-1996 michaels

Fix searching for shell quoting characters. From wosch@freebsd.


Revision tags: OPENBSD_2_0_BASE
# 1.1 15-Sep-1996 michaels

Blind update of wosch@FreeBSD's code:

optimized search algorithm
faster IO due mmap(2) [-m | -s]
better error check for damaged databases
support for databases in network byte order (SunOS/sparc)
optional case insensitve search [-i]
optional multiple databases
optional multiple pattern
new enviroment variable LOCATE_PATH for database(s)
[-S] print some statistic about the database
[-l number] limit output to number file names
[-c] suppress normal output; instead print a count of matching file names
fix prototypes/forward declarations/return type


# 1.16 17-Jan-2019 tedu

delete some historic $Id that have been chewed on by cvs
ok millert mpi


# 1.15 14-Jan-2019 schwarze

Untimely spring cleaning:
* Garbage collect useless hand-rolled lookup tables.
* Merge one-line helper functions into callers.
* Garbage collect obfuscating macros.
* Fix one format string error (%d used for u_int).
* Garbage collect setlocale(3) and <locale.h>.
* Garbage collect several unused constants.
* Minus 45 LOC, no functional change.

As noticed by tedu@, the lookup table "table" was used uninitialized.
But since it was only used as a pre-matching optimization and the real
string comparison is done further down the line, that bug probably did
not cause wrong results but merely ruined -i performance.

Code review triggered by a naive question from Jan Stary.
OK deraadt@ tedu@


Revision tags: OPENBSD_6_3_BASE OPENBSD_6_4_BASE
# 1.14 08-Dec-2017 millert

Add missing length checks to make sure we don't dereference a pointer
past the mmap(2)'d buffer. Otherwise, locate will read a single
byte past the end of the buffer. This is often harmless, but if
the length of the buffer is an even multiple of the page size,
locate will crash. OK tb@ espie@ deraadt@


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE
# 1.13 23-Oct-2015 tedu

mmap is the default. it's effectively the only tested codepath. so burn down
the stdio code path.
pros: everything is simpler. how can anyone read code this heavily spliced
with ifdef?
cons: you can't pipe a database into locate. who does this???
ok deraadt


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.12 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.11 25-Oct-2010 millert

Add missing FNM_CASEFOLD flag to fnmatch() when locate is run in case
insensitive mode. From Geoff Steckel. OK deraadt@


Revision tags: OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE
# 1.10 04-Jun-2009 espie

error out if count gets out of bounds. Happens with corrupted databases,
better than a buffer underflow and a segfault.
okay millert@


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE
# 1.9 26-Jul-2008 pyr

Add -b switch for matching on the last part of the path only.

ok landry@, otto liked the idea and the original diff, ``do it'' deraadt@


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE OPENBSD_3_7_BASE OPENBSD_3_8_BASE OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.8 29-Sep-2003 deraadt

knf


Revision tags: OPENBSD_3_4_BASE
# 1.7 03-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_3_1_BASE OPENBSD_3_2_BASE OPENBSD_3_3_BASE
# 1.6 19-Nov-2001 mpech

kill more registers

millert@ ok


Revision tags: OPENBSD_2_4_BASE OPENBSD_2_5_BASE OPENBSD_2_6_BASE OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE OPENBSD_3_0_BASE
# 1.5 24-Jul-1998 deraadt

fix spelling; aaron@ug.cs.dal.ca


Revision tags: OPENBSD_2_1_BASE OPENBSD_2_2_BASE OPENBSD_2_3_BASE
# 1.4 17-Jan-1997 millert

r?index -> strr?chr


# 1.3 20-Oct-1996 michaels

8-Bit character support. From wosch@freebsd.


# 1.2 10-Oct-1996 michaels

Fix searching for shell quoting characters. From wosch@freebsd.


Revision tags: OPENBSD_2_0_BASE
# 1.1 15-Sep-1996 michaels

Blind update of wosch@FreeBSD's code:

optimized search algorithm
faster IO due mmap(2) [-m | -s]
better error check for damaged databases
support for databases in network byte order (SunOS/sparc)
optional case insensitve search [-i]
optional multiple databases
optional multiple pattern
new enviroment variable LOCATE_PATH for database(s)
[-S] print some statistic about the database
[-l number] limit output to number file names
[-c] suppress normal output; instead print a count of matching file names
fix prototypes/forward declarations/return type


# 1.15 14-Jan-2019 schwarze

Untimely spring cleaning:
* Garbage collect useless hand-rolled lookup tables.
* Merge one-line helper functions into callers.
* Garbage collect obfuscating macros.
* Fix one format string error (%d used for u_int).
* Garbage collect setlocale(3) and <locale.h>.
* Garbage collect several unused constants.
* Minus 45 LOC, no functional change.

As noticed by tedu@, the lookup table "table" was used uninitialized.
But since it was only used as a pre-matching optimization and the real
string comparison is done further down the line, that bug probably did
not cause wrong results but merely ruined -i performance.

Code review triggered by a naive question from Jan Stary.
OK deraadt@ tedu@


Revision tags: OPENBSD_6_3_BASE OPENBSD_6_4_BASE
# 1.14 08-Dec-2017 millert

Add missing length checks to make sure we don't dereference a pointer
past the mmap(2)'d buffer. Otherwise, locate will read a single
byte past the end of the buffer. This is often harmless, but if
the length of the buffer is an even multiple of the page size,
locate will crash. OK tb@ espie@ deraadt@


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE
# 1.13 23-Oct-2015 tedu

mmap is the default. it's effectively the only tested codepath. so burn down
the stdio code path.
pros: everything is simpler. how can anyone read code this heavily spliced
with ifdef?
cons: you can't pipe a database into locate. who does this???
ok deraadt


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.12 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.11 25-Oct-2010 millert

Add missing FNM_CASEFOLD flag to fnmatch() when locate is run in case
insensitive mode. From Geoff Steckel. OK deraadt@


Revision tags: OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE
# 1.10 04-Jun-2009 espie

error out if count gets out of bounds. Happens with corrupted databases,
better than a buffer underflow and a segfault.
okay millert@


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE
# 1.9 26-Jul-2008 pyr

Add -b switch for matching on the last part of the path only.

ok landry@, otto liked the idea and the original diff, ``do it'' deraadt@


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE OPENBSD_3_7_BASE OPENBSD_3_8_BASE OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.8 29-Sep-2003 deraadt

knf


Revision tags: OPENBSD_3_4_BASE
# 1.7 03-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_3_1_BASE OPENBSD_3_2_BASE OPENBSD_3_3_BASE
# 1.6 19-Nov-2001 mpech

kill more registers

millert@ ok


Revision tags: OPENBSD_2_4_BASE OPENBSD_2_5_BASE OPENBSD_2_6_BASE OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE OPENBSD_3_0_BASE
# 1.5 24-Jul-1998 deraadt

fix spelling; aaron@ug.cs.dal.ca


Revision tags: OPENBSD_2_1_BASE OPENBSD_2_2_BASE OPENBSD_2_3_BASE
# 1.4 17-Jan-1997 millert

r?index -> strr?chr


# 1.3 20-Oct-1996 michaels

8-Bit character support. From wosch@freebsd.


# 1.2 10-Oct-1996 michaels

Fix searching for shell quoting characters. From wosch@freebsd.


Revision tags: OPENBSD_2_0_BASE
# 1.1 15-Sep-1996 michaels

Blind update of wosch@FreeBSD's code:

optimized search algorithm
faster IO due mmap(2) [-m | -s]
better error check for damaged databases
support for databases in network byte order (SunOS/sparc)
optional case insensitve search [-i]
optional multiple databases
optional multiple pattern
new enviroment variable LOCATE_PATH for database(s)
[-S] print some statistic about the database
[-l number] limit output to number file names
[-c] suppress normal output; instead print a count of matching file names
fix prototypes/forward declarations/return type


# 1.14 08-Dec-2017 millert

Add missing length checks to make sure we don't dereference a pointer
past the mmap(2)'d buffer. Otherwise, locate will read a single
byte past the end of the buffer. This is often harmless, but if
the length of the buffer is an even multiple of the page size,
locate will crash. OK tb@ espie@ deraadt@


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE
# 1.13 23-Oct-2015 tedu

mmap is the default. it's effectively the only tested codepath. so burn down
the stdio code path.
pros: everything is simpler. how can anyone read code this heavily spliced
with ifdef?
cons: you can't pipe a database into locate. who does this???
ok deraadt


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.12 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.11 25-Oct-2010 millert

Add missing FNM_CASEFOLD flag to fnmatch() when locate is run in case
insensitive mode. From Geoff Steckel. OK deraadt@


Revision tags: OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE
# 1.10 04-Jun-2009 espie

error out if count gets out of bounds. Happens with corrupted databases,
better than a buffer underflow and a segfault.
okay millert@


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE
# 1.9 26-Jul-2008 pyr

Add -b switch for matching on the last part of the path only.

ok landry@, otto liked the idea and the original diff, ``do it'' deraadt@


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE OPENBSD_3_7_BASE OPENBSD_3_8_BASE OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.8 29-Sep-2003 deraadt

knf


Revision tags: OPENBSD_3_4_BASE
# 1.7 03-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_3_1_BASE OPENBSD_3_2_BASE OPENBSD_3_3_BASE
# 1.6 19-Nov-2001 mpech

kill more registers

millert@ ok


Revision tags: OPENBSD_2_4_BASE OPENBSD_2_5_BASE OPENBSD_2_6_BASE OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE OPENBSD_3_0_BASE
# 1.5 24-Jul-1998 deraadt

fix spelling; aaron@ug.cs.dal.ca


Revision tags: OPENBSD_2_1_BASE OPENBSD_2_2_BASE OPENBSD_2_3_BASE
# 1.4 17-Jan-1997 millert

r?index -> strr?chr


# 1.3 20-Oct-1996 michaels

8-Bit character support. From wosch@freebsd.


# 1.2 10-Oct-1996 michaels

Fix searching for shell quoting characters. From wosch@freebsd.


Revision tags: OPENBSD_2_0_BASE
# 1.1 15-Sep-1996 michaels

Blind update of wosch@FreeBSD's code:

optimized search algorithm
faster IO due mmap(2) [-m | -s]
better error check for damaged databases
support for databases in network byte order (SunOS/sparc)
optional case insensitve search [-i]
optional multiple databases
optional multiple pattern
new enviroment variable LOCATE_PATH for database(s)
[-S] print some statistic about the database
[-l number] limit output to number file names
[-c] suppress normal output; instead print a count of matching file names
fix prototypes/forward declarations/return type