find: Fix -lname and -ilname.
The code did not take into account that readlink() does not add a terminating '\0', and therefore did not work reliably. As before, symlinks of length PATH_MAX or more are not handled correctly. (These can only be created on other operating systems.) PR: bin/185393 Submitted by: Ben Reser (original version) MFC after: 1 week
This commit is contained in:
parent
775cb4ad60
commit
6f9ebfa0c3
@ -1122,11 +1122,14 @@ f_name(PLAN *plan, FTSENT *entry)
|
|||||||
{
|
{
|
||||||
char fn[PATH_MAX];
|
char fn[PATH_MAX];
|
||||||
const char *name;
|
const char *name;
|
||||||
|
ssize_t len;
|
||||||
|
|
||||||
if (plan->flags & F_LINK) {
|
if (plan->flags & F_LINK) {
|
||||||
name = fn;
|
len = readlink(entry->fts_path, fn, sizeof(fn) - 1);
|
||||||
if (readlink(entry->fts_path, fn, sizeof(fn)) == -1)
|
if (len == -1)
|
||||||
return 0;
|
return 0;
|
||||||
|
fn[len] = '\0';
|
||||||
|
name = fn;
|
||||||
} else
|
} else
|
||||||
name = entry->fts_name;
|
name = entry->fts_name;
|
||||||
return !fnmatch(plan->c_data, name,
|
return !fnmatch(plan->c_data, name,
|
||||||
|
Loading…
Reference in New Issue
Block a user