pollita Thu Nov 17 14:40:52 2005 EDT
Modified files: (Branch: PHP_5_0)
/php-src/ext/standard php_fopen_wrapper.c
Log:
MFH (r-1.51) #32371 php://input sometimes returns duplicate data
http://cvs.php.net/diff.php/php-src/ext/standard/php_fopen_wrapper.c?r1=1.44&r2=1.44.2.1&ty=u
Index: php-src/ext/standard/php_fopen_wrapper.c
diff -u php-src/ext/standard/php_fopen_wrapper.c:1.44
php-src/ext/standard/php_fopen_wrapper.c:1.44.2.1
--- php-src/ext/standard/php_fopen_wrapper.c:1.44 Mon Apr 19 13:41:39 2004
+++ php-src/ext/standard/php_fopen_wrapper.c Thu Nov 17 14:40:52 2005
@@ -17,7 +17,7 @@
| Hartmut Holzgraefe <[EMAIL PROTECTED]> |
+----------------------------------------------------------------------+
*/
-/* $Id: php_fopen_wrapper.c,v 1.44 2004/04/19 17:41:39 wez Exp $ */
+/* $Id: php_fopen_wrapper.c,v 1.44.2.1 2005/11/17 19:40:52 pollita Exp $ */
#include <stdio.h>
#include <stdlib.h>
@@ -73,17 +73,19 @@
static size_t php_stream_input_read(php_stream *stream, char *buf, size_t
count TSRMLS_DC)
{
+ off_t *position = (off_t*)stream->abstract;
size_t read_bytes = 0;
+
if(!stream->eof) {
if(SG(request_info).raw_post_data) { /* data has already been
read by a post handler */
- read_bytes = SG(request_info).raw_post_data_length -
stream->position;
+ read_bytes = SG(request_info).raw_post_data_length -
*position;
if(read_bytes <= count) {
stream->eof = 1;
} else {
read_bytes = count;
}
if(read_bytes) {
- memcpy(buf, SG(request_info).raw_post_data +
stream->position, read_bytes);
+ memcpy(buf, SG(request_info).raw_post_data +
*position, read_bytes);
}
} else if(sapi_module.read_post) {
read_bytes = sapi_module.read_post(buf, count
TSRMLS_CC);
@@ -96,12 +98,15 @@
}
}
+ *position += read_bytes;
SG(read_post_bytes) += read_bytes;
return read_bytes;
}
static int php_stream_input_close(php_stream *stream, int close_handle
TSRMLS_DC)
{
+ efree(stream->abstract);
+
return 0;
}
@@ -162,7 +167,7 @@
}
if (!strcasecmp(path, "input")) {
- return php_stream_alloc(&php_stream_input_ops, NULL, 0, "rb");
+ return php_stream_alloc(&php_stream_input_ops, ecalloc(1,
sizeof(off_t)), 0, "rb");
}
if (!strcasecmp(path, "stdin")) {
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php