diff options
| author | Jilles Tjoelker <jilles@FreeBSD.org> | 2013-02-10 18:56:37 +0000 |
|---|---|---|
| committer | Jilles Tjoelker <jilles@FreeBSD.org> | 2013-02-10 18:56:37 +0000 |
| commit | 17ef6d3ab8a4b005fdcc7ab9f4f6195a2056d50e (patch) | |
| tree | adc7ca38faa1e3706d9bbcff438bf7d15b430846 /usr.bin/find/function.c | |
| parent | 4bd1e0bbf851bf2b400583a7e7310e0581f2d46f (diff) | |
Notes
Diffstat (limited to 'usr.bin/find/function.c')
| -rw-r--r-- | usr.bin/find/function.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/usr.bin/find/function.c b/usr.bin/find/function.c index 4f2eba7433f2e..cad6eb15fc875 100644 --- a/usr.bin/find/function.c +++ b/usr.bin/find/function.c @@ -472,6 +472,14 @@ c_delete(OPTION *option, char ***argvp __unused) isoutput = 1; /* possible output */ isdepth = 1; /* -depth implied */ + /* + * Try to avoid the confusing error message about relative paths + * being potentially not safe. + */ + if (ftsoptions & FTS_NOCHDIR) + errx(1, "%s: forbidden when the current directory cannot be opened", + "-delete"); + return palloc(option); } @@ -644,7 +652,8 @@ doexec: if ((plan->flags & F_NEEDOK) && !queryuser(plan->e_argv)) /* NOTREACHED */ case 0: /* change dir back from where we started */ - if (!(plan->flags & F_EXECDIR) && fchdir(dotfd)) { + if (!(plan->flags & F_EXECDIR) && + !(ftsoptions & FTS_NOCHDIR) && fchdir(dotfd)) { warn("chdir"); _exit(1); } @@ -677,6 +686,11 @@ c_exec(OPTION *option, char ***argvp) int cnt, i; char **argv, **ap, **ep, *p; + /* This would defeat -execdir's intended security. */ + if (option->flags & F_EXECDIR && ftsoptions & FTS_NOCHDIR) + errx(1, "%s: forbidden when the current directory cannot be opened", + "-execdir"); + /* XXX - was in c_execdir, but seems unnecessary!? ftsoptions &= ~FTS_NOSTAT; */ |
