+2009-09-05 Eric Blake <ebb9@byu.net>
+
+ test-openat-safer: add more checks
+ * tests/test-openat-safer.c (main): Check more code paths.
+
2009-09-05 Jim Meyering <meyering@redhat.com>
syntax-check: detect unnecessary inclusion of openat.h
errno = 0;
ASSERT (openat (dfd, "", O_RDONLY) == -1);
ASSERT (errno == ENOENT);
+ errno = 0;
+ ASSERT (openat (-1, ".", O_RDONLY) == -1);
+ ASSERT (errno == EBADF);
/* Check for trailing slash and /dev/null handling; the
particular errno might be ambiguous. */
errno = 0;
ASSERT (openat (dfd, "/dev/null/", O_RDONLY) == -1);
/* ASSERT (errno == ENOTDIR); */
- fd = openat (dfd, "/dev/null", O_RDONLY);
+ /* Using a bad directory is okay for absolute paths. */
+ fd = openat (-1, "/dev/null", O_WRONLY);
ASSERT (STDERR_FILENO < fd);
+ /* Using a non-directory is wrong for relative paths. */
+ errno = 0;
+ ASSERT (openat (fd, ".", O_RDONLY) == -1);
+ ASSERT (errno == EBADF || errno == ENOTDIR);
ASSERT (close (fd) == 0);
/* Check for our witness file. */