diff --git a/src/copy.c b/src/copy.c index e89f376f2..dda914bdb 100644 --- a/src/copy.c +++ b/src/copy.c @@ -3456,9 +3456,11 @@ owner_failure_ok (struct cp_options const *x) extern mode_t cached_umask (void) { - static mode_t mask = (mode_t) -1; - if (mask == (mode_t) -1) + static mode_t mask; + static bool cached; + if (!cached) { + cached = true; mask = umask (0); umask (mask); }