diff options
author | Jim Meyering <jim@meyering.net> | 2000-07-25 22:22:52 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2000-07-25 22:22:52 +0000 |
commit | ebd74667bc327d4bcbbe7385bd3668919d93f0cb (patch) | |
tree | 0de45f9180de12ecd2104f9ccca5f70ecfda6881 /src | |
parent | d3938d3118d1f30cc613d92eb0e72c77693e6226 (diff) | |
download | coreutils-ebd74667bc327d4bcbbe7385bd3668919d93f0cb.tar.xz |
(change_file_mode): Save errno from a possibly failed chown,
and use that later. Otherwise, errno itself could be clobbered before used.
Diffstat (limited to 'src')
-rw-r--r-- | src/chmod.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/chmod.c b/src/chmod.c index 41c538873..f958e962a 100644 --- a/src/chmod.c +++ b/src/chmod.c @@ -162,6 +162,7 @@ change_file_mode (const char *file, const struct mode_change *changes, if (newmode != (file_stats.st_mode & CHMOD_MODE_BITS)) { int fail = chmod (file, newmode); + int saved_errno = errno; if (verbosity == V_high || (verbosity == V_changes_only && !fail)) describe_change (file, newmode, (fail ? CH_FAILED : CH_SUCCEEDED)); @@ -169,7 +170,7 @@ change_file_mode (const char *file, const struct mode_change *changes, if (fail) { if (force_silent == 0) - error (0, errno, "%s", file); + error (0, saved_errno, "%s", file); errors = 1; } } |