public inbox for cygwin-cvs@sourceware.org
help / color / mirror / Atom feed
From: Corinna Vinschen <corinna@sourceware.org>
To: cygwin-cvs@sourceware.org
Subject: [newlib-cygwin] Cygwin: unlink: filter out virtual files and devices early on
Date: Tue, 22 Feb 2022 12:34:38 +0000 (GMT)	[thread overview]
Message-ID: <20220222123438.450143864826@sourceware.org> (raw)

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");


                 reply	other threads:[~2022-02-22 12:34 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220222123438.450143864826@sourceware.org \
    --to=corinna@sourceware.org \
    --cc=cygwin-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).