From: Antony Dovgal Date: Sat, 29 Dec 2007 10:52:51 +0000 (+0000) Subject: correct fix for bug #43522 X-Git-Tag: php-5.2.6RC1~212 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6db1f40e3204d6cc6cfd481765fbfec17f909db5;p=php correct fix for bug #43522 --- diff --git a/NEWS b/NEWS index 5abd8a01b8..8620bd4346 100644 --- a/NEWS +++ b/NEWS @@ -14,7 +14,7 @@ PHP NEWS function). (Ilia) - Fixed bug #43533 (escapeshellarg('') returns null). (Ilia) - Fixed bug #43522 (stream_get_line() eats additional characters). (Felipe, - Ilia) + Ilia, Tony) - Fixed bug #43495 (array_merge_recursive() crashes with recursive arrays). (Ilia) - Fixed bug #43493 (pdo_pgsql does not send username on connect when password diff --git a/main/streams/streams.c b/main/streams/streams.c index 39780cd5a4..332cc082b4 100755 --- a/main/streams/streams.c +++ b/main/streams/streams.c @@ -855,10 +855,17 @@ PHPAPI char *php_stream_get_record(php_stream *stream, size_t maxlen, size_t *re if (delim_len == 0 || !delim) { toread = maxlen; } else { + size_t seek_len; + + seek_len = stream->writepos - stream->readpos; + if (seek_len > maxlen) { + seek_len = maxlen; + } + if (delim_len == 1) { - e = memchr(stream->readbuf + stream->readpos, *delim, maxlen); + e = memchr(stream->readbuf + stream->readpos, *delim, seek_len); } else { - e = php_memnstr(stream->readbuf + stream->readpos, delim, delim_len, (stream->readbuf + stream->readpos + maxlen)); + e = php_memnstr(stream->readbuf + stream->readpos, delim, delim_len, (stream->readbuf + stream->readpos + seek_len)); } if (!e) {