summaryrefslogtreecommitdiff
path: root/src/test.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1994-07-22 17:18:46 +0000
committerJim Meyering <jim@meyering.net>1994-07-22 17:18:46 +0000
commit754e4abb56dce9f33ec18d552cff575072051356 (patch)
treec001eaeea438b3137bf611907a4fb7140a08972e /src/test.c
parent7314448bef2a1bcc42b24db371931488571df57d (diff)
downloadcoreutils-754e4abb56dce9f33ec18d552cff575072051356.tar.xz
* test.c (test_stat, binary_operator, unary_operator): Use SAFE_STAT and
SAFE_LSTAT.
Diffstat (limited to 'src/test.c')
-rw-r--r--src/test.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/test.c b/src/test.c
index c7a8eb163..9421fea10 100644
--- a/src/test.c
+++ b/src/test.c
@@ -45,6 +45,8 @@
#else /* TEST_STANDALONE */
# include "system.h"
# include "version.h"
+# include "safe-stat.h"
+# include "safe-lstat.h"
# if !defined (S_IXUGO)
# define S_IXUGO 0111
# endif /* S_IXUGO */
@@ -165,7 +167,7 @@ test_stat (path, finfo)
errno = ENOENT;
return (-1);
}
- return (stat (path, finfo));
+ return (SAFE_STAT (path, finfo));
}
/* Do the same thing access(2) does, but use the effective uid and gid,
@@ -649,9 +651,9 @@ binary_operator ()
pos += 3;
if (l_is_l || r_is_l)
test_syntax_error ("-ef does not accept -l\n", (char *)NULL);
- if (stat (argv[op - 1], &stat_buf) < 0)
+ if (SAFE_STAT (argv[op - 1], &stat_buf) < 0)
return (FALSE);
- if (stat (argv[op + 1], &stat_spare) < 0)
+ if (SAFE_STAT (argv[op + 1], &stat_spare) < 0)
return (FALSE);
return (TRUE ==
(stat_buf.st_dev == stat_spare.st_dev &&
@@ -814,7 +816,7 @@ unary_operator ()
#else
/* An empty filename is not a valid pathname. */
if ((argv[pos - 1][0] == '\0') ||
- (lstat (argv[pos - 1], &stat_buf) < 0))
+ (SAFE_LSTAT (argv[pos - 1], &stat_buf) < 0))
return (FALSE);
return (TRUE == (S_ISLNK (stat_buf.st_mode)));