Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:45450 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 64447 invoked from network); 2 Sep 2009 21:02:34 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 2 Sep 2009 21:02:34 -0000 Authentication-Results: pb1.pair.com smtp.mail=garretts@microsoft.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=garretts@microsoft.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain microsoft.com designates 131.107.115.215 as permitted sender) X-PHP-List-Original-Sender: garretts@microsoft.com X-Host-Fingerprint: 131.107.115.215 mail2.microsoft.com Received: from [131.107.115.215] ([131.107.115.215:33340] helo=smtp.microsoft.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id DE/51-56016-36DDE9A4 for ; Wed, 02 Sep 2009 17:02:30 -0400 Received: from TK5EX14MLTC104.redmond.corp.microsoft.com (157.54.79.159) by TK5-EXGWY-E802.partners.extranet.microsoft.com (10.251.56.168) with Microsoft SMTP Server (TLS) id 8.2.176.0; Wed, 2 Sep 2009 14:02:25 -0700 Received: from TK5EX14MBXC127.redmond.corp.microsoft.com ([169.254.6.236]) by TK5EX14MLTC104.redmond.corp.microsoft.com ([157.54.79.159]) with mapi; Wed, 2 Sep 2009 14:02:24 -0700 To: 'PHP Internals' Thread-Topic: Fix for 49148 (combination of stream_get_line and fseek does not work correctly) Thread-Index: AcosEKsmvtGDKo0xQKO0mDhQAZrLFQ== Date: Wed, 2 Sep 2009 21:02:23 +0000 Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: Content-Type: multipart/alternative; boundary="_000_BC1CAE3856F0A143808A7796D62870A3016BCE55TK5EX14MBXC127r_" MIME-Version: 1.0 Subject: Fix for 49148 (combination of stream_get_line and fseek does not work correctly) From: garretts@microsoft.com (Garrett Serack) --_000_BC1CAE3856F0A143808A7796D62870A3016BCE55TK5EX14MBXC127r_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable I finally got to the bottom of this bug. It was hiding nice and deep. I thought I'd run this by folks first before committing, as it impacts stre= ams, which are pretty important :D . It passes the current tests, and I wro= te test for it too. (below). Index: main/streams/streams.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- main/streams/streams.c (revision 287973) +++ main/streams/streams.c (working copy) @@ -901,10 +901,7 @@ } if (!e) { - if (seek_len < maxlen && !stream->eof) { - return NULL; - } - toread =3D maxlen; + toread =3D (seek_len < maxlen) ? seek_len : maxlen; } else { toread =3D e - (char *) stream->readbuf - stream->r= eadpos; skip =3D 1; =3D=3D=3D=3D=3D=3D=3D/ext/standard/tests/streams/bug49148.phpt:=3D=3D=3D=3D= =3D=3D=3D --TEST-- Bug #49148 (combination of stream_get_line and fseek does not work correctl= y) --FILE-- --EXPECT-- string(5) "line1" string(0) "" string(5) "line1" string(0) "" string(5) "line1" string(5) "line2" string(5) "line1" string(5) "line2" string(5) "line1" string(5) "line2" string(5) "line1" string(5) "line2" Garrett --_000_BC1CAE3856F0A143808A7796D62870A3016BCE55TK5EX14MBXC127r_--