[PHP-CVS] cvs: php-src /main/streams streams.c
lbarnaudTue May 19 10:04:35 2009 UTC Modified files: /php-src/main/streams streams.c Log: Fix build http://cvs.php.net/viewvc.cgi/php-src/main/streams/streams.c?r1=1.186r2=1.187diff_format=u Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.186 php-src/main/streams/streams.c:1.187 --- php-src/main/streams/streams.c:1.186Sun May 17 16:52:35 2009 +++ php-src/main/streams/streams.c Tue May 19 10:04:35 2009 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: streams.c,v 1.186 2009/05/17 16:52:35 lbarnaud Exp $ */ +/* $Id: streams.c,v 1.187 2009/05/19 10:04:35 lbarnaud Exp $ */ #define _GNU_SOURCE #include php.h @@ -1857,7 +1857,11 @@ } towrite -= didwrite; - writeptr.v += ZBYTES(utype, didwrite); + if (utype == IS_UNICODE) { + writeptr.u += didwrite; + } else { + writeptr.s += didwrite; + } } } else { break; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /main/streams streams.c
lbarnaudThu Mar 19 17:54:28 2009 UTC Modified files: /php-src/main/streams streams.c Log: Better fix for #44607. Fixes #47487 (php_stream_fill_read_buffer() performance degraded after fix of bug 44607). http://cvs.php.net/viewvc.cgi/php-src/main/streams/streams.c?r1=1.179r2=1.180diff_format=u Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.179 php-src/main/streams/streams.c:1.180 --- php-src/main/streams/streams.c:1.179Tue Mar 10 23:40:01 2009 +++ php-src/main/streams/streams.c Thu Mar 19 17:54:28 2009 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: streams.c,v 1.179 2009/03/10 23:40:01 helly Exp $ */ +/* $Id: streams.c,v 1.180 2009/03/19 17:54:28 lbarnaud Exp $ */ #define _GNU_SOURCE #include php.h @@ -551,16 +551,16 @@ efree(chunk_buf); } else {/* Unfiltered Binary stream */ - /* reduce buffer memory consumption if possible, to avoid a realloc */ - if (stream-readbuf.s stream-readbuflen - stream-writepos stream-chunk_size) { - memmove(stream-readbuf.s, stream-readbuf.s + stream-readpos, stream-writepos - stream-readpos); - stream-writepos -= stream-readpos; - stream-readpos = 0; - } /* is there enough data in the buffer ? */ - while (stream-writepos - stream-readpos (off_t)size) { + if (stream-writepos - stream-readpos (off_t)size) { size_t justread = 0; - size_t toread; + + /* reduce buffer memory consumption if possible, to avoid a realloc */ + if (stream-readbuf.s stream-readbuflen - stream-writepos stream-chunk_size) { + memmove(stream-readbuf.s, stream-readbuf.s + stream-readpos, stream-writepos - stream-readpos); + stream-writepos -= stream-readpos; + stream-readpos = 0; + } /* grow the buffer if required * TODO: this can fail for persistent streams */ @@ -569,15 +569,10 @@ stream-readbuf.s = (char*)perealloc(stream-readbuf.s, stream-readbuflen, stream-is_persistent); } - toread = stream-readbuflen - stream-writepos; - justread = stream-ops-read(stream, stream-readbuf.s + stream-writepos, toread TSRMLS_CC); - - if (justread != (size_t)-1) { + justread = stream-ops-read(stream, stream-readbuf.s + stream-writepos, stream-readbuflen - stream-writepos TSRMLS_CC); + if (justread != (size_t)-1 justread != 0) { stream-writepos += justread; } - if (stream-eof || justread != toread) { - break; - } } } } @@ -1114,10 +1109,25 @@ PHPAPI char *php_stream_get_record(php_stream *stream, size_t maxlen, size_t *returned_len, char *delim, size_t delim_len TSRMLS_DC) { char *e, *buf; - size_t toread; + size_t toread, len; int skip = 0; - php_stream_fill_read_buffer(stream, maxlen TSRMLS_CC); + len = stream-writepos - stream-readpos; + + while (len maxlen) { + + size_t just_read; + toread = MIN(maxlen - len, stream-chunk_size); + + php_stream_fill_read_buffer(stream, len + toread TSRMLS_CC); + + just_read = (stream-writepos - stream-readpos) - len; + len += just_read; + + if (just_read toread) { + break; + } + } if (delim_len == 0 || !delim) { toread = maxlen; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /main/streams streams.c
felipe Thu Jan 8 18:43:12 2009 UTC Modified files: /php-src/main/streams streams.c Log: - Fixed bug #47037 (No error when using fopen with emty string) Patch by Cristian Rodriguez R. http://cvs.php.net/viewvc.cgi/php-src/main/streams/streams.c?r1=1.177r2=1.178diff_format=u Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.177 php-src/main/streams/streams.c:1.178 --- php-src/main/streams/streams.c:1.177Wed Dec 31 11:12:39 2008 +++ php-src/main/streams/streams.c Thu Jan 8 18:43:12 2009 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: streams.c,v 1.177 2008/12/31 11:12:39 sebastian Exp $ */ +/* $Id: streams.c,v 1.178 2009/01/08 18:43:12 felipe Exp $ */ #define _GNU_SOURCE #include php.h @@ -2387,6 +2387,7 @@ } if (!path || !*path) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, Filename cannot be empty); return NULL; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /main/streams streams.c xp_socket.c
dsp Mon Nov 24 15:35:03 2008 UTC Modified files: /php-src/main/streams streams.c xp_socket.c Log: Revert fix for 43782, as it caused problems. [DOC] We better document the issue at it is. http://cvs.php.net/viewvc.cgi/php-src/main/streams/streams.c?r1=1.174r2=1.175diff_format=u Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.174 php-src/main/streams/streams.c:1.175 --- php-src/main/streams/streams.c:1.174Tue Nov 11 01:55:19 2008 +++ php-src/main/streams/streams.c Mon Nov 24 15:35:03 2008 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: streams.c,v 1.174 2008/11/11 01:55:19 lbarnaud Exp $ */ +/* $Id: streams.c,v 1.175 2008/11/24 15:35:03 dsp Exp $ */ #define _GNU_SOURCE #include php.h @@ -840,7 +840,7 @@ /* use the configured timeout when checking eof */ if (!stream-eof PHP_STREAM_OPTION_RETURN_ERR == php_stream_set_option(stream, PHP_STREAM_OPTION_CHECK_LIVENESS, - -1, NULL)) { + 0, NULL)) { stream-eof = 1; } http://cvs.php.net/viewvc.cgi/php-src/main/streams/xp_socket.c?r1=1.48r2=1.49diff_format=u Index: php-src/main/streams/xp_socket.c diff -u php-src/main/streams/xp_socket.c:1.48 php-src/main/streams/xp_socket.c:1.49 --- php-src/main/streams/xp_socket.c:1.48 Tue Aug 26 16:06:23 2008 +++ php-src/main/streams/xp_socket.cMon Nov 24 15:35:03 2008 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: xp_socket.c,v 1.48 2008/08/26 16:06:23 dsp Exp $ */ +/* $Id: xp_socket.c,v 1.49 2008/11/24 15:35:03 dsp Exp $ */ #include php.h #include ext/standard/file.h @@ -280,12 +280,8 @@ if (sock-socket == -1) { alive = 0; - } else { - if (php_pollfd_for(sock-socket, PHP_POLLREADABLE|POLLPRI, tv) 0) { - if (0 == recv(sock-socket, buf, sizeof(buf), MSG_PEEK) php_socket_errno() != EAGAIN) { - alive = 0; - } - } else { + } else if (php_pollfd_for(sock-socket, PHP_POLLREADABLE|POLLPRI, tv) 0) { + if (0 == recv(sock-socket, buf, sizeof(buf), MSG_PEEK) php_socket_errno() != EAGAIN) { alive = 0; } } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /main/streams streams.c xp_socket.c
dsp Tue Aug 26 16:06:23 2008 UTC Modified files: /php-src/main/streams streams.c xp_socket.c Log: Fixed bug #43782 (feof() does not detect timeout on socket) # Poll returns 0 if it times out. # We check for 0 and use the user set timeout in set_options by passing -1. http://cvs.php.net/viewvc.cgi/php-src/main/streams/streams.c?r1=1.168r2=1.169diff_format=u Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.168 php-src/main/streams/streams.c:1.169 --- php-src/main/streams/streams.c:1.168Wed Aug 6 09:03:36 2008 +++ php-src/main/streams/streams.c Tue Aug 26 16:06:23 2008 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: streams.c,v 1.168 2008/08/06 09:03:36 tony2001 Exp $ */ +/* $Id: streams.c,v 1.169 2008/08/26 16:06:23 dsp Exp $ */ #define _GNU_SOURCE #include php.h @@ -831,7 +831,7 @@ /* use the configured timeout when checking eof */ if (!stream-eof PHP_STREAM_OPTION_RETURN_ERR == php_stream_set_option(stream, PHP_STREAM_OPTION_CHECK_LIVENESS, - 0, NULL)) { + -1, NULL)) { stream-eof = 1; } http://cvs.php.net/viewvc.cgi/php-src/main/streams/xp_socket.c?r1=1.47r2=1.48diff_format=u Index: php-src/main/streams/xp_socket.c diff -u php-src/main/streams/xp_socket.c:1.47 php-src/main/streams/xp_socket.c:1.48 --- php-src/main/streams/xp_socket.c:1.47 Wed Jul 16 14:08:04 2008 +++ php-src/main/streams/xp_socket.cTue Aug 26 16:06:23 2008 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: xp_socket.c,v 1.47 2008/07/16 14:08:04 jani Exp $ */ +/* $Id: xp_socket.c,v 1.48 2008/08/26 16:06:23 dsp Exp $ */ #include php.h #include ext/standard/file.h @@ -280,8 +280,12 @@ if (sock-socket == -1) { alive = 0; - } else if (php_pollfd_for(sock-socket, PHP_POLLREADABLE|POLLPRI, tv) 0) { - if (0 == recv(sock-socket, buf, sizeof(buf), MSG_PEEK) php_socket_errno() != EAGAIN) { + } else { + if (php_pollfd_for(sock-socket, PHP_POLLREADABLE|POLLPRI, tv) 0) { + if (0 == recv(sock-socket, buf, sizeof(buf), MSG_PEEK) php_socket_errno() != EAGAIN) { + alive = 0; + } + } else { alive = 0; } } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /main/streams streams.c
tony2001Wed Aug 6 09:03:37 2008 UTC Modified files: /php-src/main/streams streams.c Log: increase context refcount before open() to avoid crash when open() fails and destroys the context http://cvs.php.net/viewvc.cgi/php-src/main/streams/streams.c?r1=1.167r2=1.168diff_format=u Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.167 php-src/main/streams/streams.c:1.168 --- php-src/main/streams/streams.c:1.167Fri Jul 11 12:40:20 2008 +++ php-src/main/streams/streams.c Wed Aug 6 09:03:36 2008 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: streams.c,v 1.167 2008/07/11 12:40:20 tony2001 Exp $ */ +/* $Id: streams.c,v 1.168 2008/08/06 09:03:36 tony2001 Exp $ */ #define _GNU_SOURCE #include php.h @@ -2414,14 +2414,22 @@ php_stream_wrapper_log_error(wrapper, options ^ REPORT_ERRORS TSRMLS_CC, wrapper does not support stream open); } else { + /* refcount++ to make sure the context doesn't get destroyed +* if open() fails and stream is closed */ + if (context) { + zend_list_addref(context-rsrc_id); + } + stream = wrapper-wops-stream_opener(wrapper, path_to_open, implicit_mode, options ^ REPORT_ERRORS, opened_path, context STREAMS_REL_CC TSRMLS_CC); - } - /* increase context refcount only if the context is really used */ - if (stream stream-context) { - zend_list_addref(stream-context-rsrc_id); + /* if open() succeeded and context was not used, do refcount-- +* XXX if a wrapper didn't actually use context (no way to know that) +* and open() failed, refcount will stay increased */ + if (context stream !stream-context) { + zend_list_delete(context-rsrc_id); + } } /* if the caller asked for a persistent stream but the wrapper did not -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /main/streams streams.c
tony2001Fri Jul 11 12:40:20 2008 UTC Modified files: /php-src/main/streams streams.c Log: not all stream wrappers use context, so no need to addref in all cases http://cvs.php.net/viewvc.cgi/php-src/main/streams/streams.c?r1=1.166r2=1.167diff_format=u Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.166 php-src/main/streams/streams.c:1.167 --- php-src/main/streams/streams.c:1.166Fri Jul 11 10:24:29 2008 +++ php-src/main/streams/streams.c Fri Jul 11 12:40:20 2008 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: streams.c,v 1.166 2008/07/11 10:24:29 tony2001 Exp $ */ +/* $Id: streams.c,v 1.167 2008/07/11 12:40:20 tony2001 Exp $ */ #define _GNU_SOURCE #include php.h @@ -2419,8 +2419,9 @@ opened_path, context STREAMS_REL_CC TSRMLS_CC); } - if (context) { - zend_list_addref(context-rsrc_id); + /* increase context refcount only if the context is really used */ + if (stream stream-context) { + zend_list_addref(stream-context-rsrc_id); } /* if the caller asked for a persistent stream but the wrapper did not -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /main/streams streams.c
stasSun Jun 8 18:21:59 2008 UTC Modified files: /php-src/main/streams streams.c Log: with unicode buffers, positions are in uchars http://cvs.php.net/viewvc.cgi/php-src/main/streams/streams.c?r1=1.163r2=1.164diff_format=u Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.163 php-src/main/streams/streams.c:1.164 --- php-src/main/streams/streams.c:1.163Mon Apr 28 22:40:10 2008 +++ php-src/main/streams/streams.c Sun Jun 8 18:21:59 2008 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: streams.c,v 1.163 2008/04/28 22:40:10 cellog Exp $ */ +/* $Id: streams.c,v 1.164 2008/06/08 18:21:59 stas Exp $ */ #define _GNU_SOURCE #include php.h @@ -509,7 +509,7 @@ stream-readbuflen += bucket-buflen; stream-readbuf.v = perealloc(stream-readbuf.v, PS_ULEN(stream-readbuf_type == IS_UNICODE, stream-readbuflen), stream-is_persistent); } - memcpy(stream-readbuf.s + stream-writepos, bucket-buf.s, PS_ULEN(stream-readbuf_type == IS_UNICODE, bucket-buflen)); + memcpy(stream-readbuf.s + PS_ULEN(stream-readbuf_type == IS_UNICODE, stream-writepos), bucket-buf.s, PS_ULEN(stream-readbuf_type == IS_UNICODE, bucket-buflen)); stream-writepos += bucket-buflen; php_stream_bucket_unlink(bucket TSRMLS_CC); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /main/streams streams.c
cellog Mon Apr 28 22:37:45 2008 UTC Modified files: /php-src/main/streams streams.c Log: MFB: Fixed potentially confusing error message on failure when no errors are logged http://cvs.php.net/viewvc.cgi/php-src/main/streams/streams.c?r1=1.161r2=1.162diff_format=u Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.161 php-src/main/streams/streams.c:1.162 --- php-src/main/streams/streams.c:1.161Thu Mar 27 10:33:52 2008 +++ php-src/main/streams/streams.c Mon Apr 28 22:37:45 2008 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: streams.c,v 1.161 2008/03/27 10:33:52 dmitry Exp $ */ +/* $Id: streams.c,v 1.162 2008/04/28 22:37:45 cellog Exp $ */ #define _GNU_SOURCE #include php.h @@ -164,7 +164,11 @@ free_msg = 1; } else { - msg = strerror(errno); + if (wrapper == php_plain_files_wrapper) { + msg = strerror(errno); + } else { + msg = operation failed; + } } } else { msg = no suitable wrapper could be found; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /main/streams streams.c
cellog Mon Apr 28 22:40:10 2008 UTC Modified files: /php-src/main/streams streams.c Log: MFB: fix erroneous use of php_resolve_path in _php_stream_wrapper_open_ex - this breaks require/include for all extensions that intercept zend_resolve_path http://cvs.php.net/viewvc.cgi/php-src/main/streams/streams.c?r1=1.162r2=1.163diff_format=u Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.162 php-src/main/streams/streams.c:1.163 --- php-src/main/streams/streams.c:1.162Mon Apr 28 22:37:45 2008 +++ php-src/main/streams/streams.c Mon Apr 28 22:40:10 2008 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: streams.c,v 1.162 2008/04/28 22:37:45 cellog Exp $ */ +/* $Id: streams.c,v 1.163 2008/04/28 22:40:10 cellog Exp $ */ #define _GNU_SOURCE #include php.h @@ -2374,7 +2374,7 @@ } if (options USE_PATH) { - resolved_path = php_resolve_path(path, strlen(path), PG(include_path) TSRMLS_CC); + resolved_path = zend_resolve_path(path, strlen(path) TSRMLS_CC); if (resolved_path) { path = resolved_path; /* we've found this file, don't re-check include_path or run realpath */ -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /main/streams streams.c
tony2001Mon Mar 24 16:28:08 2008 UTC Modified files: /php-src/main/streams streams.c Log: Change streams to not use mmap() when reading files (aka copying to memory). There are two problems with mmap() in this case: 1) there is no performance gain since we allocate the memory anyways; 2) memcpy() may crash if somebody truncates this file at the same moment (see http://dev.daylessday.org/diff/mmap.phps for example); It seems to work fine with fpassthru(), though why it is so should be investigated. Thanks to Andrey Vasilishin for the report and Anight for pressing this through =) http://cvs.php.net/viewvc.cgi/php-src/main/streams/streams.c?r1=1.159r2=1.160diff_format=u Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.159 php-src/main/streams/streams.c:1.160 --- php-src/main/streams/streams.c:1.159Sun Jan 13 22:55:02 2008 +++ php-src/main/streams/streams.c Mon Mar 24 16:28:08 2008 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: streams.c,v 1.159 2008/01/13 22:55:02 cellog Exp $ */ +/* $Id: streams.c,v 1.160 2008/03/24 16:28:08 tony2001 Exp $ */ #define _GNU_SOURCE #include php.h @@ -1648,27 +1648,6 @@ maxlen = 0; } - if (php_stream_mmap_possible(src)) { - /* guarantees src-readbuf_type == IS_STRING */ - char *p; - size_t mapped; - - p = php_stream_mmap_range(src, php_stream_tell(src), maxlen, PHP_STREAM_MAP_MODE_SHARED_READONLY, mapped); - - if (p mapped) { - *buf = pemalloc_rel_orig(mapped + 1, persistent); - - if (*buf) { - memcpy(*buf, p, mapped); - ((char*)(*buf))[mapped] = 0; - } - - php_stream_mmap_unmap(src); - - return mapped; - } - } - if (maxlen 0) { if (rettype == IS_UNICODE) { ptr.u = *buf = pemalloc_rel_orig(UBYTES(maxlen + 1), persistent); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /main/streams streams.c
tony2001Sat Dec 29 10:50:12 2007 UTC Modified files: /php-src/main/streams streams.c Log: apply correct fix for bug #43522 fix Unicode streams too this time http://cvs.php.net/viewvc.cgi/php-src/main/streams/streams.c?r1=1.155r2=1.156diff_format=u Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.155 php-src/main/streams/streams.c:1.156 --- php-src/main/streams/streams.c:1.155Mon Dec 10 14:19:20 2007 +++ php-src/main/streams/streams.c Sat Dec 29 10:50:12 2007 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: streams.c,v 1.155 2007/12/10 14:19:20 iliaa Exp $ */ +/* $Id: streams.c,v 1.156 2007/12/29 10:50:12 tony2001 Exp $ */ #define _GNU_SOURCE #include php.h @@ -1104,10 +1104,17 @@ 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.s + stream-readpos, *delim, maxlen); + e = memchr(stream-readbuf.s + stream-readpos, *delim, seek_len); } else { - e = php_memnstr(stream-readbuf.s + stream-readpos, delim, delim_len, (stream-readbuf.s + stream-readpos + maxlen)); + e = php_memnstr(stream-readbuf.s + stream-readpos, delim, delim_len, (stream-readbuf.s + stream-readpos + seek_len)); } if (!e) { @@ -1153,10 +1160,17 @@ 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 = u_memchr(stream-readbuf.u + stream-readpos, *delim, stream-writepos - stream-readpos); + e = u_memchr(stream-readbuf.u + stream-readpos, *delim, seek_len); } else { - e = u_strFindFirst(stream-readbuf.u + stream-readpos, stream-writepos - stream-readpos, delim, delim_len); + e = u_strFindFirst(stream-readbuf.u + stream-readpos, stream-readbuf.u + stream-readpos + seek_len, delim, delim_len); } if (!e) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /main/streams streams.c
helly Tue Nov 6 10:54:30 2007 UTC Modified files: /php-src/main/streams streams.c Log: - MFB ws http://cvs.php.net/viewvc.cgi/php-src/main/streams/streams.c?r1=1.153r2=1.154diff_format=u Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.153 php-src/main/streams/streams.c:1.154 --- php-src/main/streams/streams.c:1.153Wed Jul 11 14:32:54 2007 +++ php-src/main/streams/streams.c Tue Nov 6 10:54:29 2007 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: streams.c,v 1.153 2007/07/11 14:32:54 dmitry Exp $ */ +/* $Id: streams.c,v 1.154 2007/11/06 10:54:29 helly Exp $ */ #define _GNU_SOURCE #include php.h @@ -1450,12 +1450,13 @@ break; case SEEK_SET: if (offset stream-position - offset stream-position + stream-writepos - stream-readpos) { + offset stream-position + stream-writepos - stream-readpos) { stream-readpos += offset - stream-position; stream-position = offset; stream-eof = 0; return 0; } + break; } } @@ -2078,7 +2079,7 @@ php_error_docref(NULL TSRMLS_CC, E_WARNING, Use of \zlib:\ wrapper is deprecated; please use \compress.zlib://\ instead); } - if (protocol) { + if (protocol) { char *tmp = estrndup(protocol, n); if (FAILURE == zend_hash_find(wrapper_hash, (char*)tmp, n + 1, (void**)wrapperpp)) { php_strtolower(tmp, n); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /main/streams streams.c
dmitry Wed Jul 11 14:32:54 2007 UTC Modified files: /php-src/main/streams streams.c Log: Fixed wrong warning http://cvs.php.net/viewvc.cgi/php-src/main/streams/streams.c?r1=1.152r2=1.153diff_format=u Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.152 php-src/main/streams/streams.c:1.153 --- php-src/main/streams/streams.c:1.152Tue Jul 3 10:22:55 2007 +++ php-src/main/streams/streams.c Wed Jul 11 14:32:54 2007 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: streams.c,v 1.152 2007/07/03 10:22:55 dmitry Exp $ */ +/* $Id: streams.c,v 1.153 2007/07/11 14:32:54 dmitry Exp $ */ #define _GNU_SOURCE #include php.h @@ -2113,7 +2113,7 @@ #ifdef PHP_WIN32 if (localhost == 0 path[n+3] != '\0' path[n+3] != '/' path[n+4] != ':'){ #else - if (localhost == 0 path[n+3] != '/') { + if (localhost == 0 path[n+3] != '\0' path[n+3] != '/') { #endif if (options REPORT_ERRORS) { php_error_docref(NULL TSRMLS_CC, E_WARNING, remote host file access not supported, %s, path); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /main/streams streams.c
pollita Tue Mar 6 20:04:05 2007 UTC Modified files: /php-src/main/streams streams.c Log: Fix handling over overridden file:// wrapper http://cvs.php.net/viewvc.cgi/php-src/main/streams/streams.c?r1=1.149r2=1.150diff_format=u Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.149 php-src/main/streams/streams.c:1.150 --- php-src/main/streams/streams.c:1.149Sat Mar 3 18:59:53 2007 +++ php-src/main/streams/streams.c Tue Mar 6 20:04:05 2007 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: streams.c,v 1.149 2007/03/03 18:59:53 helly Exp $ */ +/* $Id: streams.c,v 1.150 2007/03/06 20:04:05 pollita Exp $ */ #define _GNU_SOURCE #include php.h @@ -2138,18 +2138,18 @@ if (options STREAM_LOCATE_WRAPPERS_ONLY) { return NULL; } - + /* The file:// wrapper may have been disabled/overridden */ - if (FG(stream_wrappers)) { - if (!wrapperpp || zend_hash_find(wrapper_hash, file, sizeof(file), (void**)wrapperpp) == FAILURE) { + if (FG(stream_wrappers)) { + if (zend_hash_find(wrapper_hash, file, sizeof(file), (void**)wrapperpp) == FAILURE) { if (options REPORT_ERRORS) { php_error_docref(NULL TSRMLS_CC, E_WARNING, Plainfiles wrapper disabled); } return NULL; + } else { + /* Handles overridden plain files wrapper */ + plain_files_wrapper = *wrapperpp; } - - /* Handles overridden plain files wrapper */ - plain_files_wrapper = *wrapperpp; } if (!php_stream_allow_url_fopen(file, sizeof(file) - 1) || -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /main/streams streams.c
tony2001Sun Sep 10 13:01:28 2006 UTC Modified files: /php-src/main/streams streams.c Log: fix coverity issue #197 I can't think of a reason to pass a NULL buf (c) Wez http://cvs.php.net/viewvc.cgi/php-src/main/streams/streams.c?r1=1.131r2=1.132diff_format=u Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.131 php-src/main/streams/streams.c:1.132 --- php-src/main/streams/streams.c:1.131Sun Sep 3 16:33:02 2006 +++ php-src/main/streams/streams.c Sun Sep 10 13:01:28 2006 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: streams.c,v 1.131 2006/09/03 16:33:02 iliaa Exp $ */ +/* $Id: streams.c,v 1.132 2006/09/10 13:01:28 tony2001 Exp $ */ #define _GNU_SOURCE #include php.h @@ -1611,10 +1611,6 @@ int min_room = CHUNK_SIZE / 4; php_stream_statbuf ssbuf; - if (buf) { - *buf = NULL; - } - if (rettype != src-readbuf_type) { /* UTODO: Introduce sloppy buffer conversion */ return 0; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /main/streams streams.c
iliaa Sun Sep 3 16:33:03 2006 UTC Modified files: /php-src/main/streams streams.c Log: MFB: Fixed bug #38661 (mixed-case URL breaks url-wrappers). http://cvs.php.net/viewvc.cgi/php-src/main/streams/streams.c?r1=1.130r2=1.131diff_format=u Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.130 php-src/main/streams/streams.c:1.131 --- php-src/main/streams/streams.c:1.130Tue Aug 8 16:59:11 2006 +++ php-src/main/streams/streams.c Sun Sep 3 16:33:02 2006 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: streams.c,v 1.130 2006/08/08 16:59:11 tony2001 Exp $ */ +/* $Id: streams.c,v 1.131 2006/09/03 16:33:02 iliaa Exp $ */ #define _GNU_SOURCE #include php.h @@ -1988,18 +1988,24 @@ } if (protocol) { - if (FAILURE == zend_hash_find(wrapper_hash, (char*)protocol, n, (void**)wrapperpp)){ - char wrapper_name[32]; - - if (n = sizeof(wrapper_name)) - n = sizeof(wrapper_name) - 1; - PHP_STRLCPY(wrapper_name, protocol, sizeof(wrapper_name), n); + if (FAILURE == zend_hash_find(wrapper_hash, (char*)protocol, n, (void**)wrapperpp)) { + char *tmp = estrndup(protocol, n); + php_strtolower(tmp, n); + if (FAILURE == zend_hash_find(wrapper_hash, (char*)tmp, n, (void**)wrapperpp)) { + char wrapper_name[32]; + + efree(tmp); + if (n = sizeof(wrapper_name)) { + n = sizeof(wrapper_name) - 1; + } + PHP_STRLCPY(wrapper_name, protocol, sizeof(wrapper_name), n); - php_error_docref(NULL TSRMLS_CC, E_NOTICE, Unable to find the wrapper \%s\ - did you forget to enable it when you configured PHP?, - wrapper_name); + php_error_docref(NULL TSRMLS_CC, E_NOTICE, Unable to find the wrapper \%s\ - did you forget to enable it when you configured PHP?, wrapper_name); - wrapperpp = NULL; - protocol = NULL; + wrapperpp = NULL; + protocol = NULL; + } + efree(tmp); } } /* TODO: curl based streams probably support file:// properly */ -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /main/streams streams.c
pollita Fri Jul 14 19:14:40 2006 UTC Modified files: /php-src/main/streams streams.c Log: #38105 (1/3) Backward logic, filter_product == IS_STRING means the wrapper HAS applied pre-filtering http://cvs.php.net/viewvc.cgi/php-src/main/streams/streams.c?r1=1.128r2=1.129diff_format=u Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.128 php-src/main/streams/streams.c:1.129 --- php-src/main/streams/streams.c:1.128Thu Jul 13 11:58:42 2006 +++ php-src/main/streams/streams.c Fri Jul 14 19:14:40 2006 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: streams.c,v 1.128 2006/07/13 11:58:42 tony2001 Exp $ */ +/* $Id: streams.c,v 1.129 2006/07/14 19:14:40 pollita Exp $ */ #define _GNU_SOURCE #include php.h @@ -2303,7 +2303,7 @@ /* Output encoding on text mode streams defaults to utf8 unless specified in context parameter */ if (stream strchr(implicit_mode, 't') UG(unicode)) { /* Only apply implicit unicode.to. filter if the wrapper didn't do it for us */ - if ((php_stream_filter_product(stream-writefilters, IS_UNICODE) == IS_STRING) + if ((php_stream_filter_product(stream-writefilters, IS_UNICODE) == IS_UNICODE) (strchr(implicit_mode, 'w') || strchr(implicit_mode, 'a') || strchr(implicit_mode, '+'))) { char *encoding = (context context-output_encoding) ? context-output_encoding : utf8; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /main/streams streams.c
andrei Wed Jun 21 17:10:13 2006 UTC Modified files: /php-src/main/streams streams.c Log: Typos. http://cvs.php.net/viewvc.cgi/php-src/main/streams/streams.c?r1=1.125r2=1.126diff_format=u Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.125 php-src/main/streams/streams.c:1.126 --- php-src/main/streams/streams.c:1.125Tue Jun 20 18:09:33 2006 +++ php-src/main/streams/streams.c Wed Jun 21 17:10:13 2006 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: streams.c,v 1.125 2006/06/20 18:09:33 bjori Exp $ */ +/* $Id: streams.c,v 1.126 2006/06/21 17:10:13 andrei Exp $ */ #define _GNU_SOURCE #include php.h @@ -1221,7 +1221,7 @@ /* Use runtime_encoding to map to binary */ num_conv = zend_convert_from_unicode(ZEND_U_CONVERTER(UG(runtime_encoding_conv)), str, len, buf.u, buflen, status); if (U_FAILURE(status)) { - zend_raise_conversion_error_ex(Unable to convert data to be writen, ZEND_U_CONVERTER(UG(runtime_encoding_conv)), + zend_raise_conversion_error_ex(Unable to convert data to be written, ZEND_U_CONVERTER(UG(runtime_encoding_conv)), ZEND_FROM_UNICODE, num_conv, (UG(from_error_mode) ZEND_CONV_ERROR_EXCEPTION) TSRMLS_CC); } else { php_error_docref(NULL TSRMLS_CC, E_NOTICE, %d character unicode buffer downcoded for binary stream runtime_encoding, ulen); @@ -1579,7 +1579,7 @@ if (U_FAILURE(status)) { /* Memory overflow isn't a problem becuase MAX_BYTES_FOR_STRING was allocated, anything else is a more serious problem */ - zend_raise_conversion_error_ex(Unable to convert unicode character using output_encoding, at least one character was lost, + zend_raise_conversion_error_ex(Unable to convert Unicode character using output_encoding, at least one character was lost, conv, ZEND_FROM_UNICODE, len, (UG(from_error_mode) ZEND_CONV_ERROR_EXCEPTION) TSRMLS_CC); } if (outbuf outbuf_start) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /main/streams streams.c
bjori Tue Jun 20 18:09:33 2006 UTC Modified files: /php-src/main/streams streams.c Log: Plug memleak (leaks on empty files) http://cvs.php.net/viewvc.cgi/php-src/main/streams/streams.c?r1=1.124r2=1.125diff_format=u Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.124 php-src/main/streams/streams.c:1.125 --- php-src/main/streams/streams.c:1.124Sun May 14 18:35:40 2006 +++ php-src/main/streams/streams.c Tue Jun 20 18:09:33 2006 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: streams.c,v 1.124 2006/05/14 18:35:40 helly Exp $ */ +/* $Id: streams.c,v 1.125 2006/06/20 18:09:33 bjori Exp $ */ #define _GNU_SOURCE #include php.h @@ -1635,7 +1635,7 @@ p = php_stream_mmap_range(src, php_stream_tell(src), maxlen, PHP_STREAM_MAP_MODE_SHARED_READONLY, mapped); - if (p) { + if (p mapped) { *buf = pemalloc_rel_orig(mapped + 1, persistent); if (*buf) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /main/streams streams.c
mikeThu Apr 20 17:52:02 2006 UTC Modified files: /php-src/main/streams streams.c Log: MFB: Fix reading stream filters never notified about EOF http://cvs.php.net/viewcvs.cgi/php-src/main/streams/streams.c?r1=1.121r2=1.122diff_format=u Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.121 php-src/main/streams/streams.c:1.122 --- php-src/main/streams/streams.c:1.121Tue Apr 18 19:09:31 2006 +++ php-src/main/streams/streams.c Thu Apr 20 17:52:01 2006 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: streams.c,v 1.121 2006/04/18 19:09:31 pollita Exp $ */ +/* $Id: streams.c,v 1.122 2006/04/20 17:52:01 mike Exp $ */ #define _GNU_SOURCE #include php.h @@ -440,7 +440,7 @@ /* allocate a buffer for reading chunks */ chunk_buf = emalloc(stream-chunk_size); - while (!err_flag (stream-writepos - stream-readpos (off_t)size)) { + while (!stream-eof !err_flag (stream-writepos - stream-readpos (off_t)size)) { size_t justread = 0; int flags; php_stream_bucket *bucket; @@ -449,7 +449,7 @@ /* read a chunk into a bucket */ justread = stream-ops-read(stream, chunk_buf, stream-chunk_size TSRMLS_CC); - if (justread != (size_t)-1) { + if (justread justread != (size_t)-1) { bucket = php_stream_bucket_new(stream, chunk_buf, justread, 0, 0 TSRMLS_CC); /* after this call, bucket is owned by the brigade */ -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /main/streams streams.c
pollita Thu Apr 6 19:39:11 2006 UTC Modified files: /php-src/main/streams streams.c Log: Do runtime conversions (with an E_NOTICE) on writing unicode data to a binary stream. Take the WTF out of the equation http://cvs.php.net/viewcvs.cgi/php-src/main/streams/streams.c?r1=1.118r2=1.119diff_format=u Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.118 php-src/main/streams/streams.c:1.119 --- php-src/main/streams/streams.c:1.118Fri Mar 31 22:51:37 2006 +++ php-src/main/streams/streams.c Thu Apr 6 19:39:11 2006 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: streams.c,v 1.118 2006/03/31 22:51:37 pollita Exp $ */ +/* $Id: streams.c,v 1.119 2006/04/06 19:39:11 pollita Exp $ */ #define _GNU_SOURCE #include php.h @@ -1201,6 +1201,8 @@ { size_t didwrite = 0, towrite, justwrote, shouldwrite; char *freeme = NULL; + void *buf_orig = buf.v; + int buflen_orig = buflen, conv_err = 0; /* if we have a seekable stream we need to ensure that data is written at the * current stream-position. This means invalidating the read buffer and then @@ -1211,9 +1213,26 @@ stream-ops-seek(stream, stream-position, SEEK_SET, stream-position TSRMLS_CC); } - /* Sloppy handling, make it a binary buffer */ if (buf_type == IS_UNICODE) { - buflen = UBYTES(buflen); + int len, num_conv, ulen = u_countChar32(buf.u, buflen); + char *str; + UErrorCode status = U_ZERO_ERROR; + + /* Use runtime_encoding to map to binary */ + num_conv = zend_convert_from_unicode(ZEND_U_CONVERTER(UG(runtime_encoding_conv)), str, len, buf.u, buflen, status); + if (U_FAILURE(status)) { + zend_raise_conversion_error_ex(Unable to convert data to be writen, ZEND_U_CONVERTER(UG(runtime_encoding_conv)), + ZEND_FROM_UNICODE, num_conv, (UG(from_error_mode) ZEND_CONV_ERROR_EXCEPTION) TSRMLS_CC); + } else { + php_error_docref(NULL TSRMLS_CC, E_NOTICE, %d character unicode buffer downcoded for binary stream runtime_encoding, ulen); + } + + if (num_conv buflen) { + conv_err = 1; + } + + freeme = buf.s = str; + buflen = len; } shouldwrite = buflen; @@ -1243,8 +1262,23 @@ } if (buf_type == IS_UNICODE) { - /* Was slopily converted */ - didwrite /= UBYTES(1); + /* Map bytes written back to UChars written */ + + if (shouldwrite == didwrite !conv_err) { + /* wrote it all */ + didwrite = buflen_orig; + } else { + /* Figure out how didwrite corresponds to the input buffer */ + char *tmp = emalloc(didwrite + 1), *t = tmp; + UChar *s = buf_orig; + UErrorCode status = U_ZERO_ERROR; + + ucnv_resetFromUnicode(ZEND_U_CONVERTER(UG(runtime_encoding_conv))); + ucnv_fromUnicode(ZEND_U_CONVERTER(UG(runtime_encoding_conv)), t, t + didwrite, s, s + buflen_orig, NULL, TRUE, status); + + didwrite = s - ((UChar*)buf_orig); + efree(tmp); + } } if (freeme) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /main/streams streams.c
pollita Sat Mar 25 04:37:44 2006 UTC Modified files: /php-src/main/streams streams.c Log: Handle converter instantiation errors properly http://cvs.php.net/viewcvs.cgi/php-src/main/streams/streams.c?r1=1.111r2=1.112diff_format=u Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.111 php-src/main/streams/streams.c:1.112 --- php-src/main/streams/streams.c:1.111Fri Mar 24 20:21:48 2006 +++ php-src/main/streams/streams.c Sat Mar 25 04:37:44 2006 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: streams.c,v 1.111 2006/03/24 20:21:48 pollita Exp $ */ +/* $Id: streams.c,v 1.112 2006/03/25 04:37:44 pollita Exp $ */ #define _GNU_SOURCE #include php.h @@ -2277,45 +2277,47 @@ UErrorCode status = U_ZERO_ERROR; stream-output_encoding = ucnv_open(encoding, status); - switch (U_FAILURE(status)) { - case U_ZERO_ERROR: - /* UTODO: (Maybe?) Allow overriding the default error handlers on a per-stream basis via context params */ - zend_set_converter_error_mode(stream-output_encoding, UG(from_u_error_mode)); - zend_set_converter_subst_char(stream-output_encoding, UG(subst_char), UG(subst_char_len)); - break; - case U_MEMORY_ALLOCATION_ERROR: - php_stream_wrapper_log_error(wrapper, options ^ REPORT_ERRORS TSRMLS_CC, - Unable to allocate memory for unicode output converter: %s, encoding); - break; - case U_FILE_ACCESS_ERROR: - php_stream_wrapper_log_error(wrapper, options ^ REPORT_ERRORS TSRMLS_CC, - Error loading unicode output converter: %s, encoding); - break; - default: - php_stream_wrapper_log_error(wrapper, options ^ REPORT_ERRORS TSRMLS_CC, - Unknown error starting unicode output converter: %s, encoding); + if (U_FAILURE(status)) { + switch (status) { + case U_MEMORY_ALLOCATION_ERROR: + php_stream_wrapper_log_error(wrapper, options ^ REPORT_ERRORS TSRMLS_CC, + Unable to allocate memory for unicode output converter: %s, encoding); + break; + case U_FILE_ACCESS_ERROR: + php_stream_wrapper_log_error(wrapper, options ^ REPORT_ERRORS TSRMLS_CC, + Error loading unicode output converter: %s, encoding); + break; + default: + php_stream_wrapper_log_error(wrapper, options ^ REPORT_ERRORS TSRMLS_CC, + Unknown error starting unicode output converter: %s, encoding); + } + } else { + /* UTODO: (Maybe?) Allow overriding the default error handlers on a per-stream basis via context params */ + zend_set_converter_error_mode(stream-output_encoding, UG(from_u_error_mode)); + zend_set_converter_subst_char(stream-output_encoding, UG(subst_char), UG(subst_char_len)); } } if (strchr(implicit_mode, 'r') || strchr(implicit_mode, '+')) { char *encoding = (context context-input_encoding) ? context-input_encoding : utf8; UErrorCode status = U_ZERO_ERROR; + stream-input_encoding = ucnv_open(encoding, status); - switch (U_FAILURE(status)) { - case U_ZERO_ERROR: - /* UTODO: If/When Input error handling gets implemented, set the options here */ - break; - case U_MEMORY_ALLOCATION_ERROR: - php_stream_wrapper_log_error(wrapper, options ^ REPORT_ERRORS TSRMLS_CC, - Unable to allocate memory for unicode input converter: %s, encoding); -
[PHP-CVS] cvs: php-src /main/streams streams.c
pollita Fri Mar 24 00:19:39 2006 UTC Modified files: /php-src/main/streams streams.c Log: Add some error checking when stream converters are instantiated. Use the global conversion error handlers for output conversion (for now) We may want to make this customizable on a per-stream basis via context param later on... http://cvs.php.net/viewcvs.cgi/php-src/main/streams/streams.c?r1=1.108r2=1.109diff_format=u Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.108 php-src/main/streams/streams.c:1.109 --- php-src/main/streams/streams.c:1.108Tue Mar 21 18:28:42 2006 +++ php-src/main/streams/streams.c Fri Mar 24 00:19:39 2006 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: streams.c,v 1.108 2006/03/21 18:28:42 pollita Exp $ */ +/* $Id: streams.c,v 1.109 2006/03/24 00:19:39 pollita Exp $ */ #define _GNU_SOURCE #include php.h @@ -2205,11 +2205,45 @@ UErrorCode status = U_ZERO_ERROR; stream-output_encoding = ucnv_open(encoding, status); + switch (U_FAILURE(status)) { + case U_ZERO_ERROR: + /* UTODO: (Maybe?) Allow overriding the default error handlers on a per-stream basis via context params */ + zend_set_converter_error_mode(stream-output_encoding, UG(from_u_error_mode)); + zend_set_converter_subst_char(stream-output_encoding, UG(subst_char), UG(subst_char_len)); + break; + case U_MEMORY_ALLOCATION_ERROR: + php_stream_wrapper_log_error(wrapper, options ^ REPORT_ERRORS TSRMLS_CC, + Unable to allocate memory for unicode output converter: %s, encoding); + break; + case U_FILE_ACCESS_ERROR: + php_stream_wrapper_log_error(wrapper, options ^ REPORT_ERRORS TSRMLS_CC, + Error loading unicode output converter: %s, encoding); + break; + default: + php_stream_wrapper_log_error(wrapper, options ^ REPORT_ERRORS TSRMLS_CC, + Unknown error starting unicode output converter: %s, encoding); + } } if (strchr(implicit_mode, 'r') || strchr(implicit_mode, '+')) { char *encoding = (context context-input_encoding) ? context-input_encoding : utf8; UErrorCode status = U_ZERO_ERROR; stream-input_encoding = ucnv_open(encoding, status); + switch (U_FAILURE(status)) { + case U_ZERO_ERROR: + /* UTODO: If/When Input error handling gets implemented, set the options here */ + break; + case U_MEMORY_ALLOCATION_ERROR: + php_stream_wrapper_log_error(wrapper, options ^ REPORT_ERRORS TSRMLS_CC, + Unable to allocate memory for unicode input converter: %s, encoding); + break; + case U_FILE_ACCESS_ERROR: + php_stream_wrapper_log_error(wrapper, options ^ REPORT_ERRORS TSRMLS_CC, + Error loading unicode input converter: %s, encoding); + break; + default: + php_stream_wrapper_log_error(wrapper, options ^ REPORT_ERRORS TSRMLS_CC, + Unknown error starting unicode input converter: %s, encoding); + } } } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /main/streams streams.c
pollita Tue Mar 21 18:28:42 2006 UTC Modified files: /php-src/main/streams streams.c Log: Allow grow_mode !bufstart (original assertion logic) http://cvs.php.net/viewcvs.cgi/php-src/main/streams/streams.c?r1=1.107r2=1.108diff_format=u Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.107 php-src/main/streams/streams.c:1.108 --- php-src/main/streams/streams.c:1.107Sat Mar 18 19:44:51 2006 +++ php-src/main/streams/streams.c Tue Mar 21 18:28:42 2006 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: streams.c,v 1.107 2006/03/18 19:44:51 helly Exp $ */ +/* $Id: streams.c,v 1.108 2006/03/21 18:28:42 pollita Exp $ */ #define _GNU_SOURCE #include php.h @@ -1112,7 +1112,8 @@ } if (total_copied == 0) { - assert(bufstart.v != NULL || !grow_mode || stream-eof); + assert(stream-eof || !grow_mode || + (grow_mode bufstart.v == NULL)); return NULL; } @@ -1122,10 +1123,6 @@ buf.s[0] = 0; } - if (returned_len) { - *returned_len = total_copied; - } - return bufstart.s; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /main/streams streams.c
helly Sat Mar 18 19:44:52 2006 UTC Modified files: /php-src/main/streams streams.c Log: - Fix issue in _php_stream_get_line(): Allow maxchars == 0 as macro php_stream_get_line() does http://cvs.php.net/viewcvs.cgi/php-src/main/streams/streams.c?r1=1.106r2=1.107diff_format=u Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.106 php-src/main/streams/streams.c:1.107 --- php-src/main/streams/streams.c:1.106Fri Mar 17 22:52:55 2006 +++ php-src/main/streams/streams.c Sat Mar 18 19:44:51 2006 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: streams.c,v 1.106 2006/03/17 22:52:55 andrei Exp $ */ +/* $Id: streams.c,v 1.107 2006/03/18 19:44:51 helly Exp $ */ #define _GNU_SOURCE #include php.h @@ -1053,20 +1053,22 @@ } if (is_unicode) { - int ulen = u_countChar32(readptr.u, cpysz); - - if (ulen maxchars) { - int32_t i = 0; - - ulen = maxchars; - U16_FWD_N(readptr.u, i, cpysz, ulen); - cpysz = i; + if (maxchars) { + int ulen = u_countChar32(readptr.u, cpysz); + + if (ulen maxchars) { + int32_t i = 0; + + ulen = maxchars; + U16_FWD_N(readptr.u, i, cpysz, ulen); + cpysz = i; + } + maxchars -= ulen; } - maxchars -= ulen; memcpy(buf.u, readptr.u, UBYTES(cpysz)); buf.u += cpysz; } else { - if (cpysz maxchars) { + if (maxchars cpysz maxchars) { cpysz = maxchars; } memcpy(buf.s, readptr.s, cpysz); @@ -1105,10 +1107,12 @@ } } + if (returned_len) { + *returned_len = total_copied; + } + if (total_copied == 0) { - if (grow_mode) { - assert(bufstart.v == NULL); - } + assert(bufstart.v != NULL || !grow_mode || stream-eof); return NULL; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /main/streams streams.c
pollita Wed Mar 15 21:18:36 2006 UTC Modified files: /php-src/main/streams streams.c Log: Fix improper byte count on partial reads http://cvs.php.net/viewcvs.cgi/php-src/main/streams/streams.c?r1=1.103r2=1.104diff_format=u Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.103 php-src/main/streams/streams.c:1.104 --- php-src/main/streams/streams.c:1.103Wed Mar 15 00:28:57 2006 +++ php-src/main/streams/streams.c Wed Mar 15 21:18:36 2006 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: streams.c,v 1.103 2006/03/15 00:28:57 pollita Exp $ */ +/* $Id: streams.c,v 1.104 2006/03/15 21:18:36 pollita Exp $ */ #define _GNU_SOURCE #include php.h @@ -424,6 +424,10 @@ TODO: Needs better handling of surrogate pairs */ static void php_stream_fill_read_buffer(php_stream *stream, size_t size TSRMLS_DC) { + if (stream-readpos == stream-writepos) { + stream-readpos = stream-writepos = 0; + } + /* allocate/fill the buffer */ if (stream-readfilters.head) { @@ -573,7 +577,7 @@ /* reduce buffer memory consumption if possible, to avoid a realloc */ if (stream-readbuf.s stream-readbuflen - stream-writepos stream-chunk_size) { - memmove(stream-readbuf.s, stream-readbuf.s + stream-readpos, stream-readbuflen - stream-readpos); + memmove(stream-readbuf.s, stream-readbuf.s + stream-readpos, stream-writepos - stream-readpos); stream-writepos -= stream-readpos; stream-readpos = 0; } @@ -605,7 +609,7 @@ * drain the remainder of the buffer before using the raw read mode for * the excess */ if (stream-writepos - stream-readpos 0) { - toread = UBYTES(stream-writepos - stream-readpos); + toread = PS_ULEN(stream-input_encoding, stream-writepos - stream-readpos); if (toread size) { toread = size; @@ -1038,8 +1042,8 @@ * than 8K, we waste 1 byte per additional 8K or so. * That seems acceptable to me, to avoid making this code * hard to follow */ - bufstart.s = erealloc(bufstart.s, PS_ULEN(stream, current_buf_size + cpysz + 1)); - buf.s = bufstart.s + PS_ULEN(stream, total_copied); + bufstart.s = erealloc(bufstart.s, PS_ULEN(stream-input_encoding, current_buf_size + cpysz + 1)); + buf.s = bufstart.s + PS_ULEN(stream-input_encoding, total_copied); current_buf_size += cpysz + 1; } else { if (cpysz = maxlen - 1) { @@ -1121,8 +1125,6 @@ return bufstart.s; } -/* Same deal as php_stream_read() and php_stream_get_line() - * Will give unexpected results if used against a unicode stream */ PHPAPI char *php_stream_get_record(php_stream *stream, size_t maxlen, size_t *returned_len, char *delim, size_t delim_len TSRMLS_DC) { char *e, *buf; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /main/streams streams.c
helly Thu Mar 16 00:53:58 2006 UTC Modified files: /php-src/main/streams streams.c Log: - Fix warning http://cvs.php.net/viewcvs.cgi/php-src/main/streams/streams.c?r1=1.104r2=1.105diff_format=u Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.104 php-src/main/streams/streams.c:1.105 --- php-src/main/streams/streams.c:1.104Wed Mar 15 21:18:36 2006 +++ php-src/main/streams/streams.c Thu Mar 16 00:53:58 2006 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: streams.c,v 1.104 2006/03/15 21:18:36 pollita Exp $ */ +/* $Id: streams.c,v 1.105 2006/03/16 00:53:58 helly Exp $ */ #define _GNU_SOURCE #include php.h @@ -1236,7 +1236,7 @@ } else { UErrorCode status = U_ZERO_ERROR; char *t = freeme; - UChar *p = buf_orig.u; + const UChar *p = buf_orig.u; switch (ucnv_getType(stream-output_encoding)) { case UCNV_SBCS: -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /main/streams streams.c
pollita Mon Mar 13 20:54:06 2006 UTC Modified files: /php-src/main/streams streams.c Log: Make php_stream_write_buffer() return characters written, not bytes http://cvs.php.net/viewcvs.cgi/php-src/main/streams/streams.c?r1=1.100r2=1.101diff_format=u Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.100 php-src/main/streams/streams.c:1.101 --- php-src/main/streams/streams.c:1.100Mon Mar 13 15:01:44 2006 +++ php-src/main/streams/streams.c Mon Mar 13 20:54:06 2006 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: streams.c,v 1.100 2006/03/13 15:01:44 derick Exp $ */ +/* $Id: streams.c,v 1.101 2006/03/13 20:54:06 pollita Exp $ */ #define _GNU_SOURCE #include php.h @@ -1128,7 +1128,8 @@ /* Writes a buffer directly to a stream, using multiple of the chunk size */ static size_t _php_stream_write_buffer(php_stream *stream, int buf_type, zstr buf, int buflen TSRMLS_DC) { - size_t didwrite = 0, towrite, justwrote; + size_t didwrite = 0, towrite, justwrote, shouldwrite, buflen_orig = buflen; + zstr buf_orig = buf; char *freeme = NULL; /* if we have a seekable stream we need to ensure that data is written at the @@ -1155,6 +1156,8 @@ } } + shouldwrite = buflen; + while (buflen 0) { towrite = buflen; if (towrite stream-chunk_size) { @@ -1179,6 +1182,36 @@ } } + + if (stream-output_encoding) { + /* Map didwrite back to the original character count */ + if (didwrite == shouldwrite) { + /* Everything wrote okay, no need to count */ + didwrite = buflen_orig; + } else { + UErrorCode status = U_ZERO_ERROR; + char *t = freeme; + UChar *p = buf_orig.u; + + switch (ucnv_getType(stream-output_encoding)) { + case UCNV_SBCS: + case UCNV_LATIN_1: + case UCNV_US_ASCII: + /* 1:1 character-byte mapping, didwrite really does mean the number of characters written */ + break; + default: + /* Reconvert into junk buffer to see where conversion stops in source string */ + ucnv_resetFromUnicode(stream-output_encoding); + ucnv_fromUnicode(stream-output_encoding, t, t + didwrite, p, p + buflen_orig, NULL, TRUE, status); + /* p stops at the first unconvertable UChar when t runs out of space */ + didwrite = p - buf_orig.u; + } + } + } else if (buf_type == IS_UNICODE) { + /* Was slopily converted */ + didwrite /= UBYTES(1); + } + if (freeme) { efree(freeme); } @@ -1296,10 +1329,6 @@ ret = _php_stream_write_buffer(stream, IS_UNICODE, (zstr)((UChar*)buf), count TSRMLS_CC); } - /* Return data points, not bytes */ - if (ret 0) { - ret = 1; - } return ret; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /main/streams streams.c userspace.c
helly Tue Feb 28 12:06:55 2006 UTC Modified files: /php-src/main/streams streams.c userspace.c Log: - Cleanup http://cvs.php.net/viewcvs.cgi/php-src/main/streams/streams.c?r1=1.96r2=1.97diff_format=u Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.96 php-src/main/streams/streams.c:1.97 --- php-src/main/streams/streams.c:1.96 Tue Feb 21 20:12:43 2006 +++ php-src/main/streams/streams.c Tue Feb 28 12:06:54 2006 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: streams.c,v 1.96 2006/02/21 20:12:43 dmitry Exp $ */ +/* $Id: streams.c,v 1.97 2006/02/28 12:06:54 helly Exp $ */ #define _GNU_SOURCE #include php.h @@ -2205,7 +2205,7 @@ return php_plain_files_wrapper; } - if ((wrapper wrapper-is_url) (!PG(allow_url_fopen) || (options STREAM_OPEN_FOR_INCLUDE) !PG(allow_url_include)) ) { + if ((wrapper wrapper-is_url) (!PG(allow_url_fopen) || ((options STREAM_OPEN_FOR_INCLUDE) !PG(allow_url_include))) ) { if (options REPORT_ERRORS) { php_error_docref(NULL TSRMLS_CC, E_WARNING, URL file-access is disabled in the server configuration); } http://cvs.php.net/viewcvs.cgi/php-src/main/streams/userspace.c?r1=1.32r2=1.33diff_format=u Index: php-src/main/streams/userspace.c diff -u php-src/main/streams/userspace.c:1.32 php-src/main/streams/userspace.c:1.33 --- php-src/main/streams/userspace.c:1.32 Sun Jan 1 13:09:57 2006 +++ php-src/main/streams/userspace.cTue Feb 28 12:06:54 2006 @@ -17,7 +17,7 @@ +--+ */ -/* $Id: userspace.c,v 1.32 2006/01/01 13:09:57 sniper Exp $ */ +/* $Id: userspace.c,v 1.33 2006/02/28 12:06:54 helly Exp $ */ #include php.h #include php_globals.h @@ -437,7 +437,7 @@ } /* }}} */ -/* {{{ bool stream_wrapper_unregister(string protocol) +/* {{{ proto bool stream_wrapper_unregister(string protocol) Unregister a wrapper for the life of the current request. */ PHP_FUNCTION(stream_wrapper_unregister) { @@ -458,7 +458,7 @@ } /* }}} */ -/* {{{ bool stream_wrapper_restore(string protocol) +/* {{{ proto bool stream_wrapper_restore(string protocol) Restore the original protocol handler, overriding if necessary */ PHP_FUNCTION(stream_wrapper_restore) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /main/streams streams.c
helly Tue Feb 28 18:00:03 2006 UTC Modified files: /php-src/main/streams streams.c Log: - If (SEEK_CUR,0) means an illegal seek we return -1 to denote the error http://cvs.php.net/viewcvs.cgi/php-src/main/streams/streams.c?r1=1.97r2=1.98diff_format=u Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.97 php-src/main/streams/streams.c:1.98 --- php-src/main/streams/streams.c:1.97 Tue Feb 28 12:06:54 2006 +++ php-src/main/streams/streams.c Tue Feb 28 18:00:03 2006 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: streams.c,v 1.97 2006/02/28 12:06:54 helly Exp $ */ +/* $Id: streams.c,v 1.98 2006/02/28 18:00:03 helly Exp $ */ #define _GNU_SOURCE #include php.h @@ -1638,7 +1638,7 @@ case SEEK_CUR: if (offset == 0) { /* nothing to do */ - return 0; + return stream-position = 0 ? 0 : -1; } if (offset 0 offset = stream-readbuf_avail) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /main/streams streams.c
tony2001Tue Dec 20 09:48:24 2005 EDT Modified files: /php-src/main/streams streams.c Log: MFB: fix #35740 (memory leak when including a directory) http://cvs.php.net/viewcvs.cgi/php-src/main/streams/streams.c?r1=1.91r2=1.92diff_format=u Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.91 php-src/main/streams/streams.c:1.92 --- php-src/main/streams/streams.c:1.91 Mon Dec 5 23:31:09 2005 +++ php-src/main/streams/streams.c Tue Dec 20 09:48:24 2005 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: streams.c,v 1.91 2005/12/05 23:31:09 sniper Exp $ */ +/* $Id: streams.c,v 1.92 2005/12/20 09:48:24 tony2001 Exp $ */ #define _GNU_SOURCE #include php.h @@ -2485,6 +2485,10 @@ if (stream == NULL (options REPORT_ERRORS)) { php_stream_display_wrapper_errors(wrapper, path, failed to open stream TSRMLS_CC); + if (opened_path *opened_path) { + efree(*opened_path); + *opened_path = NULL; + } } php_stream_tidy_wrapper_error_log(wrapper TSRMLS_CC); #if ZEND_DEBUG -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /main/streams streams.c
tony2001Wed Oct 5 13:18:09 2005 EDT Modified files: /php-src/main/streams streams.c Log: fix bugs #34743 #34118 (fseek/fread unicode related problems in HEAD) patch by Alex http://cvs.php.net/diff.php/php-src/main/streams/streams.c?r1=1.87r2=1.88ty=u Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.87 php-src/main/streams/streams.c:1.88 --- php-src/main/streams/streams.c:1.87 Mon Aug 22 10:48:25 2005 +++ php-src/main/streams/streams.c Wed Oct 5 13:18:06 2005 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: streams.c,v 1.87 2005/08/22 14:48:25 dmitry Exp $ */ +/* $Id: streams.c,v 1.88 2005/10/05 17:18:06 tony2001 Exp $ */ #define _GNU_SOURCE #include php.h @@ -855,6 +855,8 @@ *pnum_chars = num_chars; *pis_unicode = is_unicode; + stream-position += num_bytes; + if (num_chars == 0 grow_mode) { efree(buf); buf = NULL; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /main/streams streams.c
tony2001Wed Oct 5 17:46:31 2005 EDT Modified files: /php-src/main/streams streams.c Log: fix fwrite() and fgets() in unicode mode http://cvs.php.net/diff.php/php-src/main/streams/streams.c?r1=1.88r2=1.89ty=u Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.88 php-src/main/streams/streams.c:1.89 --- php-src/main/streams/streams.c:1.88 Wed Oct 5 13:18:06 2005 +++ php-src/main/streams/streams.c Wed Oct 5 17:46:28 2005 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: streams.c,v 1.88 2005/10/05 17:18:06 tony2001 Exp $ */ +/* $Id: streams.c,v 1.89 2005/10/05 21:46:28 tony2001 Exp $ */ #define _GNU_SOURCE #include php.h @@ -1258,7 +1258,7 @@ count_bytes = 1; /* translate U16 to bytes */ } - memcpy(buf + num_bytes, s, count_bytes); + memcpy(buf + (num_bytes 1), s, count_bytes); num_bytes += count_bytes; num_chars += count_chars; stream-readbuf_ofs += count_bytes 1; @@ -1577,23 +1577,23 @@ PHPAPI size_t _php_stream_u_write(php_stream *stream, const UChar *buf, int32_t count TSRMLS_DC) { + int32_t ret; + if (buf == NULL || count == 0 || stream-ops-write == NULL) { return 0; } if (stream-writefilters.head) { - return _php_stream_write_filtered(stream, (const char*)buf, count, PSFS_FLAG_NORMAL, 1 TSRMLS_CC); + ret = _php_stream_write_filtered(stream, (const char*)buf, count, PSFS_FLAG_NORMAL, 1 TSRMLS_CC); } else { - int32_t ret; - ret = _php_stream_write_buffer(stream, (const char*)buf, UBYTES(count) TSRMLS_CC); + } - /* Return data points, not bytes */ - if (ret 0) { - ret = 1; - } - return ret; + /* Return data points, not bytes */ + if (ret 0) { + ret = 1; } + return ret; } PHPAPI size_t _php_stream_printf(php_stream *stream TSRMLS_DC, const char *fmt, ...) -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /main/streams streams.c
wez Sun Aug 14 09:48:30 2005 EDT Modified files: /php-src/main/streams streams.c Log: tidy up implicit_mode handling; spotted by Nuno There's probably a much more efficient way to do this than the current strchr stuff. http://cvs.php.net/diff.php/php-src/main/streams/streams.c?r1=1.85r2=1.86ty=u Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.85 php-src/main/streams/streams.c:1.86 --- php-src/main/streams/streams.c:1.85 Sat Aug 13 15:22:03 2005 +++ php-src/main/streams/streams.c Sun Aug 14 09:48:29 2005 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: streams.c,v 1.85 2005/08/13 19:22:03 wez Exp $ */ +/* $Id: streams.c,v 1.86 2005/08/14 13:48:29 wez Exp $ */ #define _GNU_SOURCE #include php.h @@ -2347,7 +2347,7 @@ char *path_to_open; int persistent = options STREAM_OPEN_PERSISTENT; char *copy_of_path = NULL; - int implicit_mode[16]; + char implicit_mode[16]; int modelen = strlen(mode); if (opened_path) { @@ -2366,20 +2366,20 @@ return NULL; } - memcpy(implicit_mode, mode, modelen); + strlcpy(implicit_mode, mode, sizeof(implicit_mode)); if (context context-default_mode modelen 15 !strchr(mode, 't') !strchr(mode, 'b')) { if (context-default_mode PHP_FILE_BINARY) { implicit_mode[modelen++] = 'b'; } else if (context-default_mode PHP_FILE_TEXT) { implicit_mode[modelen++] = 't'; } - implicit_mode[modelen] = 0; + implicit_mode[modelen] = '\0'; } if (wrapper) { stream = wrapper-wops-stream_opener(wrapper, - path_to_open, (char *)implicit_mode, options ^ REPORT_ERRORS, + path_to_open, implicit_mode, options ^ REPORT_ERRORS, opened_path, context STREAMS_REL_CC TSRMLS_CC); /* if the caller asked for a persistent stream but the wrapper did not @@ -2393,7 +2393,7 @@ if (stream) { stream-wrapper = wrapper; - memcpy(stream-mode, implicit_mode, modelen + 1); + strlcpy(stream-mode, implicit_mode, sizeof(stream-mode)); } } @@ -2441,7 +2441,7 @@ } /* Output encoding on text mode streams defaults to utf8 unless specified in context parameter */ - if (stream memchr(implicit_mode, 't', modelen) (memchr(implicit_mode, 'w', modelen) || memchr(implicit_mode, 'a', modelen) || memchr(implicit_mode, '+', modelen))) { + if (stream strchr(implicit_mode, 't') (strchr(implicit_mode, 'w') || strchr(implicit_mode, 'a') || strchr(implicit_mode, '+'))) { php_stream_filter *filter; char *encoding = (context context-output_encoding) ? context-output_encoding : utf8; char *filtername; @@ -2460,7 +2460,7 @@ efree(filtername); } - if (stream memchr(implicit_mode, 't', modelen) (memchr(implicit_mode, 'r', modelen) || memchr(implicit_mode, '+', modelen))) { + if (stream strchr(implicit_mode, 't') (strchr(implicit_mode, 'r') || strchr(implicit_mode, '+'))) { php_stream_filter *filter; char *filtername; char *encoding = (context context-input_encoding) ? context-input_encoding : utf8; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /main/streams streams.c
wez Sat Aug 13 15:22:04 2005 EDT Modified files: /php-src/main/streams streams.c Log: a bit of pedantic ws http://cvs.php.net/diff.php/php-src/main/streams/streams.c?r1=1.84r2=1.85ty=u Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.84 php-src/main/streams/streams.c:1.85 --- php-src/main/streams/streams.c:1.84 Fri Aug 12 19:21:29 2005 +++ php-src/main/streams/streams.c Sat Aug 13 15:22:03 2005 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: streams.c,v 1.84 2005/08/12 23:21:29 tony2001 Exp $ */ +/* $Id: streams.c,v 1.85 2005/08/13 19:22:03 wez Exp $ */ #define _GNU_SOURCE #include php.h @@ -708,17 +708,17 @@ /* It's possible that we have a readbuf, but that it's only half of a surrogate pair */ if (!stream-readbuf.head || - (stream-readbuf.head == stream-readbuf.tail stream-readbuf.head-is_unicode - (stream-readbuf.head-buf.ustr.len - stream-readbuf_ofs) == 1 - U16_IS_SURROGATE(stream-readbuf.head-buf.ustr.val[stream-readbuf.head-buf.ustr.len-1]))) { + (stream-readbuf.head == stream-readbuf.tail stream-readbuf.head-is_unicode + (stream-readbuf.head-buf.ustr.len - stream-readbuf_ofs) == 1 + U16_IS_SURROGATE(stream-readbuf.head-buf.ustr.val[stream-readbuf.head-buf.ustr.len-1]))) { php_stream_fill_read_buffer(stream, max_bytes ? max_bytes : (max_chars ? max_chars : stream-chunk_size) TSRMLS_CC); } if (!stream-readbuf.head || - (stream-readbuf.head == stream-readbuf.tail stream-readbuf.head-is_unicode - (stream-readbuf.head-buf.ustr.len - stream-readbuf_ofs) == 1 - U16_IS_SURROGATE(stream-readbuf.head-buf.ustr.val[stream-readbuf.head-buf.ustr.len-1]))) { + (stream-readbuf.head == stream-readbuf.tail stream-readbuf.head-is_unicode + (stream-readbuf.head-buf.ustr.len - stream-readbuf_ofs) == 1 + U16_IS_SURROGATE(stream-readbuf.head-buf.ustr.val[stream-readbuf.head-buf.ustr.len-1]))) { /* Nothing to return */ *pnum_bytes = 0; *pnum_chars = 0; @@ -761,7 +761,7 @@ if ((bucket = stream-readbuf.head)) { if ((bucket-is_unicode !is_unicode) || - (!bucket-is_unicode is_unicode)) { + (!bucket-is_unicode is_unicode)) { /* data type swap, exit now */ break; } @@ -804,8 +804,8 @@ php_stream_bucket_delref(bucket TSRMLS_CC); stream-readbuf_ofs = 0; } else if (stream-readbuf_ofs == (bucket-buf.ustr.len - 1) - U16_IS_SURROGATE(bucket-buf.ustr.val[bucket-buf.ustr.len - 1]) - bucket-next bucket-next-is_unicode) { + U16_IS_SURROGATE(bucket-buf.ustr.val[bucket-buf.ustr.len - 1]) + bucket-next bucket-next-is_unicode) { /* Only one char left in the bucket, avoid already split surrogates getting stuck -- Should never happen thanks to fill_read_buffer */ php_stream_bucket *next_bucket = bucket-next; @@ -1272,7 +1272,7 @@ } if ((max_bytes = 0 num_bytes = max_bytes) || - (max_chars = 0 num_chars = max_chars)) { + (max_chars = 0 num_chars = max_chars)) { goto exit_ugetline; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /main/streams streams.c
tony2001Fri Aug 12 19:21:30 2005 EDT Modified files: /php-src/main/streams streams.c Log: make valgrind and gcc happy http://cvs.php.net/diff.php/php-src/main/streams/streams.c?r1=1.83r2=1.84ty=u Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.83 php-src/main/streams/streams.c:1.84 --- php-src/main/streams/streams.c:1.83 Thu Aug 11 19:36:06 2005 +++ php-src/main/streams/streams.c Fri Aug 12 19:21:29 2005 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: streams.c,v 1.83 2005/08/11 23:36:06 andrei Exp $ */ +/* $Id: streams.c,v 1.84 2005/08/12 23:21:29 tony2001 Exp $ */ #define _GNU_SOURCE #include php.h @@ -2379,7 +2379,7 @@ if (wrapper) { stream = wrapper-wops-stream_opener(wrapper, - path_to_open, implicit_mode, options ^ REPORT_ERRORS, + path_to_open, (char *)implicit_mode, options ^ REPORT_ERRORS, opened_path, context STREAMS_REL_CC TSRMLS_CC); /* if the caller asked for a persistent stream but the wrapper did not @@ -2441,7 +2441,7 @@ } /* Output encoding on text mode streams defaults to utf8 unless specified in context parameter */ - if (stream strchr(implicit_mode, 't') (strchr(implicit_mode, 'w') || strchr(implicit_mode, 'a') || strchr(implicit_mode, '+'))) { + if (stream memchr(implicit_mode, 't', modelen) (memchr(implicit_mode, 'w', modelen) || memchr(implicit_mode, 'a', modelen) || memchr(implicit_mode, '+', modelen))) { php_stream_filter *filter; char *encoding = (context context-output_encoding) ? context-output_encoding : utf8; char *filtername; @@ -2460,7 +2460,7 @@ efree(filtername); } - if (stream strchr(implicit_mode, 't') (strchr(implicit_mode, 'r') || strchr(implicit_mode, '+'))) { + if (stream memchr(implicit_mode, 't', modelen) (memchr(implicit_mode, 'r', modelen) || memchr(implicit_mode, '+', modelen))) { php_stream_filter *filter; char *filtername; char *encoding = (context context-input_encoding) ? context-input_encoding : utf8; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-CVS] cvs: php-src /main/streams streams.c
Yes. I foubd the error using this test file. Thanks. Dmitry. -Original Message- From: Ilia Alshanetsky [mailto:[EMAIL PROTECTED] Sent: Wednesday, June 01, 2005 9:31 PM To: Dmitry Stogov Cc: php-cvs@lists.php.net Subject: Re: [PHP-CVS] cvs: php-src /main/streams streams.c Was it the same valgrind error as the one previously reported in bug30362.phpt (it seems to be gone now)? Ilia Dmitry Stogov wrote: No. It fixes valgrind errors. Thanks. Dmitry. -Original Message- From: Ilia Alshanetsky [mailto:[EMAIL PROTECTED] Sent: Wednesday, June 01, 2005 8:21 PM To: Dmitry Stogov Cc: php-cvs@lists.php.net Subject: Re: [PHP-CVS] cvs: php-src /main/streams streams.c Is there a test case or an example of a bug that required this fix? ilia Dmitry Stogov wrote: dmitry Wed Jun 1 11:11:44 2005 EDT Modified files: /php-src/main/streams streams.c Log: Disabled search of recored separator outside of buffer http://cvs.php.net/diff.php/php-src/main/streams/streams.c?r 1=1.80r2= 1.81ty=u Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.80 php-src/main/streams/streams.c:1.81 --- php-src/main/streams/streams.c:1.80Mon May 23 11:36:58 2005 +++ php-src/main/streams/streams.c Wed Jun 1 11:11:44 2005 @@ -19,7 +19,7 @@ +- -+ */ -/* $Id: streams.c,v 1.80 2005/05/23 15:36:58 tony2001 Exp $ */ +/* $Id: streams.c,v 1.81 2005/06/01 15:11:44 dmitry Exp $ */ #define _GNU_SOURCE #include php.h @@ -852,9 +852,9 @@ toread = maxlen; } else { if (delim_len == 1) { - e = memchr(stream-readbuf + stream-readpos, *delim, stream-readbuflen - stream-readpos); + e = memchr(stream-readbuf + stream-readpos, *delim, +stream-writepos - stream-readpos); } else { - e = php_memnstr(stream-readbuf + stream-readpos, delim, delim_len, (stream-readbuf + stream-readbuflen)); + e = php_memnstr(stream-readbuf + stream-readpos, delim, +delim_len, (stream-readbuf + stream-writepos)); } if (!e) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-CVS] cvs: php-src /main/streams streams.c
Hi Tony, You are right. Thanks. Dmitry. -Original Message- From: Antony Dovgal [mailto:[EMAIL PROTECTED] Sent: Wednesday, June 01, 2005 10:13 PM To: Ilia Alshanetsky Cc: [EMAIL PROTECTED]; php-cvs@lists.php.net Subject: Re: [PHP-CVS] cvs: php-src /main/streams streams.c On Wed, 01 Jun 2005 12:20:51 -0400 Ilia Alshanetsky [EMAIL PROTECTED] wrote: Is there a test case or an example of a bug that required this fix? I guess it fixes stream_get_line() buffer overrun that I tried to fix couple of weeks ago. At least I can't reproduce it anymore. ilia Dmitry Stogov wrote: dmitryWed Jun 1 11:11:44 2005 EDT Modified files: /php-src/main/streams streams.c Log: Disabled search of recored separator outside of buffer -- Wbr, Antony Dovgal aka tony2001 [EMAIL PROTECTED] -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src /main/streams streams.c
Is there a test case or an example of a bug that required this fix? ilia Dmitry Stogov wrote: dmitry Wed Jun 1 11:11:44 2005 EDT Modified files: /php-src/main/streams streams.c Log: Disabled search of recored separator outside of buffer http://cvs.php.net/diff.php/php-src/main/streams/streams.c?r1=1.80r2=1.81ty=u Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.80 php-src/main/streams/streams.c:1.81 --- php-src/main/streams/streams.c:1.80 Mon May 23 11:36:58 2005 +++ php-src/main/streams/streams.c Wed Jun 1 11:11:44 2005 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: streams.c,v 1.80 2005/05/23 15:36:58 tony2001 Exp $ */ +/* $Id: streams.c,v 1.81 2005/06/01 15:11:44 dmitry Exp $ */ #define _GNU_SOURCE #include php.h @@ -852,9 +852,9 @@ toread = maxlen; } else { if (delim_len == 1) { - e = memchr(stream-readbuf + stream-readpos, *delim, stream-readbuflen - stream-readpos); + e = memchr(stream-readbuf + stream-readpos, *delim, stream-writepos - stream-readpos); } else { - e = php_memnstr(stream-readbuf + stream-readpos, delim, delim_len, (stream-readbuf + stream-readbuflen)); + e = php_memnstr(stream-readbuf + stream-readpos, delim, delim_len, (stream-readbuf + stream-writepos)); } if (!e) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-CVS] cvs: php-src /main/streams streams.c
No. It fixes valgrind errors. Thanks. Dmitry. -Original Message- From: Ilia Alshanetsky [mailto:[EMAIL PROTECTED] Sent: Wednesday, June 01, 2005 8:21 PM To: Dmitry Stogov Cc: php-cvs@lists.php.net Subject: Re: [PHP-CVS] cvs: php-src /main/streams streams.c Is there a test case or an example of a bug that required this fix? ilia Dmitry Stogov wrote: dmitry Wed Jun 1 11:11:44 2005 EDT Modified files: /php-src/main/streams streams.c Log: Disabled search of recored separator outside of buffer http://cvs.php.net/diff.php/php-src/main/streams/streams.c?r1=1.80r2= 1.81ty=u Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.80 php-src/main/streams/streams.c:1.81 --- php-src/main/streams/streams.c:1.80 Mon May 23 11:36:58 2005 +++ php-src/main/streams/streams.c Wed Jun 1 11:11:44 2005 @@ -19,7 +19,7 @@ +- -+ */ -/* $Id: streams.c,v 1.80 2005/05/23 15:36:58 tony2001 Exp $ */ +/* $Id: streams.c,v 1.81 2005/06/01 15:11:44 dmitry Exp $ */ #define _GNU_SOURCE #include php.h @@ -852,9 +852,9 @@ toread = maxlen; } else { if (delim_len == 1) { - e = memchr(stream-readbuf + stream-readpos, *delim, stream-readbuflen - stream-readpos); + e = memchr(stream-readbuf + stream-readpos, *delim, +stream-writepos - stream-readpos); } else { - e = php_memnstr(stream-readbuf + stream-readpos, delim, delim_len, (stream-readbuf + stream-readbuflen)); + e = php_memnstr(stream-readbuf + stream-readpos, delim, +delim_len, (stream-readbuf + stream-writepos)); } if (!e) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src /main/streams streams.c
Was it the same valgrind error as the one previously reported in bug30362.phpt (it seems to be gone now)? Ilia Dmitry Stogov wrote: No. It fixes valgrind errors. Thanks. Dmitry. -Original Message- From: Ilia Alshanetsky [mailto:[EMAIL PROTECTED] Sent: Wednesday, June 01, 2005 8:21 PM To: Dmitry Stogov Cc: php-cvs@lists.php.net Subject: Re: [PHP-CVS] cvs: php-src /main/streams streams.c Is there a test case or an example of a bug that required this fix? ilia Dmitry Stogov wrote: dmitry Wed Jun 1 11:11:44 2005 EDT Modified files: /php-src/main/streams streams.c Log: Disabled search of recored separator outside of buffer http://cvs.php.net/diff.php/php-src/main/streams/streams.c?r1=1.80r2= 1.81ty=u Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.80 php-src/main/streams/streams.c:1.81 --- php-src/main/streams/streams.c:1.80 Mon May 23 11:36:58 2005 +++ php-src/main/streams/streams.c Wed Jun 1 11:11:44 2005 @@ -19,7 +19,7 @@ +- -+ */ -/* $Id: streams.c,v 1.80 2005/05/23 15:36:58 tony2001 Exp $ */ +/* $Id: streams.c,v 1.81 2005/06/01 15:11:44 dmitry Exp $ */ #define _GNU_SOURCE #include php.h @@ -852,9 +852,9 @@ toread = maxlen; } else { if (delim_len == 1) { - e = memchr(stream-readbuf + stream-readpos, *delim, stream-readbuflen - stream-readpos); + e = memchr(stream-readbuf + stream-readpos, *delim, +stream-writepos - stream-readpos); } else { - e = php_memnstr(stream-readbuf + stream-readpos, delim, delim_len, (stream-readbuf + stream-readbuflen)); + e = php_memnstr(stream-readbuf + stream-readpos, delim, +delim_len, (stream-readbuf + stream-writepos)); } if (!e) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src /main/streams streams.c
On Wed, 01 Jun 2005 12:20:51 -0400 Ilia Alshanetsky [EMAIL PROTECTED] wrote: Is there a test case or an example of a bug that required this fix? I guess it fixes stream_get_line() buffer overrun that I tried to fix couple of weeks ago. At least I can't reproduce it anymore. ilia Dmitry Stogov wrote: dmitry Wed Jun 1 11:11:44 2005 EDT Modified files: /php-src/main/streams streams.c Log: Disabled search of recored separator outside of buffer -- Wbr, Antony Dovgal aka tony2001 [EMAIL PROTECTED] -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /main/streams streams.c
tony2001Mon May 23 07:51:53 2005 EDT Modified files: /php-src/main/streams streams.c Log: fix bug #32810 (fread after tmpfile() reads only 8192 bytes) http://cvs.php.net/diff.php/php-src/main/streams/streams.c?r1=1.78r2=1.79ty=u Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.78 php-src/main/streams/streams.c:1.79 --- php-src/main/streams/streams.c:1.78 Mon May 16 04:37:13 2005 +++ php-src/main/streams/streams.c Mon May 23 07:51:53 2005 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: streams.c,v 1.78 2005/05/16 08:37:13 tony2001 Exp $ */ +/* $Id: streams.c,v 1.79 2005/05/23 11:51:53 tony2001 Exp $ */ #define _GNU_SOURCE #include php.h @@ -603,8 +603,9 @@ } /* just break anyway, to avoid greedy read */ - if (stream-wrapper != php_plain_files_wrapper) + if (stream-wrapper != NULL stream-wrapper != php_plain_files_wrapper) { break; + } } if (didread 0) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src /main/streams streams.c
On Mon, 23 May 2005 09:54:44 -0400 Wez Furlong [EMAIL PROTECTED] wrote: WTF!??? Please revert, immediately. Please care to explain why. I tested it with all kinds of wrappers and it works fine for me. On 5/23/05, Antony Dovgal [EMAIL PROTECTED] wrote: tony2001Mon May 23 07:51:53 2005 EDT Modified files: /php-src/main/streams streams.c Log: fix bug #32810 (fread after tmpfile() reads only 8192 bytes) http://cvs.php.net/diff.php/php-src/main/streams/streams.c?r1=1.78r2=1.79ty=u Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.78 php-src/main/streams/streams.c:1.79 --- php-src/main/streams/streams.c:1.78 Mon May 16 04:37:13 2005 +++ php-src/main/streams/streams.c Mon May 23 07:51:53 2005 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: streams.c,v 1.78 2005/05/16 08:37:13 tony2001 Exp $ */ +/* $Id: streams.c,v 1.79 2005/05/23 11:51:53 tony2001 Exp $ */ #define _GNU_SOURCE #include php.h @@ -603,8 +603,9 @@ } /* just break anyway, to avoid greedy read */ - if (stream-wrapper != php_plain_files_wrapper) + if (stream-wrapper != NULL stream-wrapper != php_plain_files_wrapper) { break; + } } if (didread 0) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Wbr, Antony Dovgal aka tony2001 [EMAIL PROTECTED] -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src /main/streams streams.c
WTF!??? Please revert, immediately. --Wez. On 5/23/05, Antony Dovgal [EMAIL PROTECTED] wrote: tony2001Mon May 23 07:51:53 2005 EDT Modified files: /php-src/main/streams streams.c Log: fix bug #32810 (fread after tmpfile() reads only 8192 bytes) http://cvs.php.net/diff.php/php-src/main/streams/streams.c?r1=1.78r2=1.79ty=u Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.78 php-src/main/streams/streams.c:1.79 --- php-src/main/streams/streams.c:1.78 Mon May 16 04:37:13 2005 +++ php-src/main/streams/streams.c Mon May 23 07:51:53 2005 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: streams.c,v 1.78 2005/05/16 08:37:13 tony2001 Exp $ */ +/* $Id: streams.c,v 1.79 2005/05/23 11:51:53 tony2001 Exp $ */ #define _GNU_SOURCE #include php.h @@ -603,8 +603,9 @@ } /* just break anyway, to avoid greedy read */ - if (stream-wrapper != php_plain_files_wrapper) + if (stream-wrapper != NULL stream-wrapper != php_plain_files_wrapper) { break; + } } if (didread 0) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src /main/streams streams.c
What tests did you run, and what problem were you trying to solve? You've made reads non-greedy for streams with wrappers (except for plain files), and made reads greedy for streams without wrappers. The correct semantic is: only reads on local files should be greedy (for BC); everything else should not. Hint: test fsockopen() too. --Wez. On 5/23/05, Antony Dovgal [EMAIL PROTECTED] wrote: On Mon, 23 May 2005 09:54:44 -0400 Wez Furlong [EMAIL PROTECTED] wrote: WTF!??? Please revert, immediately. Please care to explain why. I tested it with all kinds of wrappers and it works fine for me. On 5/23/05, Antony Dovgal [EMAIL PROTECTED] wrote: tony2001Mon May 23 07:51:53 2005 EDT Modified files: /php-src/main/streams streams.c Log: fix bug #32810 (fread after tmpfile() reads only 8192 bytes) http://cvs.php.net/diff.php/php-src/main/streams/streams.c?r1=1.78r2=1.79ty=u Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.78 php-src/main/streams/streams.c:1.79 --- php-src/main/streams/streams.c:1.78 Mon May 16 04:37:13 2005 +++ php-src/main/streams/streams.c Mon May 23 07:51:53 2005 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: streams.c,v 1.78 2005/05/16 08:37:13 tony2001 Exp $ */ +/* $Id: streams.c,v 1.79 2005/05/23 11:51:53 tony2001 Exp $ */ #define _GNU_SOURCE #include php.h @@ -603,8 +603,9 @@ } /* just break anyway, to avoid greedy read */ - if (stream-wrapper != php_plain_files_wrapper) + if (stream-wrapper != NULL stream-wrapper != php_plain_files_wrapper) { break; + } } if (didread 0) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Wbr, Antony Dovgal aka tony2001 [EMAIL PROTECTED] -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src /main/streams streams.c
On Mon, 23 May 2005 10:08:39 -0400 Wez Furlong [EMAIL PROTECTED] wrote: What tests did you run, and what problem were you trying to solve? You've made reads non-greedy for streams with wrappers (except for plain files), and made reads greedy for streams without wrappers. The correct semantic is: only reads on local files should be greedy (for BC); everything else should not. So, you're trying to say that #30441, #29023, #32649 and #32810 are bogus bugs? Because from what I can see they are caused by exactly this non-greediness. On 5/23/05, Antony Dovgal [EMAIL PROTECTED] wrote: On Mon, 23 May 2005 09:54:44 -0400 Wez Furlong [EMAIL PROTECTED] wrote: WTF!??? Please revert, immediately. Please care to explain why. I tested it with all kinds of wrappers and it works fine for me. On 5/23/05, Antony Dovgal [EMAIL PROTECTED] wrote: tony2001Mon May 23 07:51:53 2005 EDT Modified files: /php-src/main/streams streams.c Log: fix bug #32810 (fread after tmpfile() reads only 8192 bytes) http://cvs.php.net/diff.php/php-src/main/streams/streams.c?r1=1.78r2=1.79ty=u Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.78 php-src/main/streams/streams.c:1.79 --- php-src/main/streams/streams.c:1.78 Mon May 16 04:37:13 2005 +++ php-src/main/streams/streams.c Mon May 23 07:51:53 2005 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: streams.c,v 1.78 2005/05/16 08:37:13 tony2001 Exp $ */ +/* $Id: streams.c,v 1.79 2005/05/23 11:51:53 tony2001 Exp $ */ #define _GNU_SOURCE #include php.h @@ -603,8 +603,9 @@ } /* just break anyway, to avoid greedy read */ - if (stream-wrapper != php_plain_files_wrapper) + if (stream-wrapper != NULL stream-wrapper != php_plain_files_wrapper) { break; + } } if (didread 0) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Wbr, Antony Dovgal aka tony2001 [EMAIL PROTECTED] -- Wbr, Antony Dovgal aka tony2001 [EMAIL PROTECTED] -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src /main/streams streams.c
30441 sounds like a bogus bug report because no one can reproduce what that guy is seeing. 29023 sounds like a valid bug. 32649 is a db2 bug report ;) 32810 is a bug, but that's because tmpfile() is implemented as a wrapper-less plain file. (The|a) correct fix for 32810 is to tag the stream with the plain_files_wrapper in _php_stream_fopen_tmpfile(). The others need further investigation. Please revert your commit, because it breaks a *lot* more stuff than it fixes. Greedy reads for local files are only really around for BC reasons (that nasty fread(, filesize()) thing). --Wez. On 5/23/05, Antony Dovgal [EMAIL PROTECTED] wrote: On Mon, 23 May 2005 10:08:39 -0400 Wez Furlong [EMAIL PROTECTED] wrote: What tests did you run, and what problem were you trying to solve? You've made reads non-greedy for streams with wrappers (except for plain files), and made reads greedy for streams without wrappers. The correct semantic is: only reads on local files should be greedy (for BC); everything else should not. So, you're trying to say that #30441, #29023, #32649 and #32810 are bogus bugs? Because from what I can see they are caused by exactly this non-greediness. On 5/23/05, Antony Dovgal [EMAIL PROTECTED] wrote: On Mon, 23 May 2005 09:54:44 -0400 Wez Furlong [EMAIL PROTECTED] wrote: WTF!??? Please revert, immediately. Please care to explain why. I tested it with all kinds of wrappers and it works fine for me. On 5/23/05, Antony Dovgal [EMAIL PROTECTED] wrote: tony2001Mon May 23 07:51:53 2005 EDT Modified files: /php-src/main/streams streams.c Log: fix bug #32810 (fread after tmpfile() reads only 8192 bytes) http://cvs.php.net/diff.php/php-src/main/streams/streams.c?r1=1.78r2=1.79ty=u Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.78 php-src/main/streams/streams.c:1.79 --- php-src/main/streams/streams.c:1.78 Mon May 16 04:37:13 2005 +++ php-src/main/streams/streams.c Mon May 23 07:51:53 2005 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: streams.c,v 1.78 2005/05/16 08:37:13 tony2001 Exp $ */ +/* $Id: streams.c,v 1.79 2005/05/23 11:51:53 tony2001 Exp $ */ #define _GNU_SOURCE #include php.h @@ -603,8 +603,9 @@ } /* just break anyway, to avoid greedy read */ - if (stream-wrapper != php_plain_files_wrapper) + if (stream-wrapper != NULL stream-wrapper != php_plain_files_wrapper) { break; + } } if (didread 0) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Wbr, Antony Dovgal aka tony2001 [EMAIL PROTECTED] -- Wbr, Antony Dovgal aka tony2001 [EMAIL PROTECTED] -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /main/streams streams.c
tony2001Mon May 23 11:36:59 2005 EDT Modified files: /php-src/main/streams streams.c Log: revert by Wez's request http://cvs.php.net/diff.php/php-src/main/streams/streams.c?r1=1.79r2=1.80ty=u Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.79 php-src/main/streams/streams.c:1.80 --- php-src/main/streams/streams.c:1.79 Mon May 23 07:51:53 2005 +++ php-src/main/streams/streams.c Mon May 23 11:36:58 2005 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: streams.c,v 1.79 2005/05/23 11:51:53 tony2001 Exp $ */ +/* $Id: streams.c,v 1.80 2005/05/23 15:36:58 tony2001 Exp $ */ #define _GNU_SOURCE #include php.h @@ -603,7 +603,7 @@ } /* just break anyway, to avoid greedy read */ - if (stream-wrapper != NULL stream-wrapper != php_plain_files_wrapper) { + if (stream-wrapper != php_plain_files_wrapper) { break; } } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src /main/streams streams.c
On Mon, 23 May 2005 11:31:05 -0400 Wez Furlong [EMAIL PROTECTED] wrote: 30441 sounds like a bogus bug report because no one can reproduce what that guy is seeing. 29023 sounds like a valid bug. 32649 is a db2 bug report ;) I mean #32469 (With COM ports (Windows), fread sees nothing until 8K) Seems to be the very same issue. 32810 is a bug, but that's because tmpfile() is implemented as a wrapper-less plain file. As far as I understand wrapper-less streams should not exist at all, right? (The|a) correct fix for 32810 is to tag the stream with the plain_files_wrapper in _php_stream_fopen_tmpfile(). If you know the correct fix why don't you just fix it then? Please revert your commit, because it breaks a *lot* more stuff than it fixes. Greedy reads for local files are only really around for BC reasons (that nasty fread(, filesize()) thing). Reverted. But I would really like to see an example that is broken by this commit. Could you plz show me one, if it's not too complex for you? Thanks. -- Wbr, Antony Dovgal aka tony2001 [EMAIL PROTECTED] -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src /main/streams streams.c
On 5/23/05, Antony Dovgal [EMAIL PROTECTED] wrote: 32810 is a bug, but that's because tmpfile() is implemented as a wrapper-less plain file. As far as I understand wrapper-less streams should not exist at all, right? Wrapper-less streams are perfectly ok and acceptable, and are the default for things opened via fsockopen and some other magic internals. But I would really like to see an example that is broken by this commit. Could you plz show me one, if it's not too complex for you? Thanks. $fp = fsockopen() fread($fp, 1); this is now greedy, but should not be so, as it breaks anyone trying to write proper network aware scripts. --Wez. -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src /main/streams streams.c
On 5/23/05, Antony Dovgal [EMAIL PROTECTED] wrote: (The|a) correct fix for 32810 is to tag the stream with the plain_files_wrapper in _php_stream_fopen_tmpfile(). If you know the correct fix why don't you just fix it then? Pick one of: - Busy - Mostly without internet access this weekend - Busy - Busy - Busy --Wez. -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /main/streams streams.c
iliaa Fri Apr 29 15:01:34 2005 EDT Modified files: /php-src/main/streams streams.c Log: Attempt to eliminate seek() prior to every write. http://cvs.php.net/diff.php/php-src/main/streams/streams.c?r1=1.76r2=1.77ty=u Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.76 php-src/main/streams/streams.c:1.77 --- php-src/main/streams/streams.c:1.76 Mon Apr 11 11:19:27 2005 +++ php-src/main/streams/streams.c Fri Apr 29 15:01:33 2005 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: streams.c,v 1.76 2005/04/11 15:19:27 tony2001 Exp $ */ +/* $Id: streams.c,v 1.77 2005/04/29 19:01:33 iliaa Exp $ */ #define _GNU_SOURCE #include php.h @@ -892,7 +892,7 @@ /* if we have a seekable stream we need to ensure that data is written at the * current stream-position. This means invalidating the read buffer and then * performing a low-level seek */ - if (stream-ops-seek (stream-flags PHP_STREAM_FLAG_NO_SEEK) == 0) { + if (stream-ops-seek (stream-flags PHP_STREAM_FLAG_NO_SEEK) == 0 stream-readpos != stream-writepos) { stream-readpos = stream-writepos = 0; stream-ops-seek(stream, stream-position, SEEK_SET, stream-position TSRMLS_CC); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src /main/streams streams.c
Seems to me best to revert. Antony, maybe you can get from Ilia the script that reproduced the valgrind exposure of the problem. At 01:33 AM 4/8/2005 +0300, Antony Dovgal wrote: If I should - just tell me, I'll do it. On Thu, 7 Apr 2005 22:01:14 +0300 (EEST) Jani Taskinen [EMAIL PROTECTED] wrote: Should Antony revert his patch then..? (wasn't Wez basically saying that? :) --Jani On Wed, 6 Apr 2005, Ilia Alshanetsky wrote: I checked the code with valgrind and it seems to me like the problem lies else where. According to valgrind (at some point, probably the last line) we have a Conditional jump or move depends on uninitialised value(s) php_stream_get_record (/php5/main/streams/streams.c:847) -- Wbr, Antony Dovgal aka tony2001 [EMAIL PROTECTED] -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src /main/streams streams.c
Andi Gutmans wrote: Seems to me best to revert. Antony, maybe you can get from Ilia the script that reproduced the valgrind exposure of the problem. The test case for stream_get_line() (bug #30362) exposes the valgrind error. Ilia -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /main/streams streams.c
tony2001Mon Apr 11 11:19:32 2005 EDT Modified files: /php-src/main/streams streams.c Log: revert the patch, the problem seems to be somewhere else http://cvs.php.net/diff.php/php-src/main/streams/streams.c?r1=1.75r2=1.76ty=u Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.75 php-src/main/streams/streams.c:1.76 --- php-src/main/streams/streams.c:1.75 Sat Apr 9 15:36:49 2005 +++ php-src/main/streams/streams.c Mon Apr 11 11:19:27 2005 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: streams.c,v 1.75 2005/04/09 19:36:49 pollita Exp $ */ +/* $Id: streams.c,v 1.76 2005/04/11 15:19:27 tony2001 Exp $ */ #define _GNU_SOURCE #include php.h @@ -847,10 +847,6 @@ php_stream_fill_read_buffer(stream, maxlen TSRMLS_CC); - if ((stream-writepos - stream-readpos)=0) { - return NULL; - } - if (delim_len == 0 || !delim) { toread = maxlen; } else { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /main/streams streams.c
pollita Sat Apr 9 15:36:50 2005 EDT Modified files: /php-src/main/streams streams.c Log: Fold validation into an inlined function per Andi's suggestion http://cvs.php.net/diff.php/php-src/main/streams/streams.c?r1=1.74r2=1.75ty=u Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.74 php-src/main/streams/streams.c:1.75 --- php-src/main/streams/streams.c:1.74 Wed Apr 6 04:26:06 2005 +++ php-src/main/streams/streams.c Sat Apr 9 15:36:49 2005 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: streams.c,v 1.74 2005/04/06 08:26:06 tony2001 Exp $ */ +/* $Id: streams.c,v 1.75 2005/04/09 19:36:49 pollita Exp $ */ #define _GNU_SOURCE #include php.h @@ -1417,10 +1417,12 @@ return SUCCESS; } -/* API for registering GLOBAL wrappers */ -PHPAPI int php_register_url_stream_wrapper(char *protocol, php_stream_wrapper *wrapper TSRMLS_DC) +/* Validate protocol scheme names during registration + * Must conform to /^[a-zA-Z0-9+.-]+$/ + */ +static inline int php_stream_wrapper_scheme_validate(char *protocol, int protocol_len) { - int i, protocol_len = strlen(protocol); + int i; for(i = 0; i protocol_len; i++) { if (!isalnum((int)protocol[i]) @@ -1431,6 +1433,18 @@ } } + return SUCCESS; +} + +/* API for registering GLOBAL wrappers */ +PHPAPI int php_register_url_stream_wrapper(char *protocol, php_stream_wrapper *wrapper TSRMLS_DC) +{ + int protocol_len = strlen(protocol); + + if (php_stream_wrapper_scheme_validate(protocol, protocol_len) == FAILURE) { + return FAILURE; + } + return zend_hash_add(url_stream_wrappers_hash, protocol, protocol_len, wrapper, sizeof(*wrapper), NULL); } @@ -1442,15 +1456,10 @@ /* API for registering VOLATILE wrappers */ PHPAPI int php_register_url_stream_wrapper_volatile(char *protocol, php_stream_wrapper *wrapper TSRMLS_DC) { - int i, protocol_len = strlen(protocol); + int protocol_len = strlen(protocol); - for(i = 0; i protocol_len; i++) { - if (!isalnum((int)protocol[i]) - protocol[i] != '+' - protocol[i] != '-' - protocol[i] != '.') { - return FAILURE; - } + if (php_stream_wrapper_scheme_validate(protocol, protocol_len) == FAILURE) { + return FAILURE; } if (!FG(stream_wrappers)) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src /main/streams streams.c
Should Antony revert his patch then..? (wasn't Wez basically saying that? :) --Jani On Wed, 6 Apr 2005, Ilia Alshanetsky wrote: I checked the code with valgrind and it seems to me like the problem lies else where. According to valgrind (at some point, probably the last line) we have a Conditional jump or move depends on uninitialised value(s) php_stream_get_record (/php5/main/streams/streams.c:847) Ilia Antony Dovgal wrote: On Wed, 6 Apr 2005 09:05:35 -0400 Wez Furlong [EMAIL PROTECTED] wrote: What problem does this fix? EOF can be a temporary condition for network streams, depending on non-blocking status, and the read call is used to re-enable it. (yay for backward compatibility). stream_get_line() gives a lot of garbage trying to read after EOF and segfaults with this code: ? $fp = fopen(dirname(__FILE__)./test.txt, 'r'); while ($data = stream_get_line($fp, 100, |)) { var_dump($data); } ? test.txt contents: --- line1 | some | another --- -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src /main/streams streams.c
If I should - just tell me, I'll do it. On Thu, 7 Apr 2005 22:01:14 +0300 (EEST) Jani Taskinen [EMAIL PROTECTED] wrote: Should Antony revert his patch then..? (wasn't Wez basically saying that? :) --Jani On Wed, 6 Apr 2005, Ilia Alshanetsky wrote: I checked the code with valgrind and it seems to me like the problem lies else where. According to valgrind (at some point, probably the last line) we have a Conditional jump or move depends on uninitialised value(s) php_stream_get_record (/php5/main/streams/streams.c:847) -- Wbr, Antony Dovgal aka tony2001 [EMAIL PROTECTED] -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /main/streams streams.c
tony2001Wed Apr 6 04:26:06 2005 EDT Modified files: /php-src/main/streams streams.c Log: do not try to read after EOF http://cvs.php.net/diff.php/php-src/main/streams/streams.c?r1=1.73r2=1.74ty=u Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.73 php-src/main/streams/streams.c:1.74 --- php-src/main/streams/streams.c:1.73 Mon Apr 4 23:00:04 2005 +++ php-src/main/streams/streams.c Wed Apr 6 04:26:06 2005 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: streams.c,v 1.73 2005/04/05 03:00:04 iliaa Exp $ */ +/* $Id: streams.c,v 1.74 2005/04/06 08:26:06 tony2001 Exp $ */ #define _GNU_SOURCE #include php.h @@ -847,6 +847,10 @@ php_stream_fill_read_buffer(stream, maxlen TSRMLS_CC); + if ((stream-writepos - stream-readpos)=0) { + return NULL; + } + if (delim_len == 0 || !delim) { toread = maxlen; } else { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src /main/streams streams.c
What problem does this fix? EOF can be a temporary condition for network streams, depending on non-blocking status, and the read call is used to re-enable it. (yay for backward compatibility). --Wez. On Apr 6, 2005 4:26 AM, Antony Dovgal [EMAIL PROTECTED] wrote: tony2001Wed Apr 6 04:26:06 2005 EDT Modified files: /php-src/main/streams streams.c Log: do not try to read after EOF http://cvs.php.net/diff.php/php-src/main/streams/streams.c?r1=1.73r2=1.74ty=u Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.73 php-src/main/streams/streams.c:1.74 --- php-src/main/streams/streams.c:1.73 Mon Apr 4 23:00:04 2005 +++ php-src/main/streams/streams.c Wed Apr 6 04:26:06 2005 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: streams.c,v 1.73 2005/04/05 03:00:04 iliaa Exp $ */ +/* $Id: streams.c,v 1.74 2005/04/06 08:26:06 tony2001 Exp $ */ #define _GNU_SOURCE #include php.h @@ -847,6 +847,10 @@ php_stream_fill_read_buffer(stream, maxlen TSRMLS_CC); + if ((stream-writepos - stream-readpos)=0) { + return NULL; + } + if (delim_len == 0 || !delim) { toread = maxlen; } else { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src /main/streams streams.c
On Wed, 6 Apr 2005 09:05:35 -0400 Wez Furlong [EMAIL PROTECTED] wrote: What problem does this fix? EOF can be a temporary condition for network streams, depending on non-blocking status, and the read call is used to re-enable it. (yay for backward compatibility). stream_get_line() gives a lot of garbage trying to read after EOF and segfaults with this code: ? $fp = fopen(dirname(__FILE__)./test.txt, 'r'); while ($data = stream_get_line($fp, 100, |)) { var_dump($data); } ? test.txt contents: --- line1 | some | another --- -- Wbr, Antony Dovgal aka tony2001 [EMAIL PROTECTED] -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /main/streams streams.c
pollita Mon Apr 4 15:34:33 2005 EDT Modified files: /php-src/main/streams streams.c Log: BugFix #32563 This could have been done in stream_wrapper_register() without introducing the slight performance hit on wrapper registration since anyone registering a wrapper in an extension should know better. The important thing is that since locate_wrapper makes the assumption that all schemes will be /^[a-z0-9+.-]+$/i Anything which registers them should make the same assumption as well. http://cvs.php.net/diff.php/php-src/main/streams/streams.c?r1=1.71r2=1.72ty=u Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.71 php-src/main/streams/streams.c:1.72 --- php-src/main/streams/streams.c:1.71 Mon Feb 21 19:24:13 2005 +++ php-src/main/streams/streams.c Mon Apr 4 15:34:32 2005 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: streams.c,v 1.71 2005/02/22 00:24:13 iliaa Exp $ */ +/* $Id: streams.c,v 1.72 2005/04/04 19:34:32 pollita Exp $ */ #define _GNU_SOURCE #include php.h @@ -1410,7 +1410,18 @@ /* API for registering GLOBAL wrappers */ PHPAPI int php_register_url_stream_wrapper(char *protocol, php_stream_wrapper *wrapper TSRMLS_DC) { - return zend_hash_add(url_stream_wrappers_hash, protocol, strlen(protocol), wrapper, sizeof(*wrapper), NULL); + int i, protocol_len = strlen(protocol); + + for(i = 0; i protocol_len; i++) { + if (!isalnum((int)protocol[i]) + protocol[i] != '+' + protocol[i] != '-' + protocol[i] != '.') { + return FAILURE; + } + } + + return zend_hash_add(url_stream_wrappers_hash, protocol, protocol_len, wrapper, sizeof(*wrapper), NULL); } PHPAPI int php_unregister_url_stream_wrapper(char *protocol TSRMLS_DC) @@ -1421,6 +1432,17 @@ /* API for registering VOLATILE wrappers */ PHPAPI int php_register_url_stream_wrapper_volatile(char *protocol, php_stream_wrapper *wrapper TSRMLS_DC) { + int i, protocol_len = strlen(protocol); + + for(i = 0; i protocol_len; i++) { + if (!isalnum((int)protocol[i]) + protocol[i] != '+' + protocol[i] != '-' + protocol[i] != '.') { + return FAILURE; + } + } + if (!FG(stream_wrappers)) { php_stream_wrapper tmpwrapper; @@ -1429,7 +1451,7 @@ zend_hash_copy(FG(stream_wrappers), url_stream_wrappers_hash, NULL, tmpwrapper, sizeof(php_stream_wrapper)); } - return zend_hash_add(FG(stream_wrappers), protocol, strlen(protocol), wrapper, sizeof(*wrapper), NULL); + return zend_hash_add(FG(stream_wrappers), protocol, protocol_len, wrapper, sizeof(*wrapper), NULL); } PHPAPI int php_unregister_url_stream_wrapper_volatile(char *protocol TSRMLS_DC) -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /main/streams streams.c
iliaa Mon Apr 4 23:00:05 2005 EDT Modified files: /php-src/main/streams streams.c Log: Fixed bug #30362 (stream_get_line() not reading data correctly). http://cvs.php.net/diff.php/php-src/main/streams/streams.c?r1=1.72r2=1.73ty=u Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.72 php-src/main/streams/streams.c:1.73 --- php-src/main/streams/streams.c:1.72 Mon Apr 4 15:34:32 2005 +++ php-src/main/streams/streams.c Mon Apr 4 23:00:04 2005 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: streams.c,v 1.72 2005/04/04 19:34:32 pollita Exp $ */ +/* $Id: streams.c,v 1.73 2005/04/05 03:00:04 iliaa Exp $ */ #define _GNU_SOURCE #include php.h @@ -843,6 +843,7 @@ { char *e, *buf; size_t toread; + int skip = 0; php_stream_fill_read_buffer(stream, maxlen TSRMLS_CC); @@ -850,15 +851,16 @@ toread = maxlen; } else { if (delim_len == 1) { - e = memchr(stream-readbuf, *delim, stream-readbuflen); + e = memchr(stream-readbuf + stream-readpos, *delim, stream-readbuflen - stream-readpos); } else { - e = php_memnstr(stream-readbuf, delim, delim_len, (stream-readbuf + stream-readbuflen)); + e = php_memnstr(stream-readbuf + stream-readpos, delim, delim_len, (stream-readbuf + stream-readbuflen)); } if (!e) { toread = maxlen; } else { - toread = e - (char *) stream-readbuf; + toread = e - (char *) stream-readbuf - stream-readpos; + skip = 1; } } @@ -868,8 +870,12 @@ buf = emalloc(toread + 1); *returned_len = php_stream_read(stream, buf, toread); - + if (*returned_len = 0) { + if (skip) { + stream-readpos += delim_len; + stream-position += delim_len; + } buf[*returned_len] = '\0'; return buf; } else { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /main/streams streams.c
rrichards Thu Nov 11 08:08:34 2004 EDT Modified files: /php-src/main/streams streams.c Log: add support for file://localhost/ support file:/// under windows again http://cvs.php.net/diff.php/php-src/main/streams/streams.c?r1=1.68r2=1.69ty=u Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.68 php-src/main/streams/streams.c:1.69 --- php-src/main/streams/streams.c:1.68 Mon Oct 11 14:31:47 2004 +++ php-src/main/streams/streams.c Thu Nov 11 08:08:32 2004 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: streams.c,v 1.68 2004/10/11 18:31:47 iliaa Exp $ */ +/* $Id: streams.c,v 1.69 2004/11/11 13:08:32 rrichards Exp $ */ #define _GNU_SOURCE #include php.h @@ -1492,24 +1492,36 @@ } /* TODO: curl based streams probably support file:// properly */ if (!protocol || !strncasecmp(protocol, file, n)) { -#ifdef PHP_WIN32 - if (protocol path[n+1] == '/' path[n+2] == '/' path[n+4] != ':') { + if (protocol) { + int localhost = 0; + + if (!strncasecmp(path, file://localhost/, 17)) { + localhost = 1; + } + +#ifdef PHP_WIN32 + if (localhost == 0 path[n+3] != '\0' path[n+3] != '/' path[n+4] != ':'){ #else - if (protocol path[n+1] == '/' path[n+2] == '/' path[n+3] != '/') { + if (localhost == 0 path[n+3] != '/') { #endif - if (options REPORT_ERRORS) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, remote host file access not supported, %s, path); + if (options REPORT_ERRORS) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, remote host file access not supported, %s, path); + } + return NULL; } - return NULL; - } - if (protocol path_for_open) { - /* skip past protocol and :/, but handle windows correctly */ - *path_for_open = (char*)path + n + 1; - while (*(++*path_for_open)=='/'); + + if (path_for_open) { + /* skip past protocol and :/, but handle windows correctly */ + *path_for_open = (char*)path + n + 1; + if (localhost == 1) { + (*path_for_open) += 11; + } + while (*(++*path_for_open)=='/'); #ifdef PHP_WIN32 - if (*(*path_for_open + 1) != ':') + if (*(*path_for_open + 1) != ':') #endif - (*path_for_open)--; + (*path_for_open)--; + } } if (options STREAM_LOCATE_WRAPPERS_ONLY) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /main/streams streams.c
pollita Fri Sep 10 17:50:29 2004 EDT Modified files: /php-src/main/streams streams.c Log: A little extra code to allow overriding plainfiles wrapper as well http://cvs.php.net/diff.php/php-src/main/streams/streams.c?r1=1.64r2=1.65ty=u Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.64 php-src/main/streams/streams.c:1.65 --- php-src/main/streams/streams.c:1.64 Fri Sep 10 16:45:35 2004 +++ php-src/main/streams/streams.c Fri Sep 10 17:50:29 2004 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: streams.c,v 1.64 2004/09/10 20:45:35 pollita Exp $ */ +/* $Id: streams.c,v 1.65 2004/09/10 21:50:29 pollita Exp $ */ #define _GNU_SOURCE #include php.h @@ -1501,9 +1501,32 @@ #endif (*path_for_open)--; } + + if (options STREAM_LOCATE_WRAPPERS_ONLY) { + return NULL; + } - /* fall back on regular file access */ - return (options STREAM_LOCATE_WRAPPERS_ONLY) ? NULL : php_plain_files_wrapper; + if (FG(stream_wrappers)) { + /* The file:// wrapper may have been disabled/overridden */ + + if (wrapper) { + /* It was found so go ahead and provide it */ + return wrapper; + } + + /* Check again, the original check might have not known the protocol name */ + if (zend_hash_find(wrapper_hash, file, sizeof(file)-1, (void**)wrapper) == SUCCESS) { + return wrapper; + } + + if (options REPORT_ERRORS) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, Plainfiles wrapper disabled); + } + return NULL; + } + + /* fall back on regular file access */ + return php_plain_files_wrapper; } if (wrapper wrapper-is_url !PG(allow_url_fopen)) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /main/streams streams.c
pollita Wed Sep 8 14:42:15 2004 EDT Modified files: /php-src/main/streams streams.c Log: Handle maxlen when stream can't be mmaped http://cvs.php.net/diff.php/php-src/main/streams/streams.c?r1=1.62r2=1.63ty=u Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.62 php-src/main/streams/streams.c:1.63 --- php-src/main/streams/streams.c:1.62 Tue Aug 31 07:37:02 2004 +++ php-src/main/streams/streams.c Wed Sep 8 14:42:15 2004 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: streams.c,v 1.62 2004/08/31 11:37:02 tony2001 Exp $ */ +/* $Id: streams.c,v 1.63 2004/09/08 18:42:15 pollita Exp $ */ #define _GNU_SOURCE #include php.h @@ -1209,6 +1209,17 @@ return mapped; } + } + + if (maxlen 0) { + ptr = *buf = pemalloc_rel_orig(maxlen + 1, persistent); + while ((len maxlen) !php_stream_eof(src)) { + ret = php_stream_read(src, ptr, maxlen - len); + len += ret; + ptr += ret; + } + *ptr = '\0'; + return len; } /* avoid many reallocs by allocating a good sized chunk to begin with, if -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /main/streams streams.c
tony2001Tue Aug 31 07:37:02 2004 EDT Modified files: /php-src/main/streams streams.c Log: fix bug #29723 (file_get_contents() fails with the file:// wrapper under Win32) http://cvs.php.net/diff.php/php-src/main/streams/streams.c?r1=1.61r2=1.62ty=u Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.61 php-src/main/streams/streams.c:1.62 --- php-src/main/streams/streams.c:1.61 Tue Jul 13 12:34:56 2004 +++ php-src/main/streams/streams.c Tue Aug 31 07:37:02 2004 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: streams.c,v 1.61 2004/07/13 16:34:56 wez Exp $ */ +/* $Id: streams.c,v 1.62 2004/08/31 11:37:02 tony2001 Exp $ */ #define _GNU_SOURCE #include php.h @@ -1454,7 +1454,11 @@ } /* TODO: curl based streams probably support file:// properly */ if (!protocol || !strncasecmp(protocol, file, n)) { +#ifdef PHP_WIN32 + if (protocol path[n+1] == '/' path[n+2] == '/' path[n+4] != ':') { +#else if (protocol path[n+1] == '/' path[n+2] == '/' path[n+3] != '/') { +#endif if (options REPORT_ERRORS) { php_error_docref(NULL TSRMLS_CC, E_WARNING, remote host file access not supported, %s, path); } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /main/streams streams.c
wez Tue Jul 13 12:34:57 2004 EDT Modified files: /php-src/main/streams streams.c Log: Looks like Sara forgot to change this too. http://cvs.php.net/diff.php/php-src/main/streams/streams.c?r1=1.60r2=1.61ty=u Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.60 php-src/main/streams/streams.c:1.61 --- php-src/main/streams/streams.c:1.60 Mon Jul 12 16:59:24 2004 +++ php-src/main/streams/streams.c Tue Jul 13 12:34:56 2004 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: streams.c,v 1.60 2004/07/12 20:59:24 wez Exp $ */ +/* $Id: streams.c,v 1.61 2004/07/13 16:34:56 wez Exp $ */ #define _GNU_SOURCE #include php.h @@ -1376,7 +1376,7 @@ int php_shutdown_stream_wrappers(int module_number TSRMLS_DC) { zend_hash_destroy(url_stream_wrappers_hash); - zend_hash_destroy(php_get_stream_filters_hash()); + zend_hash_destroy(php_get_stream_filters_hash_global()); zend_hash_destroy(php_stream_xport_get_hash()); return SUCCESS; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src /main/streams streams.c
Nice catch! At 04:34 PM 7/13/2004 +, Wez Furlong wrote: wez Tue Jul 13 12:34:57 2004 EDT Modified files: /php-src/main/streams streams.c Log: Looks like Sara forgot to change this too. http://cvs.php.net/diff.php/php-src/main/streams/streams.c?r1=1.60r2=1.61ty=u Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.60 php-src/main/streams/streams.c:1.61 --- php-src/main/streams/streams.c:1.60 Mon Jul 12 16:59:24 2004 +++ php-src/main/streams/streams.c Tue Jul 13 12:34:56 2004 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: streams.c,v 1.60 2004/07/12 20:59:24 wez Exp $ */ +/* $Id: streams.c,v 1.61 2004/07/13 16:34:56 wez Exp $ */ #define _GNU_SOURCE #include php.h @@ -1376,7 +1376,7 @@ int php_shutdown_stream_wrappers(int module_number TSRMLS_DC) { zend_hash_destroy(url_stream_wrappers_hash); - zend_hash_destroy(php_get_stream_filters_hash()); + zend_hash_destroy(php_get_stream_filters_hash_global()); zend_hash_destroy(php_stream_xport_get_hash()); return SUCCESS; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /main/streams streams.c
wez Mon Jul 12 16:59:24 2004 EDT Modified files: /php-src/main/streams streams.c Log: Fix file_get_contents() bug... http://cvs.php.net/diff.php/php-src/main/streams/streams.c?r1=1.59r2=1.60ty=u Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.59 php-src/main/streams/streams.c:1.60 --- php-src/main/streams/streams.c:1.59 Sat Jul 10 06:54:09 2004 +++ php-src/main/streams/streams.c Mon Jul 12 16:59:24 2004 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: streams.c,v 1.59 2004/07/10 10:54:09 wez Exp $ */ +/* $Id: streams.c,v 1.60 2004/07/12 20:59:24 wez Exp $ */ #define _GNU_SOURCE #include php.h @@ -1231,6 +1231,8 @@ *buf = perealloc_rel_orig(*buf, max_len + step, persistent); max_len += step; ptr = *buf + len; + } else { + ptr += ret; } } if (len) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /main/streams streams.c
wez Tue Jun 29 17:51:53 2004 EDT Modified files: /php-src/main/streams streams.c Log: Fix for Bug #28964 fread greedy behaviour http://cvs.php.net/diff.php/php-src/main/streams/streams.c?r1=1.57r2=1.58ty=u Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.57 php-src/main/streams/streams.c:1.58 --- php-src/main/streams/streams.c:1.57 Mon Jun 21 17:08:05 2004 +++ php-src/main/streams/streams.c Tue Jun 29 17:51:53 2004 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: streams.c,v 1.57 2004/06/21 21:08:05 pollita Exp $ */ +/* $Id: streams.c,v 1.58 2004/06/29 21:51:53 wez Exp $ */ #define _GNU_SOURCE #include php.h @@ -590,6 +590,9 @@ /* EOF, or temporary end of data (for non-blocking mode). */ break; } + + /* just break anyway, to avoid greedy read */ + break; } if (didread 0) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /main/streams streams.c
wez Thu May 27 09:04:14 2004 EDT Modified files: /php-src/main/streams streams.c Log: Fix #25939 for good this time. # How could I miss this?? http://cvs.php.net/diff.php/php-src/main/streams/streams.c?r1=1.54r2=1.55ty=u Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.54 php-src/main/streams/streams.c:1.55 --- php-src/main/streams/streams.c:1.54 Wed Mar 31 20:07:54 2004 +++ php-src/main/streams/streams.c Thu May 27 09:04:14 2004 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: streams.c,v 1.54 2004/04/01 01:07:54 pollita Exp $ */ +/* $Id: streams.c,v 1.55 2004/05/27 13:04:14 wez Exp $ */ #define _GNU_SOURCE #include php.h @@ -608,7 +608,7 @@ /* use the configured timeout when checking eof */ if (!stream-eof PHP_STREAM_OPTION_RETURN_ERR == php_stream_set_option(stream, PHP_STREAM_OPTION_CHECK_LIVENESS, - -1, NULL)) { + 0, NULL)) { stream-eof = 1; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /main/streams streams.c
wez Sun Mar 7 16:36:55 2004 EDT Modified files: /php-src/main/streams streams.c Log: Less magic please http://cvs.php.net/diff.php/php-src/main/streams/streams.c?r1=1.50r2=1.51ty=u Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.50 php-src/main/streams/streams.c:1.51 --- php-src/main/streams/streams.c:1.50 Mon Mar 1 02:02:23 2004 +++ php-src/main/streams/streams.c Sun Mar 7 16:36:55 2004 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: streams.c,v 1.50 2004/03/01 07:02:23 jon Exp $ */ +/* $Id: streams.c,v 1.51 2004/03/07 21:36:55 wez Exp $ */ #define _GNU_SOURCE #include php.h @@ -1881,7 +1881,10 @@ vector = (php_stream_dirent **) erealloc(vector, vector_size * sizeof(php_stream_dirent *)); } - vector[nfiles++] = (php_stream_dirent*)estrndup((const char *)sdp, sizeof(php_stream_dirent) + ((strlen(sdp.d_name) + 1) * sizeof(char))); + vector[nfiles] = emalloc(sizeof(php_stream_dirent)); + memcpy(vector[nfiles], sdp, sizeof(sdp)); + + nfiles++; } php_stream_closedir(stream); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /main/streams streams.c
wez Sun Mar 7 17:06:37 2004 EDT Modified files: /php-src/main/streams streams.c Log: add cast for qsort compare function. Kinda ugly, but helps assert that we are doing the right thing as well as kill the warning there. http://cvs.php.net/diff.php/php-src/main/streams/streams.c?r1=1.51r2=1.52ty=u Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.51 php-src/main/streams/streams.c:1.52 --- php-src/main/streams/streams.c:1.51 Sun Mar 7 16:36:55 2004 +++ php-src/main/streams/streams.c Sun Mar 7 17:06:36 2004 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: streams.c,v 1.51 2004/03/07 21:36:55 wez Exp $ */ +/* $Id: streams.c,v 1.52 2004/03/07 22:06:36 wez Exp $ */ #define _GNU_SOURCE #include php.h @@ -1891,7 +1891,7 @@ *namelist = vector; if (compare) { - qsort(*namelist, nfiles, sizeof(php_stream_dirent *), compare); + qsort(*namelist, nfiles, sizeof(php_stream_dirent *), (int(*)(const void *, const void *))compare); } return nfiles; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /main/streams streams.c
jon Mon Mar 1 02:02:24 2004 EDT Modified files: /php-src/main/streams streams.c Log: Cast the php_stream_dirent to a 'const char *' for estrndup() to avoid a compiler warning. http://cvs.php.net/diff.php/php-src/main/streams/streams.c?r1=1.49r2=1.50ty=u Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.49 php-src/main/streams/streams.c:1.50 --- php-src/main/streams/streams.c:1.49 Wed Feb 4 17:46:44 2004 +++ php-src/main/streams/streams.c Mon Mar 1 02:02:23 2004 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: streams.c,v 1.49 2004/02/04 22:46:44 wez Exp $ */ +/* $Id: streams.c,v 1.50 2004/03/01 07:02:23 jon Exp $ */ #define _GNU_SOURCE #include php.h @@ -1881,7 +1881,7 @@ vector = (php_stream_dirent **) erealloc(vector, vector_size * sizeof(php_stream_dirent *)); } - vector[nfiles++] = (php_stream_dirent*)estrndup(sdp, sizeof(php_stream_dirent) + ((strlen(sdp.d_name) + 1) * sizeof(char))); + vector[nfiles++] = (php_stream_dirent*)estrndup((const char *)sdp, sizeof(php_stream_dirent) + ((strlen(sdp.d_name) + 1) * sizeof(char))); } php_stream_closedir(stream); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src /main/streams streams.c transports.c xp_socket.c
Does this fix have possibly anything to do with bug #26863 ?? And how about doing a nice little MFH? --Jani On Wed, 4 Feb 2004, Wez Furlong wrote: wezWed Feb 4 17:46:45 2004 EDT Modified files: /php-src/main/streams streams.c transports.c xp_socket.c Log: Fix a bug in the persistent socket liveness checks and feof(); they were using the default socket timeout of 60 seconds before returning the socket to the calling script. The reason they were using that value is that the same code is used for feof(), so the fix is allowing the caller to indicate the timeout value for liveness checks. A possible remaining issue now is that 0 second timeout[1] for pfsockopen is possibly too short; it's impossible to specify a sane value for all possible uses, so maybe we need a stream context or an .ini option to control this, or maybe use the timeout value that was passed to pfsockopen(). # [1] by timeout, I mean the time that PHP will wait for data on a # persistent socket before deciding if a new connection should be made; # NOT the timeout while waiting for a new connection to be established. http://cvs.php.net/diff.php/php-src/main/streams/streams.c?r1=1.48r2=1.49ty=u Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.48 php-src/main/streams/streams.c:1.49 --- php-src/main/streams/streams.c:1.48Wed Jan 28 17:21:54 2004 +++ php-src/main/streams/streams.c Wed Feb 4 17:46:44 2004 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: streams.c,v 1.48 2004/01/28 22:21:54 pollita Exp $ */ +/* $Id: streams.c,v 1.49 2004/02/04 22:46:44 wez Exp $ */ #define _GNU_SOURCE #include php.h @@ -602,9 +602,10 @@ return 0; } + /* use the configured timeout when checking eof */ if (!stream-eof PHP_STREAM_OPTION_RETURN_ERR == php_stream_set_option(stream, PHP_STREAM_OPTION_CHECK_LIVENESS, - 0, NULL)) { + -1, NULL)) { stream-eof = 1; } http://cvs.php.net/diff.php/php-src/main/streams/transports.c?r1=1.11r2=1.12ty=u Index: php-src/main/streams/transports.c diff -u php-src/main/streams/transports.c:1.11 php-src/main/streams/transports.c:1.12 --- php-src/main/streams/transports.c:1.11 Tue Jan 27 17:40:44 2004 +++ php-src/main/streams/transports.c Wed Feb 4 17:46:44 2004 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: transports.c,v 1.11 2004/01/27 22:40:44 wez Exp $ */ +/* $Id: transports.c,v 1.12 2004/02/04 22:46:44 wez Exp $ */ #include php.h #include php_streams_int.h @@ -74,6 +74,8 @@ if (persistent_id) { switch(php_stream_from_persistent_id(persistent_id, stream TSRMLS_CC)) { case PHP_STREAM_PERSISTENT_SUCCESS: + /* use a 0 second timeout when checking if the socket + * has already died */ if (PHP_STREAM_OPTION_RETURN_OK == php_stream_set_option(stream, PHP_STREAM_OPTION_CHECK_LIVENESS, 0, NULL)) { return stream; } http://cvs.php.net/diff.php/php-src/main/streams/xp_socket.c?r1=1.21r2=1.22ty=u Index: php-src/main/streams/xp_socket.c diff -u php-src/main/streams/xp_socket.c:1.21 php-src/main/streams/xp_socket.c:1.22 --- php-src/main/streams/xp_socket.c:1.21 Thu Jan 8 03:17:59 2004 +++ php-src/main/streams/xp_socket.c Wed Feb 4 17:46:44 2004 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: xp_socket.c,v 1.21 2004/01/08 08:17:59 andi Exp $ */ +/* $Id: xp_socket.c,v 1.22 2004/02/04 22:46:44 wez Exp $ */ #include php.h #include ext/standard/file.h @@ -230,10 +230,14 @@ char buf; int alive = 1; - if (sock-timeout.tv_sec == -1) { - tv.tv_sec = FG(default_socket_timeout); + if (value == -1) { + if (sock-timeout.tv_sec == -1) { + tv.tv_sec = FG(default_socket_timeout); + } else { + tv = sock-timeout; + } } else { - tv = sock-timeout; + tv.tv_sec = value; } if (sock-socket == -1) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src /main/streams streams.c transports.c xp_socket.c
Possibly :) I found the code hanging around in my tree after being there for a week or more; I can't remember what I was working towards when I wrote it, and I'm a little too busy to check into it right now. Try this with php4.3: php -r '$fp = pfsockopen(localhost,80); $fp = pfsockopen(localhost,80);' the patch needs MFH'ing if that takes ~60 seconds to complete with no error message; I'll merge it if it needs doing (it won't be simple since the guts have changed from 4.3 to 5). --Wez. - Original Message - From: Jani Taskinen [EMAIL PROTECTED] To: Wez Furlong [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Thursday, February 05, 2004 12:53 AM Subject: Re: [PHP-CVS] cvs: php-src /main/streams streams.c transports.c xp_socket.c Does this fix have possibly anything to do with bug #26863 ?? And how about doing a nice little MFH? -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src /main/streams streams.c transports.c xp_socket.c
I'm propably missing the point..but that test completes without any errors in ~30 secs with latest builds of both PHP_4_3 and HEAD. (HEAD without your patch does exactly same..) (propably irrelevant, but with 4.2.3 it completes in less than a second, also without any errors) --Jani On Thu, 5 Feb 2004, Wez Furlong wrote: Possibly :) I found the code hanging around in my tree after being there for a week or more; I can't remember what I was working towards when I wrote it, and I'm a little too busy to check into it right now. Try this with php4.3: php -r '$fp = pfsockopen(localhost,80); $fp = pfsockopen(localhost,80);' the patch needs MFH'ing if that takes ~60 seconds to complete with no error message; I'll merge it if it needs doing (it won't be simple since the guts have changed from 4.3 to 5). --Wez. - Original Message - From: Jani Taskinen [EMAIL PROTECTED] To: Wez Furlong [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Thursday, February 05, 2004 12:53 AM Subject: Re: [PHP-CVS] cvs: php-src /main/streams streams.c transports.c xp_socket.c Does this fix have possibly anything to do with bug #26863 ?? And how about doing a nice little MFH? -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src /main/streams streams.c transports.c xp_socket.c
It should be more like 4.2.x and return in a very short time; it returns immediately for me using php5 + my patch. Is your default_socket_timeout set to 30 seconds? --Wez. - Original Message - From: Jani Taskinen [EMAIL PROTECTED] To: Wez Furlong [EMAIL PROTECTED] Cc: Wez Furlong [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Thursday, February 05, 2004 1:31 AM Subject: Re: [PHP-CVS] cvs: php-src /main/streams streams.c transports.c xp_socket.c I'm propably missing the point..but that test completes without any errors in ~30 secs with latest builds of both PHP_4_3 and HEAD. (HEAD without your patch does exactly same..) (propably irrelevant, but with 4.2.3 it completes in less than a second, also without any errors) --Jani On Thu, 5 Feb 2004, Wez Furlong wrote: Possibly :) I found the code hanging around in my tree after being there for a week or more; I can't remember what I was working towards when I wrote it, and I'm a little too busy to check into it right now. Try this with php4.3: php -r '$fp = pfsockopen(localhost,80); $fp = pfsockopen(localhost,80);' the patch needs MFH'ing if that takes ~60 seconds to complete with no error message; I'll merge it if it needs doing (it won't be simple since the guts have changed from 4.3 to 5). --Wez. - Original Message - From: Jani Taskinen [EMAIL PROTECTED] To: Wez Furlong [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Thursday, February 05, 2004 12:53 AM Subject: Re: [PHP-CVS] cvs: php-src /main/streams streams.c transports.c xp_socket.c Does this fix have possibly anything to do with bug #26863 ?? And how about doing a nice little MFH? -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src /main/streams streams.c transports.c xp_socket.c
Yes, it's 30secs..and yes, changing that changes how fast the test completes with PHP_4_3, HEAD, and HEAD without the patch. --Jani On Thu, 5 Feb 2004, Wez Furlong wrote: It should be more like 4.2.x and return in a very short time; it returns immediately for me using php5 + my patch. Is your default_socket_timeout set to 30 seconds? --Wez. - Original Message - From: Jani Taskinen [EMAIL PROTECTED] To: Wez Furlong [EMAIL PROTECTED] Cc: Wez Furlong [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Thursday, February 05, 2004 1:31 AM Subject: Re: [PHP-CVS] cvs: php-src /main/streams streams.c transports.c xp_socket.c I'm propably missing the point..but that test completes without any errors in ~30 secs with latest builds of both PHP_4_3 and HEAD. (HEAD without your patch does exactly same..) (propably irrelevant, but with 4.2.3 it completes in less than a second, also without any errors) --Jani On Thu, 5 Feb 2004, Wez Furlong wrote: Possibly :) I found the code hanging around in my tree after being there for a week or more; I can't remember what I was working towards when I wrote it, and I'm a little too busy to check into it right now. Try this with php4.3: php -r '$fp = pfsockopen(localhost,80); $fp = pfsockopen(localhost,80);' the patch needs MFH'ing if that takes ~60 seconds to complete with no error message; I'll merge it if it needs doing (it won't be simple since the guts have changed from 4.3 to 5). --Wez. - Original Message - From: Jani Taskinen [EMAIL PROTECTED] To: Wez Furlong [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Thursday, February 05, 2004 12:53 AM Subject: Re: [PHP-CVS] cvs: php-src /main/streams streams.c transports.c xp_socket.c Does this fix have possibly anything to do with bug #26863 ?? And how about doing a nice little MFH? -- https://www.paypal.com/xclick/[EMAIL PROTECTED]no_note=1tax=0currency_code=EUR -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /main/streams streams.c
iliaa Thu Nov 27 19:00:29 2003 EDT Modified files: /php-src/main/streams streams.c Log: Fixed a memory leak. Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.40 php-src/main/streams/streams.c:1.41 --- php-src/main/streams/streams.c:1.40 Sun Nov 23 12:35:00 2003 +++ php-src/main/streams/streams.c Thu Nov 27 19:00:28 2003 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: streams.c,v 1.40 2003/11/23 17:35:00 pollita Exp $ */ +/* $Id: streams.c,v 1.41 2003/11/28 00:00:28 iliaa Exp $ */ #define _GNU_SOURCE #include php.h @@ -1692,9 +1692,9 @@ ALLOC_INIT_ZVAL(copied_val); *copied_val = *optionvalue; zval_copy_ctor(copied_val); - + INIT_PZVAL(copied_val); + if (FAILURE == zend_hash_find(Z_ARRVAL_P(context-options), (char*)wrappername, strlen(wrappername)+1, (void**)wrapperhash)) { - MAKE_STD_ZVAL(category); array_init(category); if (FAILURE == zend_hash_update(Z_ARRVAL_P(context-options), (char*)wrappername, strlen(wrappername)+1, (void**)category, sizeof(zval *), NULL)) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /main/streams streams.c
pollita Sun Nov 23 12:35:01 2003 EDT Modified files: /php-src/main/streams streams.c Log: Fix for file:// wrapper parsing. (Cristiano Duarte [EMAIL PROTECTED]) Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.39 php-src/main/streams/streams.c:1.40 --- php-src/main/streams/streams.c:1.39 Mon Nov 3 09:12:46 2003 +++ php-src/main/streams/streams.c Sun Nov 23 12:35:00 2003 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: streams.c,v 1.39 2003/11/03 14:12:46 derick Exp $ */ +/* $Id: streams.c,v 1.40 2003/11/23 17:35:00 pollita Exp $ */ #define _GNU_SOURCE #include php.h @@ -1433,7 +1433,7 @@ #ifdef PHP_WIN32 if (*(*path_for_open + 1) != ':') #endif - *path_for_open--; + (*path_for_open)--; } /* fall back on regular file access */ -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src /main/streams streams.c
That win32 branch of the code looks suspect (I know it is not part of the commit). Anyone have time to check it out? --Wez. #ifdef PHP_WIN32 if (*(*path_for_open + 1) != ':') #endif - *path_for_open--; + (*path_for_open)--; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /main/streams streams.c
helly Sat Sep 13 15:56:40 2003 EDT Modified files: /php-src/main/streams streams.c Log: Show the whole message when in debug mode Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.36 php-src/main/streams/streams.c:1.37 --- php-src/main/streams/streams.c:1.36 Sat Sep 13 11:27:08 2003 +++ php-src/main/streams/streams.c Sat Sep 13 15:56:38 2003 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: streams.c,v 1.36 2003/09/13 15:27:08 abies Exp $ */ +/* $Id: streams.c,v 1.37 2003/09/13 19:56:38 helly Exp $ */ #define _GNU_SOURCE #include php.h @@ -367,8 +367,8 @@ /* it leaked: Lets deliberately NOT pefree it so that the memory manager shows it * as leaked; it will log a warning, but lets help it out and display what kind * of stream it was. */ - char leakbuf[512]; - snprintf(leakbuf, sizeof(leakbuf), __FILE__ (%d) : Stream of type '%s' %p (path:%s) was not closed\n, __LINE__, stream-ops-label, stream, stream-__orig_path); + char *leakinfo; + spprintf(leakinfo, 0, __FILE__ (%d) : Stream of type '%s' %p (path:%s) was not closed\n, __LINE__, stream-ops-label, stream, stream-__orig_path); if (stream-__orig_path) { pefree(stream-__orig_path, stream-is_persistent); @@ -376,10 +376,11 @@ } # if defined(PHP_WIN32) - OutputDebugString(leakbuf); + OutputDebugString(leakinfo); # else - fprintf(stderr, %s, leakbuf); + fprintf(stderr, %s, leakinfo); # endif + efree(leakinfo); } else { if (stream-__orig_path) { pefree(stream-__orig_path, stream-is_persistent); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /main/streams streams.c
iliaa Thu Sep 11 01:07:39 2003 EDT Modified files: /php-src/main/streams streams.c Log: Fixed bug #25316 (Possible infinite loop inside _php_stream_write()). Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.34 php-src/main/streams/streams.c:1.35 --- php-src/main/streams/streams.c:1.34 Tue Sep 9 20:58:12 2003 +++ php-src/main/streams/streams.c Thu Sep 11 01:07:26 2003 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: streams.c,v 1.34 2003/09/10 00:58:12 iliaa Exp $ */ +/* $Id: streams.c,v 1.35 2003/09/11 05:07:26 iliaa Exp $ */ #define _GNU_SOURCE #include php.h @@ -867,7 +867,8 @@ justwrote = stream-ops-write(stream, buf, towrite TSRMLS_CC); - if (justwrote 0) { + /* convert justwrote to an integer, since normally it is unsigned */ + if ((int)justwrote 0) { buf += justwrote; count -= justwrote; didwrite += justwrote; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /main/streams streams.c
iliaa Tue Sep 9 20:58:12 2003 EDT Modified files: /php-src/main/streams streams.c Log: Fixed bug #25429 (fix copying of stdin using copy() function) Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.33 php-src/main/streams/streams.c:1.34 --- php-src/main/streams/streams.c:1.33 Thu Aug 28 13:07:40 2003 +++ php-src/main/streams/streams.c Tue Sep 9 20:58:12 2003 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: streams.c,v 1.33 2003/08/28 17:07:40 sas Exp $ */ +/* $Id: streams.c,v 1.34 2003/09/10 00:58:12 iliaa Exp $ */ #define _GNU_SOURCE #include php.h @@ -1243,6 +1243,9 @@ if (ssbuf.sb.st_size == 0 #ifdef S_ISFIFO !S_ISFIFO(ssbuf.sb.st_mode) +#endif +#ifdef S_ISCHR + !S_ISCHR(ssbuf.sb.st_mode) #endif ) { return 1; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /main/streams streams.c
iliaa Mon Jul 28 14:57:28 2003 EDT Modified files: /php-src/main/streams streams.c Log: Fixed a double free bug when freeing persistent streams. Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.30 php-src/main/streams/streams.c:1.31 --- php-src/main/streams/streams.c:1.30 Wed Jul 2 18:18:59 2003 +++ php-src/main/streams/streams.c Mon Jul 28 14:57:28 2003 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: streams.c,v 1.30 2003/07/02 22:18:59 pollita Exp $ */ +/* $Id: streams.c,v 1.31 2003/07/28 18:57:28 iliaa Exp $ */ #define _GNU_SOURCE #include php.h @@ -254,7 +254,7 @@ static int _php_stream_free_persistent(list_entry *le, void *pStream TSRMLS_DC) { - return le-ptr == pStream; + return (le-ptr == pStream !((php_stream *)pStream)-in_free); } PHPAPI int _php_stream_free(php_stream *stream, int close_options TSRMLS_DC) /* {{{ */ @@ -336,8 +336,6 @@ } if (close_options PHP_STREAM_FREE_RELEASE_STREAM) { - int was_persistent = stream-is_persistent; - while (stream-readfilters.head) { php_stream_filter_remove(stream-readfilters.head, 1 TSRMLS_CC); } @@ -359,7 +357,11 @@ pefree(stream-readbuf, stream-is_persistent); stream-readbuf = NULL; } - + + if (stream-is_persistent) { + /* we don't work with *stream but need its value for comparison */ + zend_hash_apply_with_argument(EG(persistent_list), (apply_func_arg_t) _php_stream_free_persistent, stream TSRMLS_CC); + } #if ZEND_DEBUG if ((close_options PHP_STREAM_FREE_RSRC_DTOR) (stream-__exposed == 0) (EG(error_reporting) E_WARNING)) { /* it leaked: Lets deliberately NOT pefree it so that the memory manager shows it @@ -389,10 +391,6 @@ #else pefree(stream, stream-is_persistent); #endif - if (was_persistent) { - /* we don't work with *stream but need its value for comparison */ - zend_hash_apply_with_argument(EG(persistent_list), (apply_func_arg_t) _php_stream_free_persistent, stream TSRMLS_CC); - } } return ret; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /main/streams streams.c
pollita Fri Jun 27 00:27:18 2003 EDT Modified files: /php-src/main/streams streams.c Log: MFB PHP_4_3 main/streams.c r-1.125.2.70 Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.27 php-src/main/streams/streams.c:1.28 --- php-src/main/streams/streams.c:1.27 Mon Jun 16 14:19:14 2003 +++ php-src/main/streams/streams.c Fri Jun 27 00:27:18 2003 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: streams.c,v 1.27 2003/06/16 18:19:14 pollita Exp $ */ +/* $Id: streams.c,v 1.28 2003/06/27 04:27:18 pollita Exp $ */ #define _GNU_SOURCE #include php.h @@ -1622,6 +1622,10 @@ zval_ptr_dtor(context-options); context-options = NULL; } + if (context-notifier) { + php_stream_notification_free(context-notifier); + context-notifier = NULL; + } efree(context); } @@ -1630,6 +1634,7 @@ php_stream_context *context; context = ecalloc(1, sizeof(php_stream_context)); + context-notifier = NULL; MAKE_STD_ZVAL(context-options); array_init(context-options); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php