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/main] Cygwin: fix an ugly cast
Date: Fri,  8 Sep 2023 20:41:51 +0000 (GMT)	[thread overview]
Message-ID: <20230908204151.14CB13858D38@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=c5913771a641ec54308ef5054837198be2a6fd63

commit c5913771a641ec54308ef5054837198be2a6fd63
Author:     Corinna Vinschen <corinna@vinschen.de>
AuthorDate: Fri Sep 8 22:41:21 2023 +0200
Commit:     Corinna Vinschen <corinna@vinschen.de>
CommitDate: Fri Sep 8 22:41:21 2023 +0200

    Cygwin: fix an ugly cast
    
    fhandler_base::fchown casts any fhandler landing here to a
    fhandler_disk_file.  That's ugly and dangerous.  Duplicate
    the path_conv info into an explicitly create fhandler_disk_file
    instead and call fchmod on that.
    
    Signed-off-by: Corinna Vinschen <corinna@vinschen.de>

Diff:
---
 winsup/cygwin/fhandler/base.cc | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/winsup/cygwin/fhandler/base.cc b/winsup/cygwin/fhandler/base.cc
index 6163df2914d4..cdef01a2da67 100644
--- a/winsup/cygwin/fhandler/base.cc
+++ b/winsup/cygwin/fhandler/base.cc
@@ -1725,7 +1725,10 @@ int
 fhandler_base::fchown (uid_t uid, gid_t gid)
 {
   if (pc.is_fs_special ())
-    return ((fhandler_disk_file *) this)->fhandler_disk_file::fchown (uid, gid);
+    {
+      fhandler_disk_file fh (pc);
+      return fh.fchown (uid, gid);
+    }
   /* By default, just succeeds. */
   return 0;
 }

                 reply	other threads:[~2023-09-08 20:41 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=20230908204151.14CB13858D38@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).