#include "cp.h"
#include "backupfile.h"
#include "version.h"
+#include "safe-stat.h"
+#include "safe-lstat.h"
#ifndef _POSIX_VERSION
uid_t geteuid ();
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. */
dest = argv[argc - 1];
- if (lstat (dest, &sb))
+ if (SAFE_LSTAT (dest, &sb))
{
if (errno != ENOENT)
{
/* 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;
}
`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;