Fix some POSIX-compliance bugs in link, rename, mkdir.
* syscalls.cc (link): Delete obsolete comment. Reject directories and missing source up front. (rename): Use correct errno for trailing '.'. Detect empty strings. Allow trailing slash to newpath iff oldpath is directory. * dir.cc (mkdir): Reject dangling symlink with trailing slash. * fhandler_disk_file.cc (fhandler_disk_file::link): Reject trailing slash. * fhandler.cc (fhandler_base::link): Match Linux errno.
This commit is contained in:
@ -1186,7 +1186,8 @@ fhandler_disk_file::ftruncate (_off64_t length, bool allow_truncate)
|
||||
int
|
||||
fhandler_disk_file::link (const char *newpath)
|
||||
{
|
||||
path_conv newpc (newpath, PC_SYM_NOFOLLOW | PC_POSIX, stat_suffixes);
|
||||
size_t nlen = strlen (newpath);
|
||||
path_conv newpc (newpath, PC_SYM_NOFOLLOW | PC_POSIX | PC_NULLEMPTY, stat_suffixes);
|
||||
if (newpc.error)
|
||||
{
|
||||
set_errno (newpc.error);
|
||||
@ -1200,7 +1201,13 @@ fhandler_disk_file::link (const char *newpath)
|
||||
return -1;
|
||||
}
|
||||
|
||||
char new_buf[strlen (newpath) + 5];
|
||||
if (isdirsep (newpath[nlen - 1]) || has_dot_last_component (newpath, false))
|
||||
{
|
||||
set_errno (ENOENT);
|
||||
return -1;
|
||||
}
|
||||
|
||||
char new_buf[nlen + 5];
|
||||
if (!newpc.error)
|
||||
{
|
||||
if (pc.is_lnk_special ())
|
||||
|
Reference in New Issue
Block a user