public inbox for cygwin-cvs@sourceware.org
help / color / mirror / Atom feed
* [newlib-cygwin] Cygwin: unlink: filter out virtual files and devices early on
@ 2022-02-22 12:34 Corinna Vinschen
0 siblings, 0 replies; only message in thread
From: Corinna Vinschen @ 2022-02-22 12:34 UTC (permalink / raw)
To: cygwin-cvs
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=f2dc492df0f310aec97b5fc5847cca8d6cb70a33
commit f2dc492df0f310aec97b5fc5847cca8d6cb70a33
Author: Corinna Vinschen <corinna@vinschen.de>
Date: Tue Feb 22 13:32:29 2022 +0100
Cygwin: unlink: filter out virtual files and devices early on
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Diff:
---
winsup/cygwin/devices.h | 1 +
winsup/cygwin/syscalls.cc | 6 +++++-
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/winsup/cygwin/devices.h b/winsup/cygwin/devices.h
index fbbde6ab9..8f718dd17 100644
--- a/winsup/cygwin/devices.h
+++ b/winsup/cygwin/devices.h
@@ -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)
diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc
index 661c14347..24ec01da8 100644
--- a/winsup/cygwin/syscalls.cc
+++ b/winsup/cygwin/syscalls.cc
@@ -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");
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-02-22 12:34 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-22 12:34 [newlib-cygwin] Cygwin: unlink: filter out virtual files and devices early on Corinna Vinschen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).