summaryrefslogtreecommitdiffstats
path: root/winsup
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2008-05-22 11:18:46 +0000
committerCorinna Vinschen <corinna@vinschen.de>2008-05-22 11:18:46 +0000
commitb72918135c4d863ef18a4a438cb8276b777cc0aa (patch)
tree004fb965ddd194e4eaf6691ba5dd058d529e6deb /winsup
parentae47b14a12d21f7d4a506b5682308d2fe3f8a0ec (diff)
downloadcygnal-b72918135c4d863ef18a4a438cb8276b777cc0aa.tar.gz
cygnal-b72918135c4d863ef18a4a438cb8276b777cc0aa.tar.bz2
cygnal-b72918135c4d863ef18a4a438cb8276b777cc0aa.zip
* path.cc (cygwin_conv_path): Define tp before setting up faul handler.
* syscalls.cc: Ditto, throughout. (gen_full_path_at): Add bool parameter to allow NULL pathname. (futimesat): Allow NULL pathname as GLIBC.
Diffstat (limited to 'winsup')
-rw-r--r--winsup/cygwin/ChangeLog7
-rw-r--r--winsup/cygwin/path.cc4
-rw-r--r--winsup/cygwin/syscalls.cc66
3 files changed, 49 insertions, 28 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index dc823062b..1ecefe1a9 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,10 @@
+2008-05-22 Corinna Vinschen <corinna@vinschen.de>
+
+ * path.cc (cygwin_conv_path): Define tp before setting up faul handler.
+ * syscalls.cc: Ditto, throughout.
+ (gen_full_path_at): Add bool parameter to allow NULL pathname.
+ (futimesat): Allow NULL pathname as GLIBC.
+
2008-05-21 Christopher Faylor <me+cygwin@cgf.cx>
* string.h (strchr): Eliminate.
diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc
index 58f0afde7..dd50f3d50 100644
--- a/winsup/cygwin/path.cc
+++ b/winsup/cygwin/path.cc
@@ -2799,12 +2799,12 @@ extern "C" ssize_t
cygwin_conv_path (cygwin_conv_path_t what, const void *from, void *to,
size_t size)
{
+ tmp_pathbuf tp;
myfault efault;
if (efault.faulted (EFAULT))
return -1;
path_conv p;
- tmp_pathbuf tp;
size_t lsiz = 0;
char *buf = NULL;
int error = 0;
@@ -2935,11 +2935,11 @@ realpath (const char *path, char *resolved)
/* Guard reading from a potentially invalid path and writing to a
potentially invalid resolved. */
+ tmp_pathbuf tp;
myfault efault;
if (efault.faulted (EFAULT))
return NULL;
- tmp_pathbuf tp;
char *tpath;
if (isdrive (path))
{
diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc
index a7471d958..18c8d7498 100644
--- a/winsup/cygwin/syscalls.cc
+++ b/winsup/cygwin/syscalls.cc
@@ -3567,19 +3567,30 @@ pclose (FILE *fp)
/* Preliminary(?) implementation of the openat family of functions. */
static int
-gen_full_path_at (char *path_ret, int dirfd, const char *pathname)
+gen_full_path_at (char *path_ret, int dirfd, const char *pathname,
+ bool null_pathname_allowed = false)
{
- if (!*pathname)
+ /* Set null_pathname_allowed to true to allow GLIBC compatible behaviour
+ for NULL pathname. Only used by futimesat. */
+ if (!pathname && !null_pathname_allowed)
{
- set_errno (ENOENT);
+ set_errno (EFAULT);
return -1;
}
- if (strlen (pathname) >= PATH_MAX)
+ if (pathname)
{
- set_errno (ENAMETOOLONG);
- return -1;
+ if (!*pathname)
+ {
+ set_errno (ENOENT);
+ return -1;
+ }
+ if (strlen (pathname) >= PATH_MAX)
+ {
+ set_errno (ENAMETOOLONG);
+ return -1;
+ }
}
- if (isdirsep (*pathname))
+ if (pathname && isdirsep (*pathname))
stpcpy (path_ret, pathname);
else
{
@@ -3604,9 +3615,12 @@ gen_full_path_at (char *path_ret, int dirfd, const char *pathname)
set_errno (ENOTDIR);
return -1;
}
- if (p[-1] != '/')
- *p++ = '/';
- stpcpy (p, pathname);
+ if (pathname)
+ {
+ if (p[-1] != '/')
+ *p++ = '/';
+ stpcpy (p, pathname);
+ }
}
return 0;
}
@@ -3614,10 +3628,10 @@ gen_full_path_at (char *path_ret, int dirfd, const char *pathname)
extern "C" int
openat (int dirfd, const char *pathname, int flags, ...)
{
+ tmp_pathbuf tp;
myfault efault;
if (efault.faulted (EFAULT))
return -1;
- tmp_pathbuf tp;
char *path = tp.c_get ();
if (gen_full_path_at (path, dirfd, pathname))
return -1;
@@ -3634,12 +3648,12 @@ openat (int dirfd, const char *pathname, int flags, ...)
extern "C" int
faccessat (int dirfd, const char *pathname, int mode, int flags)
{
+ tmp_pathbuf tp;
myfault efault;
if (efault.faulted (EFAULT))
return -1;
int res = -1;
- tmp_pathbuf tp;
char *path = tp.c_get ();
if (!gen_full_path_at (path, dirfd, pathname))
{
@@ -3665,10 +3679,10 @@ faccessat (int dirfd, const char *pathname, int mode, int flags)
extern "C" int
fchmodat (int dirfd, const char *pathname, mode_t mode, int flags)
{
+ tmp_pathbuf tp;
myfault efault;
if (efault.faulted (EFAULT))
return -1;
- tmp_pathbuf tp;
char *path = tp.c_get ();
if (gen_full_path_at (path, dirfd, pathname))
return -1;
@@ -3679,10 +3693,10 @@ extern "C" int
fchownat (int dirfd, const char *pathname, __uid32_t uid, __gid32_t gid,
int flags)
{
+ tmp_pathbuf tp;
myfault efault;
if (efault.faulted (EFAULT))
return -1;
- tmp_pathbuf tp;
char *path = tp.c_get ();
if (gen_full_path_at (path, dirfd, pathname))
return -1;
@@ -3693,10 +3707,10 @@ fchownat (int dirfd, const char *pathname, __uid32_t uid, __gid32_t gid,
extern "C" int
fstatat (int dirfd, const char *pathname, struct __stat64 *st, int flags)
{
+ tmp_pathbuf tp;
myfault efault;
if (efault.faulted (EFAULT))
return -1;
- tmp_pathbuf tp;
char *path = tp.c_get ();
if (gen_full_path_at (path, dirfd, pathname))
return -1;
@@ -3709,10 +3723,10 @@ extern "C" int
utimensat (int dirfd, const char *pathname, const struct timespec *times,
int flags)
{
+ tmp_pathbuf tp;
myfault efault;
if (efault.faulted (EFAULT))
return -1;
- tmp_pathbuf tp;
char *path = tp.c_get ();
if (gen_full_path_at (path, dirfd, pathname))
return -1;
@@ -3725,12 +3739,12 @@ utimensat (int dirfd, const char *pathname, const struct timespec *times,
extern "C" int
futimesat (int dirfd, const char *pathname, const struct timeval *times)
{
+ tmp_pathbuf tp;
myfault efault;
if (efault.faulted (EFAULT))
return -1;
- tmp_pathbuf tp;
char *path = tp.c_get ();
- if (gen_full_path_at (path, dirfd, pathname))
+ if (gen_full_path_at (path, dirfd, pathname, true))
return -1;
return utimes (path, times);
}
@@ -3740,10 +3754,10 @@ linkat (int olddirfd, const char *oldpathname,
int newdirfd, const char *newpathname,
int flags)
{
+ tmp_pathbuf tp;
myfault efault;
if (efault.faulted (EFAULT))
return -1;
- tmp_pathbuf tp;
char *oldpath = tp.c_get ();
if (gen_full_path_at (oldpath, olddirfd, oldpathname))
return -1;
@@ -3766,10 +3780,10 @@ linkat (int olddirfd, const char *oldpathname,
extern "C" int
mkdirat (int dirfd, const char *pathname, mode_t mode)
{
+ tmp_pathbuf tp;
myfault efault;
if (efault.faulted (EFAULT))
return -1;
- tmp_pathbuf tp;
char *path = tp.c_get ();
if (gen_full_path_at (path, dirfd, pathname))
return -1;
@@ -3779,10 +3793,10 @@ mkdirat (int dirfd, const char *pathname, mode_t mode)
extern "C" int
mkfifoat (int dirfd, const char *pathname, mode_t mode)
{
+ tmp_pathbuf tp;
myfault efault;
if (efault.faulted (EFAULT))
return -1;
- tmp_pathbuf tp;
char *path = tp.c_get ();
if (gen_full_path_at (path, dirfd, pathname))
return -1;
@@ -3792,10 +3806,10 @@ mkfifoat (int dirfd, const char *pathname, mode_t mode)
extern "C" int
mknodat (int dirfd, const char *pathname, mode_t mode, __dev32_t dev)
{
+ tmp_pathbuf tp;
myfault efault;
if (efault.faulted (EFAULT))
return -1;
- tmp_pathbuf tp;
char *path = tp.c_get ();
if (gen_full_path_at (path, dirfd, pathname))
return -1;
@@ -3805,10 +3819,10 @@ mknodat (int dirfd, const char *pathname, mode_t mode, __dev32_t dev)
extern "C" ssize_t
readlinkat (int dirfd, const char *pathname, char *buf, size_t bufsize)
{
+ tmp_pathbuf tp;
myfault efault;
if (efault.faulted (EFAULT))
return -1;
- tmp_pathbuf tp;
char *path = tp.c_get ();
if (gen_full_path_at (path, dirfd, pathname))
return -1;
@@ -3819,10 +3833,10 @@ extern "C" int
renameat (int olddirfd, const char *oldpathname,
int newdirfd, const char *newpathname)
{
+ tmp_pathbuf tp;
myfault efault;
if (efault.faulted (EFAULT))
return -1;
- tmp_pathbuf tp;
char *oldpath = tp.c_get ();
if (gen_full_path_at (oldpath, olddirfd, oldpathname))
return -1;
@@ -3835,10 +3849,10 @@ renameat (int olddirfd, const char *oldpathname,
extern "C" int
symlinkat (const char *oldpath, int newdirfd, const char *newpathname)
{
+ tmp_pathbuf tp;
myfault efault;
if (efault.faulted (EFAULT))
return -1;
- tmp_pathbuf tp;
char *newpath = tp.c_get ();
if (gen_full_path_at (newpath, newdirfd, newpathname))
return -1;
@@ -3848,10 +3862,10 @@ symlinkat (const char *oldpath, int newdirfd, const char *newpathname)
extern "C" int
unlinkat (int dirfd, const char *pathname, int flags)
{
+ tmp_pathbuf tp;
myfault efault;
if (efault.faulted (EFAULT))
return -1;
- tmp_pathbuf tp;
char *path = tp.c_get ();
if (gen_full_path_at (path, dirfd, pathname))
return -1;