From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2155) id 773AD3857C48; Fri, 19 Feb 2021 17:15:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 773AD3857C48 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Corinna Vinschen To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin] Cygwin: default to O_BINARY in fhandler_base::reset_to_open_binmode() X-Act-Checkin: newlib-cygwin X-Git-Author: Corinna Vinschen X-Git-Refname: refs/heads/master X-Git-Oldrev: b56a371436192c965984013682043412cb22fc57 X-Git-Newrev: 543e39bb129ac77e29e3800a468100a754ad3d2a Message-Id: <20210219171528.773AD3857C48@sourceware.org> Date: Fri, 19 Feb 2021 17:15:28 +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: Fri, 19 Feb 2021 17:15:28 -0000 https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=543e39bb129ac77e29e3800a468100a754ad3d2a commit 543e39bb129ac77e29e3800a468100a754ad3d2a Author: Corinna Vinschen Date: Fri Feb 19 18:12:37 2021 +0100 Cygwin: default to O_BINARY in fhandler_base::reset_to_open_binmode() This only affects the very seldom bordercase of apps calling setmode(fd, 0) on fhandlers not calling fhandler_base::set_open_status(). All fhandlers not calling set_open_status() are binary mode only, but the way reset_to_open_binmode worked, calling setmode(fd, 0) would have "reset" their open flags to O_TEXT accidentally. Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/fhandler.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h index 5d095d384..12c45a5d7 100644 --- a/winsup/cygwin/fhandler.h +++ b/winsup/cygwin/fhandler.h @@ -274,7 +274,8 @@ class fhandler_base void reset_to_open_binmode () { set_flags ((get_flags () & ~(O_TEXT | O_BINARY)) - | ((open_status.wbinary || open_status.rbinary) + | (((open_status.wbinset ? open_status.wbinary : 1) + || (open_status.rbinset ? open_status.rbinary : 1)) ? O_BINARY : O_TEXT)); }