Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:26606 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 32948 invoked by uid 1010); 15 Nov 2006 16:07:31 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 32933 invoked from network); 15 Nov 2006 16:07:31 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 15 Nov 2006 16:07:31 -0000 Authentication-Results: pb1.pair.com smtp.mail=pierre.php@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=pierre.php@gmail.com; sender-id=pass; domainkeys=good Received-SPF: pass (pb1.pair.com: domain gmail.com designates 64.233.184.238 as permitted sender) DomainKey-Status: good X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: pierre.php@gmail.com X-Host-Fingerprint: 64.233.184.238 wr-out-0506.google.com Linux 2.4/2.6 Received: from [64.233.184.238] ([64.233.184.238:35910] helo=wr-out-0506.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 87/35-03517-F3B3B554 for ; Wed, 15 Nov 2006 11:07:29 -0500 Received: by wr-out-0506.google.com with SMTP id i32so50387wra for ; Wed, 15 Nov 2006 08:07:25 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=Kq6cGFddy3X/0nLIlZxTRJCkeReLH32vxvRYpUlp3suoB+aMfPjysJdEXz7gclFyT7xfSzGzxBL2JvCqggFe3l3xTBTqf0DOLUpwD3z+bxJH1z6UDvK4//qnQw0/TWbEpiguBZ2grLluS8/zl2o2SVYU/BiOJJZ5pWMEIqFwIUE= Received: by 10.78.50.5 with SMTP id x5mr348842hux.1163606844361; Wed, 15 Nov 2006 08:07:24 -0800 (PST) Received: by 10.78.137.6 with HTTP; Wed, 15 Nov 2006 08:07:24 -0800 (PST) Message-ID: Date: Wed, 15 Nov 2006 17:07:24 +0100 To: php-dev , "Wez Furlong" , "Dmitry Stogov" MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline Subject: Windows SAPI possible binary file operation bug and possible fix From: pierre.php@gmail.com (Pierre) 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