From f6c9ff6646a97ad4dd45ebdf755d4eb73fe5b6a5 Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Thu, 29 Sep 2005 16:23:22 +0000 Subject: * dir.cc (mkdir): Check for trailing /. or /.. component. (rmdir): Ditto. * path.cc (has_dot_last_component): New function. * path.h (has_dot_last_component): Add declaration. --- winsup/cygwin/dir.cc | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'winsup/cygwin/dir.cc') diff --git a/winsup/cygwin/dir.cc b/winsup/cygwin/dir.cc index bbb4ca17f..c6b318edd 100644 --- a/winsup/cygwin/dir.cc +++ b/winsup/cygwin/dir.cc @@ -255,6 +255,16 @@ mkdir (const char *dir, mode_t mode) int res = -1; fhandler_base *fh = NULL; + myfault efault; + if (efault.faulted (EFAULT)) + return -1; + + if (has_dot_last_component (dir)) + { + set_errno (ENOENT); + return -1; + } + if (!(fh = build_fh_name (dir, NULL, PC_SYM_NOFOLLOW | PC_WRITABLE))) goto done; /* errno already set */; @@ -279,6 +289,16 @@ rmdir (const char *dir) int res = -1; fhandler_base *fh = NULL; + myfault efault; + if (efault.faulted (EFAULT)) + return -1; + + if (has_dot_last_component (dir)) + { + set_errno (EINVAL); + return -1; + } + if (!(fh = build_fh_name (dir, NULL, PC_SYM_NOFOLLOW | PC_WRITABLE))) goto done; /* errno already set */; -- cgit v1.2.3