diff -ur -N -x find.info findutils-20080905.orig/locate/frcode.c findutils-20080905/locate/frcode.c --- findutils-20080905.orig/locate/frcode.c 2008-07-10 09:58:41.000000000 +0200 +++ findutils-20080905/locate/frcode.c 2008-08-02 13:54:05.000000000 +0200 @@ -177,8 +177,8 @@ long result; char *p; - /* Reset errno in oreder to be able to distinguish LONG_MAX/LONG_MIN - * from values whichare actually out of range + /* Reset errno in order to be able to distinguish LONG_MAX/LONG_MIN + * from values which are 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) ) {