From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2155) id 450143864826; Tue, 22 Feb 2022 12:34:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 450143864826 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Corinna Vinschen To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin] Cygwin: unlink: filter out virtual files and devices early on X-Act-Checkin: newlib-cygwin X-Git-Author: Corinna Vinschen X-Git-Refname: refs/heads/master X-Git-Oldrev: 4ec08891a005c040da5bf7c38ae44f932d29bd77 X-Git-Newrev: f2dc492df0f310aec97b5fc5847cca8d6cb70a33 Message-Id: <20220222123438.450143864826@sourceware.org> Date: Tue, 22 Feb 2022 12:34:38 +0000 (GMT) X-BeenThere: cygwin-cvs@cygwin.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Cygwin core component git logs List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Feb 2022 12:34:38 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3Df2dc492df0f= 310aec97b5fc5847cca8d6cb70a33 commit f2dc492df0f310aec97b5fc5847cca8d6cb70a33 Author: Corinna Vinschen Date: Tue Feb 22 13:32:29 2022 +0100 Cygwin: unlink: filter out virtual files and devices early on =20 Signed-off-by: Corinna Vinschen 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 =3D=3D FH_CYGDRIVE) =20 #define isdev_dev(devn) (devn =3D=3D FH_DEV) +#define isdevfd_dev(devn) (devn =3D=3D FH_DEV_FD) =20 #define isprocsys_dev(devn) (devn =3D=3D FH_PROCSYS) =20 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.issocke= t ())) + { + set_errno (EPERM); + goto done; + } if (!win32_name.exists ()) { debug_printf ("unlinking a nonexistent file");