]> granicus.if.org Git - php/commitdiff
correct fix for bug #43522
authorAntony Dovgal <tony2001@php.net>
Sat, 29 Dec 2007 10:52:51 +0000 (10:52 +0000)
committerAntony Dovgal <tony2001@php.net>
Sat, 29 Dec 2007 10:52:51 +0000 (10:52 +0000)
NEWS
main/streams/streams.c

diff --git a/NEWS b/NEWS
index 5abd8a01b8c9c282c4e690156863a8abe08f0cc2..8620bd43463ecca95159a2f3a67182eb4fc7927d 100644 (file)
--- 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
index 39780cd5a4a2715ac4fe6138849e7d3c37f26897..332cc082b474077f06f48a0e4dca2930a88c62dc 100755 (executable)
@@ -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) {