Last update, with Tobias's help.
The following diff
- changes MAXPATHLEN from sys/param.h to PATH_MAX from limits.h
- adds a missing prototype for sane_count
- locate.bigram and locate.code now abort when reading a pathname
exceeding PATH_MAX bytes on stdin
Index:
On Wed, Nov 26, 2014 at 09:48:15PM +0100, Nicolas Bedos wrote:
Last update, with Tobias's help.
The following diff
- changes MAXPATHLEN from sys/param.h to PATH_MAX from limits.h
- adds a missing prototype for sane_count
- locate.bigram and locate.code now abort when reading a pathname
Tobias Stoeckmann wrote:
I would free() it nontheless outside the while loop. For the sake of
faster review. But that's just my opinion.
Also, it would be nice if there is only one len/sizeof() check after
fgetln. Which means that the check should be done after the
if/else-block. Could
Tobias Stoeckmann wrote:
I would recommend using fgetln for the actual line parsing. Then this
kinda fragile code can be avoided (fragile: fgets and its users have a
hard time to properly handle '\0' chars inside a file).
Thank you for the advice. Here is an updated diff. It does indeed look
On Mon, Nov 24, 2014 at 08:37:47PM +0100, Nicolas Bedos wrote:
In locate.code.c 'mbuf' is never free()d: it is only allocated for the
last line of input and after processing this line the program ends. I
hope it is ok.
I would free() it nontheless outside the while loop. For the sake of
Hello,
locate(1) doesn't handle paths longer than MAXPATHLEN well: they are
silently split into MAXPATHLEN-long strings and each string is included
in the database. Here is an example :
$ cat loc_test.sh
testdir='/tmp/locate_maxpathlen'
db=$testdir/db
On Sun, Nov 23, 2014 at 06:59:59PM +0100, Nicolas Bedos wrote:
Index: src/usr.bin/locate//code/locate.code.c
===
RCS file: /cvs/src/usr.bin/locate/code/locate.code.c,v
retrieving revision 1.17
diff -u -p -u -r1.17 locate.code.c