From: Jim Meyering Date: Sat, 30 Jul 1994 16:17:45 +0000 (+0000) Subject: . X-Git-Tag: textutils-1_12_1~638 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a272d8b0c6e62937ef7b69e3ca750e34fd3e3152;p=thirdparty%2Fcoreutils.git . --- diff --git a/src/cp.c b/src/cp.c index 3fb200bd16..fbbc4fd8cc 100644 --- a/src/cp.c +++ b/src/cp.c @@ -37,6 +37,8 @@ #include "cp.h" #include "backupfile.h" #include "version.h" +#include "safe-stat.h" +#include "safe-lstat.h" #ifndef _POSIX_VERSION uid_t geteuid (); @@ -295,9 +297,9 @@ main (argc, argv) of `stat' to call. */ if (flag_dereference) - xstat = stat; + xstat = safe_stat; else - xstat = lstat; + xstat = safe_lstat; /* Allocate space for remembering copied and created files. */ @@ -328,7 +330,7 @@ do_copy (argc, argv) dest = argv[argc - 1]; - if (lstat (dest, &sb)) + if (SAFE_LSTAT (dest, &sb)) { if (errno != ENOENT) { @@ -345,7 +347,7 @@ do_copy (argc, argv) /* If `dest' is not a symlink to a nonexistent file, use the results of stat instead of lstat, so we can copy files into symlinks to directories. */ - if (stat (dest, &sbx) == 0) + if (SAFE_STAT (dest, &sbx) == 0) sb = sbx; } @@ -437,7 +439,7 @@ do_copy (argc, argv) `cp source dest/' to `cp source dest/basename(source)'. */ if (dest[strlen (dest) - 1] == '/' - && lstat (source, &source_stats) == 0 + && SAFE_LSTAT (source, &source_stats) == 0 && !S_ISDIR (source_stats.st_mode)) { char *source_base;