* 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.
This commit is contained in:
Corinna Vinschen
2005-09-29 16:23:22 +00:00
parent 9a7b0aad2a
commit f6c9ff6646
3 changed files with 39 additions and 0 deletions

View File

@@ -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 */;