This is the mail archive of the
cygwin-patches
mailing list for the Cygwin project.
Re: [1.7] bugs in faccessat
- From: Eric Blake <ebb9 at byu dot net>
- To: cygwin-patches at cygwin dot com
- Date: Thu, 03 Sep 2009 13:08:57 -0600
- Subject: Re: [1.7] bugs in faccessat
- References: <loom.20090903T175736-252@post.gmane.org>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
According to Eric Blake on 9/3/2009 9:58 AM:
> faccessat has at least two, and probably three bugs.
Here's a fix for 1 (typo) and 3 (check for EINVAL in more places), but not
for 2 (euidaccess, and the followup request of lchmod).
2009-09-03 Eric Blake <ebb9@byu.net>
* syscalls.cc (faccessat): Fix typo, reject bad flags.
(fchmodat, fchownat, fstatat, utimensat, linkat, unlinkat): Reject
bad flags.
- --
Don't work too hard, make some time for fun as well!
Eric Blake ebb9@byu.net
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAkqgFEkACgkQ84KuGfSFAYBE9ACfYroQbQizKsx4/tSYwB8EYoMf
qvEAnizvKp4IlNCOJcuESiy+X+/CwcK/
=86aK
-----END PGP SIGNATURE-----
diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc
index 3798587..6dee7d3 100644
--- a/winsup/cygwin/syscalls.cc
+++ b/winsup/cygwin/syscalls.cc
@@ -3825,7 +3825,8 @@ faccessat (int dirfd, const char *pathname, int mode, int flags)
char *path = tp.c_get ();
if (!gen_full_path_at (path, dirfd, pathname))
{
- if (flags & ~(F_OK|R_OK|W_OK|X_OK))
+ if ((mode & ~(F_OK|R_OK|W_OK|X_OK))
+ || (flags & ~(AT_SYMLINK_NOFOLLOW|AT_EACCESS)))
set_errno (EINVAL);
else
{
@@ -3851,6 +3852,11 @@ fchmodat (int dirfd, const char *pathname, mode_t mode, int flags)
myfault efault;
if (efault.faulted (EFAULT))
return -1;
+ if (flags & ~AT_SYMLINK_NOFOLLOW)
+ {
+ set_errno (EINVAL);
+ return -1;
+ }
char *path = tp.c_get ();
if (gen_full_path_at (path, dirfd, pathname))
return -1;
@@ -3865,6 +3871,11 @@ fchownat (int dirfd, const char *pathname, __uid32_t uid, __gid32_t gid,
myfault efault;
if (efault.faulted (EFAULT))
return -1;
+ if (flags & ~AT_SYMLINK_NOFOLLOW)
+ {
+ set_errno (EINVAL);
+ return -1;
+ }
char *path = tp.c_get ();
if (gen_full_path_at (path, dirfd, pathname))
return -1;
@@ -3879,6 +3890,11 @@ fstatat (int dirfd, const char *pathname, struct __stat64 *st, int flags)
myfault efault;
if (efault.faulted (EFAULT))
return -1;
+ if (flags & ~AT_SYMLINK_NOFOLLOW)
+ {
+ set_errno (EINVAL);
+ return -1;
+ }
char *path = tp.c_get ();
if (gen_full_path_at (path, dirfd, pathname))
return -1;
@@ -3896,6 +3912,11 @@ utimensat (int dirfd, const char *pathname, const struct timespec *times,
if (efault.faulted (EFAULT))
return -1;
char *path = tp.c_get ();
+ if (flags & ~AT_SYMLINK_NOFOLLOW)
+ {
+ set_errno (EINVAL);
+ return -1;
+ }
if (gen_full_path_at (path, dirfd, pathname))
return -1;
path_conv win32 (path, PC_POSIX | ((flags & AT_SYMLINK_NOFOLLOW)
@@ -3926,6 +3947,11 @@ linkat (int olddirfd, const char *oldpathname,
myfault efault;
if (efault.faulted (EFAULT))
return -1;
+ if (flags & ~AT_SYMLINK_FOLLOW)
+ {
+ set_errno (EINVAL);
+ return -1;
+ }
char *oldpath = tp.c_get ();
if (gen_full_path_at (oldpath, olddirfd, oldpathname))
return -1;
@@ -4034,6 +4060,11 @@ unlinkat (int dirfd, const char *pathname, int flags)
myfault efault;
if (efault.faulted (EFAULT))
return -1;
+ if (flags & ~AT_REMOVEDIR)
+ {
+ set_errno (EINVAL);
+ return -1;
+ }
char *path = tp.c_get ();
if (gen_full_path_at (path, dirfd, pathname))
return -1;