mirror of
https://sourceware.org/git/glibc.git
synced 2025-08-13 03:22:30 +03:00
hurd: Fix EINVAL error on linking to a slash-trailing path [BZ #32569]
When the target path finishes with a slash, __file_name_split_at returns an empty file name. We can test for this to refuse doing the link.
This commit is contained in:
@@ -47,6 +47,10 @@ __bind (int fd, __CONST_SOCKADDR_ARG addrarg, socklen_t len)
|
|||||||
if (dir == MACH_PORT_NULL)
|
if (dir == MACH_PORT_NULL)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
if (! *n)
|
||||||
|
/* Can't bind on the existing directory itself. */
|
||||||
|
err = ENOTDIR;
|
||||||
|
else
|
||||||
/* Create a new, unlinked node in the target directory. */
|
/* Create a new, unlinked node in the target directory. */
|
||||||
err = __dir_mkfile (dir, O_CREAT, 0666 & ~_hurd_umask, &node);
|
err = __dir_mkfile (dir, O_CREAT, 0666 & ~_hurd_umask, &node);
|
||||||
|
|
||||||
|
@@ -48,6 +48,10 @@ __linkat_common (int fromfd, const char *from, int tofd, const char *to, int at_
|
|||||||
todir = __file_name_split_at (tofd, to, &toname);
|
todir = __file_name_split_at (tofd, to, &toname);
|
||||||
if (todir != MACH_PORT_NULL)
|
if (todir != MACH_PORT_NULL)
|
||||||
{
|
{
|
||||||
|
if (! *toname)
|
||||||
|
/* Can't link to the existing directory itself. */
|
||||||
|
err = ENOTDIR;
|
||||||
|
else
|
||||||
err = __dir_link (todir, linknode, toname, 1);
|
err = __dir_link (todir, linknode, toname, 1);
|
||||||
__mach_port_deallocate (__mach_task_self (), todir);
|
__mach_port_deallocate (__mach_task_self (), todir);
|
||||||
}
|
}
|
||||||
|
@@ -88,6 +88,10 @@ __mknodat (int fd, const char *path, mode_t mode, dev_t dev)
|
|||||||
if (dir == MACH_PORT_NULL)
|
if (dir == MACH_PORT_NULL)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
if (! *name)
|
||||||
|
/* Can't link to the existing directory itself. */
|
||||||
|
errnode = err = ENOTDIR;
|
||||||
|
else
|
||||||
/* Create a new, unlinked node in the target directory. */
|
/* Create a new, unlinked node in the target directory. */
|
||||||
errnode = err = __dir_mkfile (dir, O_WRITE, (mode & ~S_IFMT) & ~_hurd_umask, &node);
|
errnode = err = __dir_mkfile (dir, O_WRITE, (mode & ~S_IFMT) & ~_hurd_umask, &node);
|
||||||
|
|
||||||
|
@@ -45,6 +45,10 @@ __symlinkat (const char *from, int fd, const char *to)
|
|||||||
if (dir == MACH_PORT_NULL)
|
if (dir == MACH_PORT_NULL)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
if (! *name)
|
||||||
|
/* Can't link to the existing directory itself. */
|
||||||
|
err = ENOTDIR;
|
||||||
|
else
|
||||||
/* Create a new, unlinked node in the target directory. */
|
/* Create a new, unlinked node in the target directory. */
|
||||||
err = __dir_mkfile (dir, O_WRITE, 0777 & ~_hurd_umask, &node);
|
err = __dir_mkfile (dir, O_WRITE, 0777 & ~_hurd_umask, &node);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user