diff options
author | Dmitry V. Levin <ldv@altlinux.org> | 2015-12-23 21:43:21 +0000 |
---|---|---|
committer | James Youngman <jay@gnu.org> | 2015-12-23 21:44:33 +0000 |
commit | f4d77401d08cfb4aa90143f1b5905546f7912992 (patch) | |
tree | 7b8a398602b900911936681f34a2c32409e76da5 | |
parent | 2135babdeea446f83ae5b9f89174779a061bc617 (diff) | |
download | findutils-f4d77401d08cfb4aa90143f1b5905546f7912992.tar.gz |
Fix save_cwd/restore_cwd error diagnostics.
Before this change, a pointer to struct saved_cwd was used in place
of char*, leading to incorrect error diagnostics, e.g.:
$ chmod a-x . && find / -maxdepth 0 -exec true \;
find: Failed to change directory: ÿÿÿÿ: Permission denied
find: failed to restore initial working directory: ÿÿÿÿ: Permission denied
* find/exec.c (prep_child_for_exec): Fix error diagnostics.
* find/util.c (record_initial_cwd, cleanup_initial_cwd): Likewise.
-rw-r--r-- | find/exec.c | 4 | ||||
-rw-r--r-- | find/util.c | 8 |
2 files changed, 9 insertions, 3 deletions
diff --git a/find/exec.c b/find/exec.c index a57b6d42..7b6ecf6e 100644 --- a/find/exec.c +++ b/find/exec.c @@ -282,7 +282,9 @@ prep_child_for_exec (bool close_stdin, const struct saved_cwd *wd) */ if (0 != restore_cwd (wd)) { - error (0, errno, _("Failed to change directory: %s"), wd); + error (0, errno, _("Failed to change directory%s%s"), + (wd->desc < 0 && wd->name) ? ": " : "", + (wd->desc < 0 && wd->name) ? wd->name : ""); ok = false; } return ok; diff --git a/find/util.c b/find/util.c index eb5efa2e..0560e631 100644 --- a/find/util.c +++ b/find/util.c @@ -456,7 +456,9 @@ record_initial_cwd (void) if (0 != save_cwd (initial_wd)) { error (EXIT_FAILURE, errno, - _("failed to save initial working directory: %s"), initial_wd); + _("Failed to save initial working directory%s%s"), + (initial_wd->desc < 0 && initial_wd->name) ? ": " : "", + (initial_wd->desc < 0 && initial_wd->name) ? initial_wd->name : ""); } } @@ -473,7 +475,9 @@ cleanup_initial_cwd (void) { /* since we may already be in atexit, die with _exit(). */ error (0, errno, - _("failed to restore initial working directory: %s"), initial_wd); + _("Failed to restore initial working directory%s%s"), + (initial_wd->desc < 0 && initial_wd->name) ? ": " : "", + (initial_wd->desc < 0 && initial_wd->name) ? initial_wd->name : ""); _exit (EXIT_FAILURE); } } |