summaryrefslogtreecommitdiff
path: root/src/cp.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1994-07-30 16:17:45 +0000
committerJim Meyering <jim@meyering.net>1994-07-30 16:17:45 +0000
commita272d8b0c6e62937ef7b69e3ca750e34fd3e3152 (patch)
tree90892dd17477b0c98c563d6597f6be0bd367c90b /src/cp.c
parent15ddd652be4aa1dfb1f9d198dcada21ec964cd7e (diff)
downloadcoreutils-a272d8b0c6e62937ef7b69e3ca750e34fd3e3152.tar.xz
.
Diffstat (limited to 'src/cp.c')
-rw-r--r--src/cp.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/cp.c b/src/cp.c
index 3fb200bd1..fbbc4fd8c 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;