Cygwin: unlink: filter out virtual files and devices early on

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
Corinna Vinschen 2022-02-22 13:32:29 +01:00
parent 4ec08891a0
commit f2dc492df0
2 changed files with 6 additions and 1 deletions

View File

@ -433,6 +433,7 @@ extern const _device dev_fs_storage;
#define iscygdrive_dev(devn) (devn == FH_CYGDRIVE)
#define isdev_dev(devn) (devn == FH_DEV)
#define isdevfd_dev(devn) (devn == FH_DEV_FD)
#define isprocsys_dev(devn) (devn == FH_PROCSYS)

View File

@ -1123,7 +1123,11 @@ unlink (const char *ourname)
set_errno (EROFS);
goto done;
}
if (isdevfd_dev (devn) || (win32_name.isdevice () && !win32_name.issocket ()))
{
set_errno (EPERM);
goto done;
}
if (!win32_name.exists ())
{
debug_printf ("unlinking a nonexistent file");