[newlib-cygwin/main] Cygwin: fix an ugly cast

Corinna Vinschen corinna@sourceware.org
Fri Sep 8 20:41:51 GMT 2023


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;
 }


More information about the Cygwin-cvs mailing list