Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:26612 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 50095 invoked by uid 1010); 15 Nov 2006 18:37:33 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 50080 invoked from network); 15 Nov 2006 18:37:33 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 15 Nov 2006 18:37:33 -0000 Authentication-Results: pb1.pair.com header.from=kingwez@gmail.com; sender-id=pass; domainkeys=good Authentication-Results: pb1.pair.com smtp.mail=kingwez@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 64.233.182.189 as permitted sender) DomainKey-Status: good X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: kingwez@gmail.com X-Host-Fingerprint: 64.233.182.189 nf-out-0910.google.com Linux 2.4/2.6 Received: from [64.233.182.189] ([64.233.182.189:29081] helo=nf-out-0910.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 54/E9-21305-B6E5B554 for ; Wed, 15 Nov 2006 13:37:32 -0500 Received: by nf-out-0910.google.com with SMTP id l35so802583nfa for ; Wed, 15 Nov 2006 10:37:28 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=bpTcCD1azJkxQdb6s8a6yLOF+ONdnip4+c4N+FadMi6marDLj22qCSNhk+4vCn68z0Qk3f52Qg67sH02idqF9XnYfBMmUjoTz5O5EPhzuXiW03NUbZanZjcRqMfRNwEpwx0f2tMMMAQe7n78epdctnYTYGsnHaTk+IGr0DnntPs= Received: by 10.82.107.15 with SMTP id f15mr244698buc.1163615847844; Wed, 15 Nov 2006 10:37:27 -0800 (PST) Received: by 10.82.167.13 with HTTP; Wed, 15 Nov 2006 10:37:27 -0800 (PST) Message-ID: <4e89b4260611151037r6529e142w349440bf5f5c1843@mail.gmail.com> Date: Wed, 15 Nov 2006 13:37:27 -0500 To: Pierre Cc: php-dev , "Dmitry Stogov" In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: Subject: Re: Windows SAPI possible binary file operation bug and possible fix From: kingwez@gmail.com ("Wez Furlong") We cannot change it in SAPI where we are not the .exe because we don't own the process. Messing with that flag affects the entire process and could break things at a higher level. I call this kind of thing "library abuse", where one piece of code assumes that it is the only consumer of the library. In a modular application, this is not the case. I think your actual bug is elsewhere, and that the binary flag isn't being explicitly set on a stdio file handle somewhere in the zip library code. I'm -1 on making this change to the other SAPI. Incidentally, using stdio is not portable in a server application that might have more than 255 open files at one time. Best to use the streams layer throughout if possible. --Wez. On 11/15/06, Pierre wrote: > Hello, > > While debugging a zip bug (http://pecl.php.net/bugs/bug.php?id=9278), > I was wondering what's the difference between CLI/CGI and ISAPI or > Apache2. The same code works perfectly in CLI and CGI on windows and > using all SAPIs on linux (apache1 or 2, cli, cgi). It was not that > obvious, even after having read the MS manual. > > The problem seems to be the default mode for the file operation and > the binary mode being ignored by windows ("rb" or "wb"). > > We only force the default mode in Embed, CLI and CGI. I would suggest > to do it as well in all SAPIs: > ./sapi/cgi/cgi_main.c:1042: _fmode = _O_BINARY; /* sets default > for file streams to binary */ > ./sapi/cli/php_cli.c:626: _fmode = _O_BINARY; > /*sets default for file streams to binary */ > ./sapi/embed/php_embed.c:157: _fmode = _O_BINARY; > /*sets default for file streams to binary */ > > _fmode is global per process. We should set the mode of stdin/out: > > _setmode( _fileno( stdin ), _O_BINARY ); > > If we need it and if it is already opened when we init the SAPI, but > someone has to verify this point. > > I do not have the time to test it now, but it should also solve a > couple of other issues in HEAD. I can write a patch and commit if we > agree on this fix. > > Thanks for your upcoming comments, > > --Pierre > [1] http://msdn2.microsoft.com/en-us/library/z5hh6ee9(VS.80).aspx >