cellog          Mon Sep 22 01:26:14 2008 UTC

  Modified files:              (Branch: PHP_5_3)
    /php-src    NEWS 
    /php-src/main/streams       filter.c streams.c 
  Log:
  MF52 fix Bug #46147: after stream seek, appending stream filter reads 
incorrect data
  
http://cvs.php.net/viewvc.cgi/php-src/NEWS?r1=1.2027.2.547.2.965.2.328&r2=1.2027.2.547.2.965.2.329&diff_format=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.2027.2.547.2.965.2.328 
php-src/NEWS:1.2027.2.547.2.965.2.329
--- php-src/NEWS:1.2027.2.547.2.965.2.328       Sun Sep 21 18:13:45 2008
+++ php-src/NEWS        Mon Sep 22 01:26:13 2008
@@ -10,6 +10,8 @@
 
 - Fixed bug causing the algorithm parameter of mhash() to be modified. (Scott)
 
+- Fixed Bug #46147 (after stream seek, appending stream filter reads incorrect 
data).
+  (Greg)
 - Fixed bug #46115 (Memory leak when calling a method using Reflection).
   (Dmitry)
 - Fixed bug #46106 (Memory leaks when using global statement). (Dmitry)
http://cvs.php.net/viewvc.cgi/php-src/main/streams/filter.c?r1=1.17.2.3.2.10.2.1&r2=1.17.2.3.2.10.2.2&diff_format=u
Index: php-src/main/streams/filter.c
diff -u php-src/main/streams/filter.c:1.17.2.3.2.10.2.1 
php-src/main/streams/filter.c:1.17.2.3.2.10.2.2
--- php-src/main/streams/filter.c:1.17.2.3.2.10.2.1     Mon Dec 31 07:17:17 2007
+++ php-src/main/streams/filter.c       Mon Sep 22 01:26:14 2008
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: filter.c,v 1.17.2.3.2.10.2.1 2007/12/31 07:17:17 sebastian Exp $ */
+/* $Id: filter.c,v 1.17.2.3.2.10.2.2 2008/09/22 01:26:14 cellog Exp $ */
 
 #include "php.h"
 #include "php_globals.h"
@@ -381,15 +381,12 @@
                                stream->writepos = 0;
                                break;
                        case PSFS_PASS_ON:
-                               /* Put any filtered data onto the readbuffer 
stack.
-                                  Previously read data has been at least 
partially consumed. */
-                               stream->readpos += consumed;
-
-                               if (stream->writepos == stream->readpos) {
-                                       /* Entirely consumed */
-                                       stream->writepos = 0;
-                                       stream->readpos = 0;
-                               }
+                               /* If any data is consumed, we cannot rely upon 
the existing read buffer,
+                                  as the filtered data must replace the 
existing data, so invalidate the cache */
+                               /* note that changes here should be reflected in
+                                  
main/streams/streams.c::php_stream_fill_read_buffer */
+                               stream->writepos = 0;
+                               stream->readpos = 0;
 
                                while (brig_outp->head) {
                                        bucket = brig_outp->head;
http://cvs.php.net/viewvc.cgi/php-src/main/streams/streams.c?r1=1.82.2.6.2.18.2.14&r2=1.82.2.6.2.18.2.15&diff_format=u
Index: php-src/main/streams/streams.c
diff -u php-src/main/streams/streams.c:1.82.2.6.2.18.2.14 
php-src/main/streams/streams.c:1.82.2.6.2.18.2.15
--- php-src/main/streams/streams.c:1.82.2.6.2.18.2.14   Tue Aug 26 16:06:36 2008
+++ php-src/main/streams/streams.c      Mon Sep 22 01:26:14 2008
@@ -19,7 +19,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: streams.c,v 1.82.2.6.2.18.2.14 2008/08/26 16:06:36 dsp Exp $ */
+/* $Id: streams.c,v 1.82.2.6.2.18.2.15 2008/09/22 01:26:14 cellog Exp $ */
 
 #define _GNU_SOURCE
 #include "php.h"
@@ -448,6 +448,10 @@
                php_stream_bucket_brigade brig_in = { NULL, NULL }, brig_out = 
{ NULL, NULL };
                php_stream_bucket_brigade *brig_inp = &brig_in, *brig_outp = 
&brig_out, *brig_swap;
 
+               /* Invalidate the existing cache, otherwise reads can fail, see 
note in
+                  main/streams/filter.c::_php_stream_filter_append */
+               stream->writepos = stream->readpos = 0;
+
                /* allocate a buffer for reading chunks */
                chunk_buf = emalloc(stream->chunk_size);
 



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to