From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2155) id 14CB13858D38; Fri, 8 Sep 2023 20:41:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 14CB13858D38 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1694205711; bh=qJym2iFGH93I8Vfll1+5WR+wEaor2EN4YAknkK6NwUo=; h=From:To:Subject:Date:From; b=d7T5H0CUNbMPwPEyHCeQpcrX7nhaaeZEhAVGA5Eq7golsm3qlJV7hRcAqmOd1zshw ooaFBnfZxLOhCKojr1oKnOEBnyT3VWfyy5jRWfV0rH2K9awP3+rmZQWEsPZ9Jg71wW zGdgNFGnXEu2eE2+dLWhBGcgONgDJeW0v5VkJEKE= 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/main] Cygwin: fix an ugly cast X-Act-Checkin: newlib-cygwin X-Git-Author: Corinna Vinschen X-Git-Refname: refs/heads/main X-Git-Oldrev: bedefff9e25b6b2bdc13e0268a437f82dc4b4798 X-Git-Newrev: c5913771a641ec54308ef5054837198be2a6fd63 Message-Id: <20230908204151.14CB13858D38@sourceware.org> Date: Fri, 8 Sep 2023 20:41:51 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3Dc5913771a64= 1ec54308ef5054837198be2a6fd63 commit c5913771a641ec54308ef5054837198be2a6fd63 Author: Corinna Vinschen AuthorDate: Fri Sep 8 22:41:21 2023 +0200 Commit: Corinna Vinschen CommitDate: Fri Sep 8 22:41:21 2023 +0200 Cygwin: fix an ugly cast =20 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. =20 Signed-off-by: Corinna Vinschen 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; }