diff -ur -N findutils-4.4.0.orig/locate/frcode.c findutils-4.4.0/locate/frcode.c --- findutils-4.4.0.orig/locate/frcode.c 2007-09-08 13:15:03.000000000 +0200 +++ findutils-4.4.0/locate/frcode.c 2008-03-24 21:26:56.000000000 +0100 @@ -177,7 +177,7 @@ long result; char *p; - /* Reset errno in oreder to be able to distinguish LONG_MAX/LONG_MIN + /* Reset errno in order to be able to distinguish LONG_MAX/LONG_MIN * from values whichare actually out of range */ errno = 0; @@ -223,6 +223,7 @@ char *oldpath; /* The previous input entry. */ size_t pathsize, oldpathsize; /* Amounts allocated for them. */ int count, oldcount, diffcount; /* Their prefix lengths & the difference. */ + int prefix_count; int line_len; /* Length of input line. */ int delimiter = '\n'; int optc; @@ -239,16 +240,19 @@ oldpath = xmalloc (oldpathsize); oldpath[0] = 0; - oldcount = 0; - while ((optc = getopt_long (argc, argv, "hv0S:", longopts, (int *) 0)) != -1) + while ((optc = getopt_long (argc, argv, "hv0rS:", longopts, (int *) 0)) != -1) switch (optc) { case '0': delimiter = 0; break; + case 'r': + strcpy (oldpath, "."); + break; + case 'S': slocate_compat = 1; slocate_seclevel = get_seclevel(optarg); @@ -280,6 +284,7 @@ return 1; } + prefix_count = oldcount = strlen (oldpath); if (slocate_compat) { @@ -297,12 +302,21 @@ } } + if (prefix_count) + { + putc ('\0', stdout); + putc ('\0', stdout); + } while ((line_len = getdelim (&path, &pathsize, delimiter, stdin)) > 0) { path[line_len - 1] = '\0'; /* FIXME temporary: nuke the newline. */ count = prefix_length (oldpath, path); + if (count < prefix_count) + { + error(1, 0, _("Path %s is not a relative path."), path); + } diffcount = count - oldcount; if ( (diffcount > SHRT_MAX) || (diffcount < SHRT_MIN) ) {