lbarnaud Mon Nov 3 23:29:50 2008 UTC
Added files: (Branch: PHP_5_2)
/php-src/ext/standard/tests/file bug44607.phpt
Modified files:
/php-src/main/streams streams.c
/php-src NEWS
Log:
MFH: Fixed bug #44607 (stream_get_line unable to correctly identify the
"ending" in the stream content)
http://cvs.php.net/viewvc.cgi/php-src/main/streams/streams.c?r1=1.82.2.6.2.27&r2=1.82.2.6.2.28&diff_format=u
Index: php-src/main/streams/streams.c
diff -u php-src/main/streams/streams.c:1.82.2.6.2.27
php-src/main/streams/streams.c:1.82.2.6.2.28
--- php-src/main/streams/streams.c:1.82.2.6.2.27 Mon Nov 3 15:48:05 2008
+++ php-src/main/streams/streams.c Mon Nov 3 23:29:50 2008
@@ -19,7 +19,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: streams.c,v 1.82.2.6.2.27 2008/11/03 15:48:05 lbarnaud Exp $ */
+/* $Id: streams.c,v 1.82.2.6.2.28 2008/11/03 23:29:50 lbarnaud Exp $ */
#define _GNU_SOURCE
#include "php.h"
@@ -531,16 +531,16 @@
efree(chunk_buf);
} else {
+ /* reduce buffer memory consumption if possible, to avoid a
realloc */
+ if (stream->readbuf && stream->readbuflen - stream->writepos <
stream->chunk_size) {
+ memmove(stream->readbuf, stream->readbuf +
stream->readpos, stream->readbuflen - stream->readpos);
+ stream->writepos -= stream->readpos;
+ stream->readpos = 0;
+ }
/* is there enough data in the buffer ? */
- if (stream->writepos - stream->readpos < (off_t)size) {
+ while (stream->writepos - stream->readpos < (off_t)size) {
size_t justread = 0;
-
- /* reduce buffer memory consumption if possible, to
avoid a realloc */
- if (stream->readbuf && stream->readbuflen -
stream->writepos < stream->chunk_size) {
- memmove(stream->readbuf, stream->readbuf +
stream->readpos, stream->readbuflen - stream->readpos);
- stream->writepos -= stream->readpos;
- stream->readpos = 0;
- }
+ size_t toread;
/* grow the buffer if required
* TODO: this can fail for persistent streams */
@@ -550,13 +550,17 @@
stream->is_persistent);
}
+ toread = stream->readbuflen - stream->writepos;
justread = stream->ops->read(stream, stream->readbuf +
stream->writepos,
- stream->readbuflen - stream->writepos
+ toread
TSRMLS_CC);
if (justread != (size_t)-1) {
stream->writepos += justread;
}
+ if (stream->eof || justread != toread) {
+ break;
+ }
}
}
}
http://cvs.php.net/viewvc.cgi/php-src/NEWS?r1=1.2027.2.547.2.1299&r2=1.2027.2.547.2.1300&diff_format=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.2027.2.547.2.1299 php-src/NEWS:1.2027.2.547.2.1300
--- php-src/NEWS:1.2027.2.547.2.1299 Mon Nov 3 23:26:23 2008
+++ php-src/NEWS Mon Nov 3 23:29:50 2008
@@ -26,6 +26,8 @@
(Arnaud)
- Fixed bug #44938 (gettext functions crash with overly long domain).
(Christian Schneider, Ilia)
+- Fixed bug #44607 (stream_get_line unable to correctly identify the "ending"
+ in the stream content). (Arnaud)
- Fixed bug #44327 (PDORow::queryString property & numeric offsets / Crash).
(Felipe)
- Fixed bug #43452 (strings containing a weekday, or a number plus weekday
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/bug44607.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/file/bug44607.phpt
+++ php-src/ext/standard/tests/file/bug44607.phpt
--TEST--
Bug #44607 (stream_get_line unable to correctly identify the "ending" in the
stream content)
--FILE--
<?php
$eol = '<EOL>';
$tempnam = tempnam(sys_get_temp_dir(), 'php');
$data = str_repeat('.', 14000);
$data .= $eol;
$data .= $data;
file_put_contents($tempnam, $data);
$fd = fopen($tempnam, 'r');
var_dump(strlen(stream_get_line($fd, 15000, $eol)));
var_dump(strlen(stream_get_line($fd, 15000, $eol)));
fseek($fd, 1, SEEK_SET);
var_dump(strlen(stream_get_line($fd, 15000, $eol)));
var_dump(strlen(stream_get_line($fd, 15000, $eol)));
?>
--EXPECT--
int(14000)
int(14000)
int(13999)
int(14000)
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php