[PHP-CVS] cvs: php-src /ext/standard http_fopen_wrapper.c
lbarnaudSat May 16 20:34:08 2009 UTC Modified files: /php-src/ext/standard http_fopen_wrapper.c Log: Fixed bug #38802 (max_redirects and ignore_errors) (patch by datib...@php.net) http://cvs.php.net/viewvc.cgi/php-src/ext/standard/http_fopen_wrapper.c?r1=1.143&r2=1.144&diff_format=u Index: php-src/ext/standard/http_fopen_wrapper.c diff -u php-src/ext/standard/http_fopen_wrapper.c:1.143 php-src/ext/standard/http_fopen_wrapper.c:1.144 --- php-src/ext/standard/http_fopen_wrapper.c:1.143 Thu May 14 13:36:44 2009 +++ php-src/ext/standard/http_fopen_wrapper.c Sat May 16 20:34:08 2009 @@ -19,7 +19,7 @@ | Sara Golemon | +--+ */ -/* $Id: http_fopen_wrapper.c,v 1.143 2009/05/14 13:36:44 cellog Exp $ */ +/* $Id: http_fopen_wrapper.c,v 1.144 2009/05/16 20:34:08 lbarnaud Exp $ */ #include "php.h" #include "php_globals.h" @@ -146,7 +146,7 @@ size_t chunk_size = 0, file_size = 0; int eol_detect = 0; char *transport_string, *errstr = NULL; - int transport_len, have_header = 0, request_fulluri = 0; + int transport_len, have_header = 0, request_fulluri = 0, ignore_errors = 0; char *protocol_version = NULL; int protocol_version_len = 3; /* Default: "1.0" */ char *charset = NULL; @@ -600,9 +600,11 @@ } else { response_code = 0; } + if (context && SUCCESS==php_stream_context_get_option(context, "http", "ignore_errors", &tmpzval)) { + ignore_errors = zend_is_true(*tmpzval); + } /* when we request only the header, don't fail even on error codes */ - if ((options & STREAM_ONLY_GET_HEADERS) || - (context && php_stream_context_get_option(context, "http", "ignore_errors", &tmpzval) == SUCCESS && zend_is_true(*tmpzval)) ) { + if ((options & STREAM_ONLY_GET_HEADERS) || ignore_errors) { reqok = 1; } /* all status codes in the 2xx range are defined by the specification as successful; @@ -704,7 +706,7 @@ } if (!reqok || location[0] != '\0') { - if (options & STREAM_ONLY_GET_HEADERS && redirect_max <= 1) { + if (((options & STREAM_ONLY_GET_HEADERS) || ignore_errors) && redirect_max <= 1) { goto out; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard http_fopen_wrapper.c
cellog Thu May 14 13:36:45 2009 UTC Modified files: /php-src/ext/standard http_fopen_wrapper.c Log: fix potential free of NULL http://cvs.php.net/viewvc.cgi/php-src/ext/standard/http_fopen_wrapper.c?r1=1.142&r2=1.143&diff_format=u Index: php-src/ext/standard/http_fopen_wrapper.c diff -u php-src/ext/standard/http_fopen_wrapper.c:1.142 php-src/ext/standard/http_fopen_wrapper.c:1.143 --- php-src/ext/standard/http_fopen_wrapper.c:1.142 Tue May 5 00:30:40 2009 +++ php-src/ext/standard/http_fopen_wrapper.c Thu May 14 13:36:44 2009 @@ -19,7 +19,7 @@ | Sara Golemon | +--+ */ -/* $Id: http_fopen_wrapper.c,v 1.142 2009/05/05 00:30:40 jani Exp $ */ +/* $Id: http_fopen_wrapper.c,v 1.143 2009/05/14 13:36:44 cellog Exp $ */ #include "php.h" #include "php_globals.h" @@ -450,7 +450,9 @@ have_header |= HTTP_HEADER_TYPE; } } - efree(tmp); + if (tmp) { + efree(tmp); + } } /* auth header if it was specified */ -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard http_fopen_wrapper.c
lbarnaudTue Jul 29 13:57:20 2008 UTC Modified files: /php-src/ext/standard http_fopen_wrapper.c Log: Fixed previous fix http://cvs.php.net/viewvc.cgi/php-src/ext/standard/http_fopen_wrapper.c?r1=1.136&r2=1.137&diff_format=u Index: php-src/ext/standard/http_fopen_wrapper.c diff -u php-src/ext/standard/http_fopen_wrapper.c:1.136 php-src/ext/standard/http_fopen_wrapper.c:1.137 --- php-src/ext/standard/http_fopen_wrapper.c:1.136 Mon Jul 28 19:03:57 2008 +++ php-src/ext/standard/http_fopen_wrapper.c Tue Jul 29 13:57:20 2008 @@ -19,7 +19,7 @@ | Sara Golemon <[EMAIL PROTECTED]> | +--+ */ -/* $Id: http_fopen_wrapper.c,v 1.136 2008/07/28 19:03:57 lbarnaud Exp $ */ +/* $Id: http_fopen_wrapper.c,v 1.137 2008/07/29 13:57:20 lbarnaud Exp $ */ #include "php.h" #include "php_globals.h" @@ -81,6 +81,9 @@ #define HTTP_HEADER_CONTENT_LENGTH 16 #define HTTP_HEADER_TYPE 32 +#define HTTP_WRAPPER_HEADER_INIT1 +#define HTTP_WRAPPER_REDIRECTED 2 + static inline char *php_http_detect_charset(char *http_header_line) /* {{{ */ { char *s; @@ -123,7 +126,7 @@ } /* }}} */ -php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper, char *path, char *mode, int options, char **opened_path, php_stream_context *context, int redirect_max, int header_init STREAMS_DC TSRMLS_DC) /* {{{ */ +php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper, char *path, char *mode, int options, char **opened_path, php_stream_context *context, int redirect_max, int flags STREAMS_DC TSRMLS_DC) /* {{{ */ { php_stream *stream = NULL; php_url *resource = NULL; @@ -149,6 +152,8 @@ char *charset = NULL; struct timeval timeout; char *user_headers = NULL; + int header_init = ((flags & HTTP_WRAPPER_HEADER_INIT) != 0); + int redirected = ((flags & HTTP_WRAPPER_REDIRECTED) != 0); tmp_line[0] = '\0'; @@ -296,7 +301,7 @@ if (Z_TYPE_PP(tmpzval) == IS_STRING && Z_STRLEN_PP(tmpzval) > 0) { /* As per the RFC, automatically redirected requests MUST NOT use other methods than * GET and HEAD unless it can be confirmed by the user */ - if (redirect_max == PHP_URL_REDIRECT_MAX + if (!redirected || (Z_STRLEN_PP(tmpzval) == 3 && memcmp("GET", Z_STRVAL_PP(tmpzval), 3) == 0) || (Z_STRLEN_PP(tmpzval) == 4 && memcmp("HEAD",Z_STRVAL_PP(tmpzval), 4) == 0) ) { @@ -749,7 +754,7 @@ CHECK_FOR_CNTRL_CHARS(resource->pass) CHECK_FOR_CNTRL_CHARS(resource->path) } - stream = php_stream_url_wrap_http_ex(wrapper, new_path, mode, options, opened_path, context, --redirect_max, 0 STREAMS_CC TSRMLS_CC); + stream = php_stream_url_wrap_http_ex(wrapper, new_path, mode, options, opened_path, context, --redirect_max, HTTP_WRAPPER_REDIRECTED STREAMS_CC TSRMLS_CC); } else { php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "HTTP request failed! %s", tmp_line); } @@ -803,7 +808,7 @@ php_stream *php_stream_url_wrap_http(php_stream_wrapper *wrapper, char *path, char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC) /* {{{ */ { - return php_stream_url_wrap_http_ex(wrapper, path, mode, options, opened_path, context, PHP_URL_REDIRECT_MAX, 1 STREAMS_CC TSRMLS_CC); + return php_stream_url_wrap_http_ex(wrapper, path, mode, options, opened_path, context, PHP_URL_REDIRECT_MAX, HTTP_WRAPPER_HEADER_INIT STREAMS_CC TSRMLS_CC); } /* }}} */ -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard http_fopen_wrapper.c
lbarnaudMon Jul 28 19:03:57 2008 UTC Modified files: /php-src/ext/standard http_fopen_wrapper.c Log: When automatically redirecting an HTTP request, use the GET method when the original method was not HEAD or GET (fixes #45540) # # The RFC says that in case of 3xx code, "The action required MAY be # carried out [...] *only if the method used in the second request is GET or # HEAD*". # # This may not break anything as actually POST requests replying # with a Location header never worked as the redirecting request was sent using # the POST method, but without Entity-Body (and without Content-Length header, # which caused the server to reply with a "411 Length Required" or to treat # the request as GET). # http://cvs.php.net/viewvc.cgi/php-src/ext/standard/http_fopen_wrapper.c?r1=1.135&r2=1.136&diff_format=u Index: php-src/ext/standard/http_fopen_wrapper.c diff -u php-src/ext/standard/http_fopen_wrapper.c:1.135 php-src/ext/standard/http_fopen_wrapper.c:1.136 --- php-src/ext/standard/http_fopen_wrapper.c:1.135 Fri Jul 25 08:27:10 2008 +++ php-src/ext/standard/http_fopen_wrapper.c Mon Jul 28 19:03:57 2008 @@ -19,7 +19,7 @@ | Sara Golemon <[EMAIL PROTECTED]> | +--+ */ -/* $Id: http_fopen_wrapper.c,v 1.135 2008/07/25 08:27:10 mike Exp $ */ +/* $Id: http_fopen_wrapper.c,v 1.136 2008/07/28 19:03:57 lbarnaud Exp $ */ #include "php.h" #include "php_globals.h" @@ -294,10 +294,17 @@ if (context && php_stream_context_get_option(context, "http", "method", &tmpzval) == SUCCESS) { if (Z_TYPE_PP(tmpzval) == IS_STRING && Z_STRLEN_PP(tmpzval) > 0) { - scratch_len = strlen(path) + 29 + Z_STRLEN_PP(tmpzval); - scratch = emalloc(scratch_len); - strlcpy(scratch, Z_STRVAL_PP(tmpzval), Z_STRLEN_PP(tmpzval) + 1); - strcat(scratch, " "); + /* As per the RFC, automatically redirected requests MUST NOT use other methods than +* GET and HEAD unless it can be confirmed by the user */ + if (redirect_max == PHP_URL_REDIRECT_MAX + || (Z_STRLEN_PP(tmpzval) == 3 && memcmp("GET", Z_STRVAL_PP(tmpzval), 3) == 0) + || (Z_STRLEN_PP(tmpzval) == 4 && memcmp("HEAD",Z_STRVAL_PP(tmpzval), 4) == 0) + ) { + scratch_len = strlen(path) + 29 + Z_STRLEN_PP(tmpzval); + scratch = emalloc(scratch_len); + strlcpy(scratch, Z_STRVAL_PP(tmpzval), Z_STRLEN_PP(tmpzval) + 1); + strcat(scratch, " "); + } } } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard http_fopen_wrapper.c
mikeFri Jul 25 08:27:10 2008 UTC Modified files: /php-src/ext/standard http_fopen_wrapper.c Log: - Changed HTTP stream wrapper to accept any code between and including 200 to 399 as successful. (patch by Noah Fontes) http://cvs.php.net/viewvc.cgi/php-src/ext/standard/http_fopen_wrapper.c?r1=1.134&r2=1.135&diff_format=u Index: php-src/ext/standard/http_fopen_wrapper.c diff -u php-src/ext/standard/http_fopen_wrapper.c:1.134 php-src/ext/standard/http_fopen_wrapper.c:1.135 --- php-src/ext/standard/http_fopen_wrapper.c:1.134 Fri Jul 11 10:24:29 2008 +++ php-src/ext/standard/http_fopen_wrapper.c Fri Jul 25 08:27:10 2008 @@ -19,7 +19,7 @@ | Sara Golemon <[EMAIL PROTECTED]> | +--+ */ -/* $Id: http_fopen_wrapper.c,v 1.134 2008/07/11 10:24:29 tony2001 Exp $ */ +/* $Id: http_fopen_wrapper.c,v 1.135 2008/07/25 08:27:10 mike Exp $ */ #include "php.h" #include "php_globals.h" @@ -572,25 +572,25 @@ (context && php_stream_context_get_option(context, "http", "ignore_errors", &tmpzval) == SUCCESS && zend_is_true(*tmpzval)) ) { reqok = 1; } - switch(response_code) { - case 200: - case 206: /* partial content */ - case 302: - case 303: - case 301: - reqok = 1; - break; - case 403: - php_stream_notify_error(context, PHP_STREAM_NOTIFY_AUTH_RESULT, - tmp_line, response_code); - break; - default: - /* safety net in the event tmp_line == NULL */ - if (!tmp_line_len) { - tmp_line[0] = '\0'; - } - php_stream_notify_error(context, PHP_STREAM_NOTIFY_FAILURE, - tmp_line, response_code); + /* all status codes in the 2xx range are defined by the specification as successful; +* all status codes in the 3xx range are for redirection, and so also should never +* fail */ + if (response_code >= 200 && response_code < 400) { + reqok = 1; + } else { + switch(response_code) { + case 403: + php_stream_notify_error(context, PHP_STREAM_NOTIFY_AUTH_RESULT, + tmp_line, response_code); + break; + default: + /* safety net in the event tmp_line == NULL */ + if (!tmp_line_len) { + tmp_line[0] = '\0'; + } + php_stream_notify_error(context, PHP_STREAM_NOTIFY_FAILURE, + tmp_line, response_code); + } } if (tmp_line[tmp_line_len - 1] == '\n') { --tmp_line_len; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard http_fopen_wrapper.c
iliaa Sun Apr 6 15:21:45 2008 UTC Modified files: /php-src/ext/standard http_fopen_wrapper.c Log: MFB: Fixed bug #44603 (Order issues with Content-Type/Length headers on POST) http://cvs.php.net/viewvc.cgi/php-src/ext/standard/http_fopen_wrapper.c?r1=1.131&r2=1.132&diff_format=u Index: php-src/ext/standard/http_fopen_wrapper.c diff -u php-src/ext/standard/http_fopen_wrapper.c:1.131 php-src/ext/standard/http_fopen_wrapper.c:1.132 --- php-src/ext/standard/http_fopen_wrapper.c:1.131 Mon Dec 31 07:12:15 2007 +++ php-src/ext/standard/http_fopen_wrapper.c Sun Apr 6 15:21:45 2008 @@ -19,7 +19,7 @@ | Sara Golemon <[EMAIL PROTECTED]> | +--+ */ -/* $Id: http_fopen_wrapper.c,v 1.131 2007/12/31 07:12:15 sebastian Exp $ */ +/* $Id: http_fopen_wrapper.c,v 1.132 2008/04/06 15:21:45 iliaa Exp $ */ #include "php.h" #include "php_globals.h" @@ -148,6 +148,7 @@ int protocol_version_len = 3; /* Default: "1.0" */ char *charset = NULL; struct timeval timeout; + char *user_headers = NULL; tmp_line[0] = '\0'; @@ -394,10 +395,8 @@ efree(tmp); tmp = tmp_c; } - - /* Output trimmed headers with \r\n at the end */ - php_stream_write(stream, tmp, strlen(tmp)); - php_stream_write(stream, "\r\n", sizeof("\r\n") - 1); + + user_headers = estrdup(tmp); /* Make lowercase for easy comparison against 'standard' headers */ php_strtolower(tmp, strlen(tmp)); @@ -495,6 +494,27 @@ } } + if (user_headers) { + /* A bit weird, but some servers require that Content-Length be sent prior to Content-Type for POST +* see bug #44603 for details. Since Content-Type maybe part of user's headers we need to do this check first. +*/ + if ( + header_init && + context && + !(have_header & HTTP_HEADER_CONTENT_LENGTH) && + php_stream_context_get_option(context, "http", "content", &tmpzval) == SUCCESS && + Z_TYPE_PP(tmpzval) == IS_STRING && Z_STRLEN_PP(tmpzval) > 0 + ) { + scratch_len = slprintf(scratch, scratch_len, "Content-Length: %d\r\n", Z_STRLEN_PP(tmpzval)); + php_stream_write(stream, scratch, scratch_len); + have_header |= HTTP_HEADER_CONTENT_LENGTH; + } + + php_stream_write(stream, user_headers, strlen(user_headers)); + php_stream_write(stream, "\r\n", sizeof("\r\n")-1); + efree(user_headers); + } + /* Request content, such as for POST requests */ if (header_init && context && php_stream_context_get_option(context, "http", "content", &tmpzval) == SUCCESS && -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard http_fopen_wrapper.c /ext/standard/tests/network http-stream.phpt
derick Thu Nov 29 12:27:49 2007 UTC Added files: /php-src/ext/standard/tests/network http-stream.phpt Modified files: /php-src/ext/standard http_fopen_wrapper.c Log: - Fixed a segfault when reading from an HTTP stream. http://cvs.php.net/viewvc.cgi/php-src/ext/standard/http_fopen_wrapper.c?r1=1.129&r2=1.130&diff_format=u Index: php-src/ext/standard/http_fopen_wrapper.c diff -u php-src/ext/standard/http_fopen_wrapper.c:1.129 php-src/ext/standard/http_fopen_wrapper.c:1.130 --- php-src/ext/standard/http_fopen_wrapper.c:1.129 Mon Nov 5 00:47:21 2007 +++ php-src/ext/standard/http_fopen_wrapper.c Thu Nov 29 12:27:49 2007 @@ -19,7 +19,7 @@ | Sara Golemon <[EMAIL PROTECTED]> | +--+ */ -/* $Id: http_fopen_wrapper.c,v 1.129 2007/11/05 00:47:21 pollita Exp $ */ +/* $Id: http_fopen_wrapper.c,v 1.130 2007/11/29 12:27:49 derick Exp $ */ #include "php.h" #include "php_globals.h" @@ -545,7 +545,7 @@ } /* when we request only the header, don't fail even on error codes */ if ((options & STREAM_ONLY_GET_HEADERS) || - (php_stream_context_get_option(context, "http", "ignore_errors", &tmpzval) == SUCCESS && zend_is_true(*tmpzval)) ) { + (context && php_stream_context_get_option(context, "http", "ignore_errors", &tmpzval) == SUCCESS && zend_is_true(*tmpzval)) ) { reqok = 1; } switch(response_code) { http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/network/http-stream.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/network/http-stream.phpt +++ php-src/ext/standard/tests/network/http-stream.phpt --TEST-- http-stream test --FILE-- load("http://php.net/news.rss";); echo "ALIVE\n"; ?> --EXPECTF-- ALIVE -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard http_fopen_wrapper.c
pollita Mon Nov 5 00:47:21 2007 UTC Modified files: /php-src/ext/standard http_fopen_wrapper.c Log: Allow http fopen wrapper to fetch content on 'error' condition (David Zulke) http://cvs.php.net/viewvc.cgi/php-src/ext/standard/http_fopen_wrapper.c?r1=1.128&r2=1.129&diff_format=u Index: php-src/ext/standard/http_fopen_wrapper.c diff -u php-src/ext/standard/http_fopen_wrapper.c:1.128 php-src/ext/standard/http_fopen_wrapper.c:1.129 --- php-src/ext/standard/http_fopen_wrapper.c:1.128 Sun Sep 30 05:43:28 2007 +++ php-src/ext/standard/http_fopen_wrapper.c Mon Nov 5 00:47:21 2007 @@ -19,7 +19,7 @@ | Sara Golemon <[EMAIL PROTECTED]> | +--+ */ -/* $Id: http_fopen_wrapper.c,v 1.128 2007/09/30 05:43:28 jani Exp $ */ +/* $Id: http_fopen_wrapper.c,v 1.129 2007/11/05 00:47:21 pollita Exp $ */ #include "php.h" #include "php_globals.h" @@ -544,7 +544,8 @@ response_code = 0; } /* when we request only the header, don't fail even on error codes */ - if (options & STREAM_ONLY_GET_HEADERS) { + if ((options & STREAM_ONLY_GET_HEADERS) || + (php_stream_context_get_option(context, "http", "ignore_errors", &tmpzval) == SUCCESS && zend_is_true(*tmpzval)) ) { reqok = 1; } switch(response_code) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard http_fopen_wrapper.c
bjori Mon Apr 23 16:32:37 2007 UTC Modified files: /php-src/ext/standard http_fopen_wrapper.c Log: Plug leak http://cvs.php.net/viewvc.cgi/php-src/ext/standard/http_fopen_wrapper.c?r1=1.124&r2=1.125&diff_format=u Index: php-src/ext/standard/http_fopen_wrapper.c diff -u php-src/ext/standard/http_fopen_wrapper.c:1.124 php-src/ext/standard/http_fopen_wrapper.c:1.125 --- php-src/ext/standard/http_fopen_wrapper.c:1.124 Sun Jan 14 14:37:16 2007 +++ php-src/ext/standard/http_fopen_wrapper.c Mon Apr 23 16:32:37 2007 @@ -19,7 +19,7 @@ | Sara Golemon <[EMAIL PROTECTED]> | +--+ */ -/* $Id: http_fopen_wrapper.c,v 1.124 2007/01/14 14:37:16 bjori Exp $ */ +/* $Id: http_fopen_wrapper.c,v 1.125 2007/04/23 16:32:37 bjori Exp $ */ #include "php.h" #include "php_globals.h" @@ -179,6 +179,7 @@ if (strpbrk(mode, "awx+")) { php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "HTTP wrapper does not support writeable connections."); + php_url_free(resource); return NULL; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard http_fopen_wrapper.c
bjori Sun Jan 14 14:37:17 2007 UTC Modified files: /php-src/ext/standard http_fopen_wrapper.c Log: MFB: Fix typo in error message http://cvs.php.net/viewvc.cgi/php-src/ext/standard/http_fopen_wrapper.c?r1=1.123&r2=1.124&diff_format=u Index: php-src/ext/standard/http_fopen_wrapper.c diff -u php-src/ext/standard/http_fopen_wrapper.c:1.123 php-src/ext/standard/http_fopen_wrapper.c:1.124 --- php-src/ext/standard/http_fopen_wrapper.c:1.123 Mon Jan 1 09:29:32 2007 +++ php-src/ext/standard/http_fopen_wrapper.c Sun Jan 14 14:37:16 2007 @@ -19,7 +19,7 @@ | Sara Golemon <[EMAIL PROTECTED]> | +--+ */ -/* $Id: http_fopen_wrapper.c,v 1.123 2007/01/01 09:29:32 sebastian Exp $ */ +/* $Id: http_fopen_wrapper.c,v 1.124 2007/01/14 14:37:16 bjori Exp $ */ #include "php.h" #include "php_globals.h" @@ -222,7 +222,7 @@ smart_str_append_unsigned(&header, resource->port); smart_str_appendl(&header, " HTTP/1.0\r\n\r\n", sizeof(" HTTP/1.0\r\n\r\n")-1); if (php_stream_write(stream, header.c, header.len) != header.len) { - php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "Cannot conect to HTTPS server through proxy"); + php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "Cannot connect to HTTPS server through proxy"); php_stream_close(stream); stream = NULL; } @@ -245,7 +245,7 @@ if (stream) { if (php_stream_xport_crypto_setup(stream, STREAM_CRYPTO_METHOD_SSLv23_CLIENT, NULL TSRMLS_CC) < 0 || php_stream_xport_crypto_enable(stream, 1 TSRMLS_CC) < 0) { - php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "Cannot conect to HTTPS server through proxy"); + php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "Cannot connect to HTTPS server through proxy"); php_stream_close(stream); stream = NULL; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard http_fopen_wrapper.c
tony2001Tue Dec 5 18:42:22 2006 UTC Modified files: /php-src/ext/standard http_fopen_wrapper.c Log: nuke redundant zval_ptr_dtor() call and fix memory corruption/segfault http://cvs.php.net/viewvc.cgi/php-src/ext/standard/http_fopen_wrapper.c?r1=1.120&r2=1.121&diff_format=u Index: php-src/ext/standard/http_fopen_wrapper.c diff -u php-src/ext/standard/http_fopen_wrapper.c:1.120 php-src/ext/standard/http_fopen_wrapper.c:1.121 --- php-src/ext/standard/http_fopen_wrapper.c:1.120 Sun Oct 8 13:34:23 2006 +++ php-src/ext/standard/http_fopen_wrapper.c Tue Dec 5 18:42:22 2006 @@ -19,7 +19,7 @@ | Sara Golemon <[EMAIL PROTECTED]> | +--+ */ -/* $Id: http_fopen_wrapper.c,v 1.120 2006/10/08 13:34:23 bjori Exp $ */ +/* $Id: http_fopen_wrapper.c,v 1.121 2006/12/05 18:42:22 tony2001 Exp $ */ #include "php.h" #include "php_globals.h" @@ -289,7 +289,6 @@ SEPARATE_ZVAL(tmpzval); convert_to_double_ex(tmpzval); protocol_version_len = spprintf(&protocol_version, 0, "%.1f", Z_DVAL_PP(tmpzval)); - zval_ptr_dtor(tmpzval); } if (!scratch) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard http_fopen_wrapper.c /main/streams memory.c
bjori Thu Jun 29 14:42:30 2006 UTC Modified files: /php-src/ext/standard http_fopen_wrapper.c /php-src/main/streams memory.c Log: url->URL http://cvs.php.net/viewvc.cgi/php-src/ext/standard/http_fopen_wrapper.c?r1=1.116&r2=1.117&diff_format=u Index: php-src/ext/standard/http_fopen_wrapper.c diff -u php-src/ext/standard/http_fopen_wrapper.c:1.116 php-src/ext/standard/http_fopen_wrapper.c:1.117 --- php-src/ext/standard/http_fopen_wrapper.c:1.116 Fri Apr 28 19:03:57 2006 +++ php-src/ext/standard/http_fopen_wrapper.c Thu Jun 29 14:42:30 2006 @@ -19,7 +19,7 @@ | Sara Golemon <[EMAIL PROTECTED]> | +--+ */ -/* $Id: http_fopen_wrapper.c,v 1.116 2006/04/28 19:03:57 fmk Exp $ */ +/* $Id: http_fopen_wrapper.c,v 1.117 2006/06/29 14:42:30 bjori Exp $ */ #include "php.h" #include "php_globals.h" @@ -671,7 +671,7 @@ php_url_free(resource); /* check for invalid redirection URLs */ if ((resource = php_url_parse(new_path)) == NULL) { - php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "Invalid redirect url! %s", new_path); + php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "Invalid redirect URL! %s", new_path); goto out; } @@ -683,7 +683,7 @@ s = (unsigned char*)val; e = s + l; \ while (s < e) { \ if (iscntrl(*s)) { \ - php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "Invalid redirect url! %s", new_path); \ + php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "Invalid redirect URL! %s", new_path); \ goto out; \ } \ s++;\ http://cvs.php.net/viewvc.cgi/php-src/main/streams/memory.c?r1=1.23&r2=1.24&diff_format=u Index: php-src/main/streams/memory.c diff -u php-src/main/streams/memory.c:1.23 php-src/main/streams/memory.c:1.24 --- php-src/main/streams/memory.c:1.23 Tue Jun 6 14:08:47 2006 +++ php-src/main/streams/memory.c Thu Jun 29 14:42:30 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: memory.c,v 1.23 2006/06/06 14:08:47 tony2001 Exp $ */ +/* $Id: memory.c,v 1.24 2006/06/29 14:42:30 bjori Exp $ */ #define _GNU_SOURCE #include "php.h" @@ -584,7 +584,7 @@ } if ((comma = memchr(path, ',', dlen)) == NULL) { - php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "rfc2397: no comma in url"); + php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "rfc2397: no comma in URL"); return NULL; } @@ -645,7 +645,7 @@ } if (mlen) { zval_ptr_dtor(&meta); - php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "rfc2397: illegal url"); + php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "rfc2397: illegal URL"); return NULL; } } else { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard http_fopen_wrapper.c
iliaa Sun Apr 16 17:41:26 2006 UTC Modified files: /php-src/ext/standard http_fopen_wrapper.c Log: MFB51: fixed typo http://cvs.php.net/viewcvs.cgi/php-src/ext/standard/http_fopen_wrapper.c?r1=1.114&r2=1.115&diff_format=u Index: php-src/ext/standard/http_fopen_wrapper.c diff -u php-src/ext/standard/http_fopen_wrapper.c:1.114 php-src/ext/standard/http_fopen_wrapper.c:1.115 --- php-src/ext/standard/http_fopen_wrapper.c:1.114 Sun Apr 16 16:55:25 2006 +++ php-src/ext/standard/http_fopen_wrapper.c Sun Apr 16 17:41:26 2006 @@ -19,7 +19,7 @@ | Sara Golemon <[EMAIL PROTECTED]> | +--+ */ -/* $Id: http_fopen_wrapper.c,v 1.114 2006/04/16 16:55:25 iliaa Exp $ */ +/* $Id: http_fopen_wrapper.c,v 1.115 2006/04/16 17:41:26 iliaa Exp $ */ #include "php.h" #include "php_globals.h" @@ -691,7 +691,7 @@ } \ } \ /* check for control characters in login, password & path */ - if (strncasecmp(newpath, "http://";, sizeof("http://";) - 1) || strncasecmp(newpath, "https://";, sizeof("https://";) - 1) { + if (strncasecmp(new_path, "http://";, sizeof("http://";) - 1) || strncasecmp(new_path, "https://";, sizeof("https://";) - 1)) { CHECK_FOR_CNTRL_CHARS(resource->user) CHECK_FOR_CNTRL_CHARS(resource->pass) CHECK_FOR_CNTRL_CHARS(resource->path) -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard http_fopen_wrapper.c
iliaa Sun Apr 16 16:55:25 2006 UTC Modified files: /php-src/ext/standard http_fopen_wrapper.c Log: MFB51: Fixed bug #37045 (Fixed check for special chars for http redirects). http://cvs.php.net/viewcvs.cgi/php-src/ext/standard/http_fopen_wrapper.c?r1=1.113&r2=1.114&diff_format=u Index: php-src/ext/standard/http_fopen_wrapper.c diff -u php-src/ext/standard/http_fopen_wrapper.c:1.113 php-src/ext/standard/http_fopen_wrapper.c:1.114 --- php-src/ext/standard/http_fopen_wrapper.c:1.113 Wed Apr 12 22:40:56 2006 +++ php-src/ext/standard/http_fopen_wrapper.c Sun Apr 16 16:55:25 2006 @@ -19,7 +19,7 @@ | Sara Golemon <[EMAIL PROTECTED]> | +--+ */ -/* $Id: http_fopen_wrapper.c,v 1.113 2006/04/12 22:40:56 pollita Exp $ */ +/* $Id: http_fopen_wrapper.c,v 1.114 2006/04/16 16:55:25 iliaa Exp $ */ #include "php.h" #include "php_globals.h" @@ -691,10 +691,11 @@ } \ } \ /* check for control characters in login, password & path */ - CHECK_FOR_CNTRL_CHARS(resource->user) - CHECK_FOR_CNTRL_CHARS(resource->pass) - CHECK_FOR_CNTRL_CHARS(resource->path) - + if (strncasecmp(newpath, "http://";, sizeof("http://";) - 1) || strncasecmp(newpath, "https://";, sizeof("https://";) - 1) { + CHECK_FOR_CNTRL_CHARS(resource->user) + CHECK_FOR_CNTRL_CHARS(resource->pass) + CHECK_FOR_CNTRL_CHARS(resource->path) + } stream = php_stream_url_wrap_http_ex(wrapper, new_path, mode, options, opened_path, context, --redirect_max, 0 STREAMS_CC TSRMLS_CC); } else { php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "HTTP request failed! %s", tmp_line); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard http_fopen_wrapper.c /main/streams filter.c php_stream_filter_api.h streams.c
pollita Wed Apr 12 22:40:56 2006 UTC Modified files: /php-src/ext/standard http_fopen_wrapper.c /php-src/main/streams filter.c php_stream_filter_api.h streams.c Log: Allow http:// wrapper to automatically apply correct unicode.from.* filter based on content-type header http://cvs.php.net/viewcvs.cgi/php-src/ext/standard/http_fopen_wrapper.c?r1=1.112&r2=1.113&diff_format=u Index: php-src/ext/standard/http_fopen_wrapper.c diff -u php-src/ext/standard/http_fopen_wrapper.c:1.112 php-src/ext/standard/http_fopen_wrapper.c:1.113 --- php-src/ext/standard/http_fopen_wrapper.c:1.112 Sun Mar 26 17:12:26 2006 +++ php-src/ext/standard/http_fopen_wrapper.c Wed Apr 12 22:40:56 2006 @@ -19,7 +19,7 @@ | Sara Golemon <[EMAIL PROTECTED]> | +--+ */ -/* $Id: http_fopen_wrapper.c,v 1.112 2006/03/26 17:12:26 iliaa Exp $ */ +/* $Id: http_fopen_wrapper.c,v 1.113 2006/04/12 22:40:56 pollita Exp $ */ #include "php.h" #include "php_globals.h" @@ -81,6 +81,47 @@ #define HTTP_HEADER_CONTENT_LENGTH 16 #define HTTP_HEADER_TYPE 32 +static inline char *php_http_detect_charset(char *http_header_line) +{ + char *s; + + /* Note: This is a fairly remedial parser which could be easily confused by invalid data + The worst case scenario from such confusion should only result in the unicode filter not + being applied. While unfortunate, it's more an issue of the server sending a bad header */ + for (s = strchr(http_header_line, ';'); s; s = strchr(s + 1, ';')) { + char *p = s; + + while (*(++p) == ' '); + if (strncmp(p, "charset", sizeof("charset") - 1) != 0) { + continue; + } + p += sizeof("charset") - 1; + + while (*p == ' ') p++; + if (*p != '=') { + continue; + } + + while (*(++p) == ' '); + if (*p == '"') { + s = p + 1; + if (!(p = strchr(s, '"'))) { + /* Bad things, unmatched quote */ + return NULL; + } + return estrndup(s, p - s); + break; + } + + /* Unquoted value */ + s = p; + while (*p && *p != ' ' && *p != ';') p++; + return estrndup(s, p - s); + } + + return NULL; +} + php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper, char *path, char *mode, int options, char **opened_path, php_stream_context *context, int redirect_max, int header_init STREAMS_DC TSRMLS_DC) { php_stream *stream = NULL; @@ -104,6 +145,7 @@ int transport_len, have_header = 0, request_fulluri = 0; char *protocol_version = NULL; int protocol_version_len = 3; /* Default: "1.0" */ + char *charset = NULL; tmp_line[0] = '\0'; @@ -543,6 +585,11 @@ if (!strncasecmp(http_header_line, "Location: ", 10)) { strlcpy(location, http_header_line + 10, sizeof(location)); } else if (!strncasecmp(http_header_line, "Content-Type: ", 14)) { + + if (UG(unicode) && strchr(mode, 't')) { + charset = php_http_detect_charset(http_header_line + sizeof("Content-type: ")); + } + php_stream_notify_info(context, PHP_STREAM_NOTIFY_MIME_TYPE_IS, http_header_line + 14, 0); } else if (!strncasecmp(http_header_line, "Content-Length: ", 16)) { file_size = atoi(http_header_line + 16); @@ -572,6 +619,11 @@ php_stream_close(stream); stream = NULL; + if (charset) { + efree(charset); + charset = NULL; + } + if (location[0] != '\0'){ char new_path[HTTP_HEADER_BLOCK_SIZE]; @@ -684,6 +736,13 @@ } + if (charset) { + if (stream && UG(unicode) && strchr(mode, 't')) { + php_stream_encoding_apply(stream, 0, charset, UG(to_error_mode), NULL); + } + efree(charset); + } + return stream; } http://cvs.php.net/viewcvs.cgi/php-src/main/streams/filter.c?r1=1.28&r2=1.29&diff_format=u Index: php-src/main/streams/filter.c diff -u php-src/main/streams/filter.c:1.28 php-src/main/streams/filter.c:1.29 --- php-src/main/streams/filter.c:1.28 Wed Mar 29 01:20:43 2006 +++ php-src/main/streams/filter.c Wed Apr 12 22:40:56 2006 @@ -16,7 +16,7 @@ +---
[PHP-CVS] cvs: php-src /ext/standard http_fopen_wrapper.c
iliaa Sun Mar 26 17:12:26 2006 UTC Modified files: /php-src/ext/standard http_fopen_wrapper.c Log: MFB51: Fixed bug #36857 (Added support for partial content fetching to the HTTP streams wrapper). http://cvs.php.net/viewcvs.cgi/php-src/ext/standard/http_fopen_wrapper.c?r1=1.111&r2=1.112&diff_format=u Index: php-src/ext/standard/http_fopen_wrapper.c diff -u php-src/ext/standard/http_fopen_wrapper.c:1.111 php-src/ext/standard/http_fopen_wrapper.c:1.112 --- php-src/ext/standard/http_fopen_wrapper.c:1.111 Thu Mar 2 13:12:45 2006 +++ php-src/ext/standard/http_fopen_wrapper.c Sun Mar 26 17:12:26 2006 @@ -19,7 +19,7 @@ | Sara Golemon <[EMAIL PROTECTED]> | +--+ */ -/* $Id: http_fopen_wrapper.c,v 1.111 2006/03/02 13:12:45 dmitry Exp $ */ +/* $Id: http_fopen_wrapper.c,v 1.112 2006/03/26 17:12:26 iliaa Exp $ */ #include "php.h" #include "php_globals.h" @@ -493,6 +493,7 @@ } switch(response_code) { case 200: + case 206: /* partial content */ case 302: case 303: case 301: -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard http_fopen_wrapper.c
iliaa Fri Jan 20 01:40:48 2006 UTC Modified files: /php-src/ext/standard http_fopen_wrapper.c Log: MFB51: Allow get_headers() to return header information even for non-200 responses. http://cvs.php.net/viewcvs.cgi/php-src/ext/standard/http_fopen_wrapper.c?r1=1.108&r2=1.109&diff_format=u Index: php-src/ext/standard/http_fopen_wrapper.c diff -u php-src/ext/standard/http_fopen_wrapper.c:1.108 php-src/ext/standard/http_fopen_wrapper.c:1.109 --- php-src/ext/standard/http_fopen_wrapper.c:1.108 Sun Jan 1 13:09:55 2006 +++ php-src/ext/standard/http_fopen_wrapper.c Fri Jan 20 01:40:48 2006 @@ -19,7 +19,7 @@ | Sara Golemon <[EMAIL PROTECTED]> | +--+ */ -/* $Id: http_fopen_wrapper.c,v 1.108 2006/01/01 13:09:55 sniper Exp $ */ +/* $Id: http_fopen_wrapper.c,v 1.109 2006/01/20 01:40:48 iliaa Exp $ */ #include "php.h" #include "php_globals.h" @@ -487,6 +487,10 @@ } else { response_code = 0; } + /* when we request only the header, don't fail even on error codes */ + if (options & STREAM_ONLY_GET_HEADERS) { + reqok = 1; + } switch(response_code) { case 200: case 302: -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard http_fopen_wrapper.c
iliaa Mon Dec 12 05:04:43 2005 EDT Modified files: /php-src/ext/standard http_fopen_wrapper.c Log: MFB51: Fixed bug #35629 (crash in http:// wrapper on multiple redirects). http://cvs.php.net/viewcvs.cgi/php-src/ext/standard/http_fopen_wrapper.c?r1=1.106&r2=1.107&diff_format=u Index: php-src/ext/standard/http_fopen_wrapper.c diff -u php-src/ext/standard/http_fopen_wrapper.c:1.106 php-src/ext/standard/http_fopen_wrapper.c:1.107 --- php-src/ext/standard/http_fopen_wrapper.c:1.106 Fri Dec 9 18:53:54 2005 +++ php-src/ext/standard/http_fopen_wrapper.c Mon Dec 12 05:04:43 2005 @@ -19,7 +19,7 @@ | Sara Golemon <[EMAIL PROTECTED]> | +--+ */ -/* $Id: http_fopen_wrapper.c,v 1.106 2005/12/09 18:53:54 tony2001 Exp $ */ +/* $Id: http_fopen_wrapper.c,v 1.107 2005/12/12 05:04:43 iliaa Exp $ */ #include "php.h" #include "php_globals.h" @@ -94,7 +94,7 @@ int scratch_len = 0; int body = 0; char location[HTTP_HEADER_BLOCK_SIZE]; - zval **response_header = NULL; + zval *response_header = NULL; int reqok = 0; char *http_header_line = NULL; char tmp_line[128]; @@ -461,18 +461,17 @@ location[0] = '\0'; - if (!header_init) { - MAKE_STD_ZVAL(stream->wrapperdata); - array_init(stream->wrapperdata); - response_header = &stream->wrapperdata; - } else { + if (header_init) { zval *tmp; MAKE_STD_ZVAL(tmp); array_init(tmp); ZEND_SET_SYMBOL(EG(active_symbol_table), "http_response_header", tmp); - - zend_hash_find(EG(active_symbol_table), - "http_response_header", sizeof("http_response_header"), (void **) &response_header); + } + + { + zval **rh; + zend_hash_find(EG(active_symbol_table), "http_response_header", sizeof("http_response_header"), (void **) &rh); + response_header = *rh; } if (!php_stream_eof(stream)) { @@ -515,7 +514,7 @@ } MAKE_STD_ZVAL(http_response); ZVAL_STRINGL(http_response, tmp_line, tmp_line_len, 1); - zend_hash_next_index_insert(Z_ARRVAL_PP(response_header), &http_response, sizeof(zval *), NULL); + zend_hash_next_index_insert(Z_ARRVAL_P(response_header), &http_response, sizeof(zval *), NULL); } } else { php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "HTTP request failed, unexpected end of socket!"); @@ -554,7 +553,7 @@ ZVAL_STRINGL(http_header, http_header_line, http_header_line_length, 1); - zend_hash_next_index_insert(Z_ARRVAL_PP(response_header), &http_header, sizeof(zval *), NULL); + zend_hash_next_index_insert(Z_ARRVAL_P(response_header), &http_header, sizeof(zval *), NULL); } } else { break; @@ -570,7 +569,6 @@ if (location[0] != '\0'){ - zval *entry, **entryp; char new_path[HTTP_HEADER_BLOCK_SIZE]; char loc_path[HTTP_HEADER_BLOCK_SIZE]; @@ -641,20 +639,6 @@ CHECK_FOR_CNTRL_CHARS(resource->path) stream = php_stream_url_wrap_http_ex(wrapper, new_path, mode, options, opened_path, context, --redirect_max, 0 STREAMS_CC TSRMLS_CC); - if (stream && stream->wrapperdata && *response_header != stream->wrapperdata) { - entryp = &entry; - MAKE_STD_ZVAL(entry); - ZVAL_EMPTY_STRING(entry); - zend_hash_next_index_insert(Z_ARRVAL_PP(response_header), entryp, sizeof(zval *), NULL); - zend_hash_internal_pointer_reset(Z_ARRVAL_P(stream->wrapperdata)); - while (zend_hash_get_current_data(Z_ARRVAL_P(stream->wrapperdata), (void **)&entryp) == SUCCESS) { - zval_add_ref(entryp); - zend_hash_next_index_insert(Z_ARRVAL_PP(response_header), entryp, sizeof(zval *), NULL); - zend_hash_move_forward(Z_ARRVAL_P(stream->wrapperdata)); - } - zval_dtor(stream->wrapperdata); - FREE_ZVAL(stream->wrapperdata); - } } else { php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "H
[PHP-CVS] cvs: php-src /ext/standard http_fopen_wrapper.c
tony2001Fri Dec 9 13:53:54 2005 EDT Modified files: /php-src/ext/standard http_fopen_wrapper.c Log: MF51: fix wrong macro usage http://cvs.php.net/diff.php/php-src/ext/standard/http_fopen_wrapper.c?r1=1.105&r2=1.106&ty=u Index: php-src/ext/standard/http_fopen_wrapper.c diff -u php-src/ext/standard/http_fopen_wrapper.c:1.105 php-src/ext/standard/http_fopen_wrapper.c:1.106 --- php-src/ext/standard/http_fopen_wrapper.c:1.105 Wed Dec 7 21:53:34 2005 +++ php-src/ext/standard/http_fopen_wrapper.c Fri Dec 9 13:53:54 2005 @@ -19,7 +19,7 @@ | Sara Golemon <[EMAIL PROTECTED]> | +--+ */ -/* $Id: http_fopen_wrapper.c,v 1.105 2005/12/08 02:53:34 iliaa Exp $ */ +/* $Id: http_fopen_wrapper.c,v 1.106 2005/12/09 18:53:54 tony2001 Exp $ */ #include "php.h" #include "php_globals.h" @@ -479,7 +479,7 @@ size_t tmp_line_len; /* get response header */ - if (_php_stream_get_line(stream, tmp_line, sizeof(tmp_line) - 1, &tmp_line_len TSRMLS_CC) != NULL) { + if (php_stream_get_line(stream, tmp_line, sizeof(tmp_line) - 1, &tmp_line_len) != NULL) { zval *http_response; int response_code; @@ -528,7 +528,7 @@ while (!body && !php_stream_eof(stream)) { size_t http_header_line_length; - if (php_stream_get_line(stream, http_header_line, HTTP_HEADER_BLOCK_SIZE, &http_header_line_length TSRMLS_CC) && *http_header_line != '\n' && *http_header_line != '\r') { + if (php_stream_get_line(stream, http_header_line, HTTP_HEADER_BLOCK_SIZE, &http_header_line_length) && *http_header_line != '\n' && *http_header_line != '\r') { char *e = http_header_line + http_header_line_length - 1; while (*e == '\n' || *e == '\r') { e--; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard http_fopen_wrapper.c
iliaa Wed Dec 7 21:53:34 2005 EDT Modified files: /php-src/ext/standard http_fopen_wrapper.c Log: MFB51: Fixed bug #34359 (Possible crash inside fopen http wrapper). http://cvs.php.net/diff.php/php-src/ext/standard/http_fopen_wrapper.c?r1=1.104&r2=1.105&ty=u Index: php-src/ext/standard/http_fopen_wrapper.c diff -u php-src/ext/standard/http_fopen_wrapper.c:1.104 php-src/ext/standard/http_fopen_wrapper.c:1.105 --- php-src/ext/standard/http_fopen_wrapper.c:1.104 Tue Dec 6 14:13:27 2005 +++ php-src/ext/standard/http_fopen_wrapper.c Wed Dec 7 21:53:34 2005 @@ -19,7 +19,7 @@ | Sara Golemon <[EMAIL PROTECTED]> | +--+ */ -/* $Id: http_fopen_wrapper.c,v 1.104 2005/12/06 19:13:27 pollita Exp $ */ +/* $Id: http_fopen_wrapper.c,v 1.105 2005/12/08 02:53:34 iliaa Exp $ */ #include "php.h" #include "php_globals.h" @@ -526,28 +526,16 @@ http_header_line = emalloc(HTTP_HEADER_BLOCK_SIZE); - while (!body && !php_stream_eof(stream)){ - - if (php_stream_gets(stream, http_header_line, HTTP_HEADER_BLOCK_SIZE-1) != NULL){ - char *p; - int found_eol = 0; - int http_header_line_length; - - http_header_line[HTTP_HEADER_BLOCK_SIZE-1] = '\0'; - - p = http_header_line; - while(*p) { - while(*p == '\n' || *p == '\r') { - *p = '\0'; - p--; - found_eol = 1; - } - if (found_eol) - break; - p++; + while (!body && !php_stream_eof(stream)) { + size_t http_header_line_length; + if (php_stream_get_line(stream, http_header_line, HTTP_HEADER_BLOCK_SIZE, &http_header_line_length TSRMLS_CC) && *http_header_line != '\n' && *http_header_line != '\r') { + char *e = http_header_line + http_header_line_length - 1; + while (*e == '\n' || *e == '\r') { + e--; } - http_header_line_length = p-http_header_line+1; - + http_header_line_length = e - http_header_line + 1; + http_header_line[http_header_line_length] = '\0'; + if (!strncasecmp(http_header_line, "Location: ", 10)) { strlcpy(location, http_header_line + 10, sizeof(location)); } else if (!strncasecmp(http_header_line, "Content-Type: ", 14)) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard http_fopen_wrapper.c
pollita Tue Dec 6 14:13:30 2005 EDT Modified files: /php-src/ext/standard http_fopen_wrapper.c Log: Block potential segfault. Context option type not checked for "user_agent","header", and "content" http://cvs.php.net/diff.php/php-src/ext/standard/http_fopen_wrapper.c?r1=1.103&r2=1.104&ty=u Index: php-src/ext/standard/http_fopen_wrapper.c diff -u php-src/ext/standard/http_fopen_wrapper.c:1.103 php-src/ext/standard/http_fopen_wrapper.c:1.104 --- php-src/ext/standard/http_fopen_wrapper.c:1.103 Mon Nov 14 23:24:17 2005 +++ php-src/ext/standard/http_fopen_wrapper.c Tue Dec 6 14:13:27 2005 @@ -19,7 +19,7 @@ | Sara Golemon <[EMAIL PROTECTED]> | +--+ */ -/* $Id: http_fopen_wrapper.c,v 1.103 2005/11/15 04:24:17 iliaa Exp $ */ +/* $Id: http_fopen_wrapper.c,v 1.104 2005/12/06 19:13:27 pollita Exp $ */ #include "php.h" #include "php_globals.h" @@ -305,7 +305,7 @@ if (context && php_stream_context_get_option(context, "http", "header", &tmpzval) == SUCCESS && - Z_STRLEN_PP(tmpzval)) { + Z_TYPE_PP(tmpzval) == IS_STRING && Z_STRLEN_PP(tmpzval)) { /* Remove newlines and spaces from start and end, php_trim will estrndup() */ tmp = php_trim(Z_STRVAL_PP(tmpzval), Z_STRLEN_PP(tmpzval), NULL, 0, IS_STRING, NULL, 3 TSRMLS_CC); @@ -409,7 +409,8 @@ } if (context && - php_stream_context_get_option(context, "http", "user_agent", &ua_zval) == SUCCESS) { + php_stream_context_get_option(context, "http", "user_agent", &ua_zval) == SUCCESS && + Z_TYPE_PP(ua_zval) == IS_STRING) { ua_str = Z_STRVAL_PP(ua_zval); } else if (FG(user_agent)) { ua_str = FG(user_agent); @@ -441,7 +442,7 @@ /* Request content, such as for POST requests */ if (header_init && context && php_stream_context_get_option(context, "http", "content", &tmpzval) == SUCCESS && - Z_STRLEN_PP(tmpzval) > 0) { + Z_TYPE_PP(tmpzval) == IS_STRING && Z_STRLEN_PP(tmpzval) > 0) { if (!(have_header & HTTP_HEADER_CONTENT_LENGTH)) { scratch_len = snprintf(scratch, scratch_len, "Content-Length: %d\r\n", Z_STRLEN_PP(tmpzval)); php_stream_write(stream, scratch, scratch_len); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard http_fopen_wrapper.c
iliaa Mon Nov 14 23:24:29 2005 EDT Modified files: /php-src/ext/standard http_fopen_wrapper.c Log: Fixed possible crash in http:// wrapper. http://cvs.php.net/diff.php/php-src/ext/standard/http_fopen_wrapper.c?r1=1.102&r2=1.103&ty=u Index: php-src/ext/standard/http_fopen_wrapper.c diff -u php-src/ext/standard/http_fopen_wrapper.c:1.102 php-src/ext/standard/http_fopen_wrapper.c:1.103 --- php-src/ext/standard/http_fopen_wrapper.c:1.102 Wed Sep 21 11:54:42 2005 +++ php-src/ext/standard/http_fopen_wrapper.c Mon Nov 14 23:24:17 2005 @@ -19,7 +19,7 @@ | Sara Golemon <[EMAIL PROTECTED]> | +--+ */ -/* $Id: http_fopen_wrapper.c,v 1.102 2005/09/21 15:54:42 dmitry Exp $ */ +/* $Id: http_fopen_wrapper.c,v 1.103 2005/11/15 04:24:17 iliaa Exp $ */ #include "php.h" #include "php_globals.h" @@ -460,12 +460,11 @@ location[0] = '\0'; - if (!header_init && FAILURE == zend_hash_find(EG(active_symbol_table), - "http_response_header", sizeof("http_response_header"), (void **) &response_header)) { - header_init = 1; - } - - if (header_init) { + if (!header_init) { + MAKE_STD_ZVAL(stream->wrapperdata); + array_init(stream->wrapperdata); + response_header = &stream->wrapperdata; + } else { zval *tmp; MAKE_STD_ZVAL(tmp); array_init(tmp); @@ -475,7 +474,6 @@ "http_response_header", sizeof("http_response_header"), (void **) &response_header); } - if (!php_stream_eof(stream)) { size_t tmp_line_len; /* get response header */ @@ -484,9 +482,6 @@ zval *http_response; int response_code; - MAKE_STD_ZVAL(http_response); - ZVAL_NULL(http_response); - if (tmp_line_len > 9) { response_code = atoi(tmp_line + 9); } else { @@ -511,18 +506,14 @@ php_stream_notify_error(context, PHP_STREAM_NOTIFY_FAILURE, tmp_line, response_code); } - - Z_STRLEN_P(http_response) = tmp_line_len; - Z_STRVAL_P(http_response) = estrndup(tmp_line, Z_STRLEN_P(http_response)); - if (Z_STRVAL_P(http_response)[Z_STRLEN_P(http_response)-1]=='\n') { - Z_STRVAL_P(http_response)[Z_STRLEN_P(http_response)-1]=0; - Z_STRLEN_P(http_response)--; - if (Z_STRVAL_P(http_response)[Z_STRLEN_P(http_response)-1]=='\r') { - Z_STRVAL_P(http_response)[Z_STRLEN_P(http_response)-1]=0; - Z_STRLEN_P(http_response)--; + if (tmp_line[tmp_line_len - 1] == '\n') { + --tmp_line_len; + if (tmp_line[tmp_line_len - 1] == '\r') { + --tmp_line_len; } } - Z_TYPE_P(http_response) = IS_STRING; + MAKE_STD_ZVAL(http_response); + ZVAL_STRINGL(http_response, tmp_line, tmp_line_len, 1); zend_hash_next_index_insert(Z_ARRVAL_PP(response_header), &http_response, sizeof(zval *), NULL); } } else { @@ -661,7 +652,7 @@ CHECK_FOR_CNTRL_CHARS(resource->path) stream = php_stream_url_wrap_http_ex(wrapper, new_path, mode, options, opened_path, context, --redirect_max, 0 STREAMS_CC TSRMLS_CC); - if (stream && stream->wrapperdata) { + if (stream && stream->wrapperdata && *response_header != stream->wrapperdata) { entryp = &entry; MAKE_STD_ZVAL(entry); ZVAL_EMPTY_STRING(entry); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard http_fopen_wrapper.c
dmitry Wed Sep 21 11:54:43 2005 EDT Modified files: /php-src/ext/standard http_fopen_wrapper.c Log: Fixed memory corruption http://cvs.php.net/diff.php/php-src/ext/standard/http_fopen_wrapper.c?r1=1.101&r2=1.102&ty=u Index: php-src/ext/standard/http_fopen_wrapper.c diff -u php-src/ext/standard/http_fopen_wrapper.c:1.101 php-src/ext/standard/http_fopen_wrapper.c:1.102 --- php-src/ext/standard/http_fopen_wrapper.c:1.101 Wed Sep 21 11:04:48 2005 +++ php-src/ext/standard/http_fopen_wrapper.c Wed Sep 21 11:54:42 2005 @@ -19,7 +19,7 @@ | Sara Golemon <[EMAIL PROTECTED]> | +--+ */ -/* $Id: http_fopen_wrapper.c,v 1.101 2005/09/21 15:04:48 dmitry Exp $ */ +/* $Id: http_fopen_wrapper.c,v 1.102 2005/09/21 15:54:42 dmitry Exp $ */ #include "php.h" #include "php_globals.h" @@ -260,11 +260,12 @@ if (!request_fulluri && context && php_stream_context_get_option(context, "http", "request_fulluri", &tmpzval) == SUCCESS) { - (*tmpzval)->refcount++; - SEPARATE_ZVAL(tmpzval); - convert_to_boolean_ex(tmpzval); - request_fulluri = Z_BVAL_PP(tmpzval) ? 1 : 0; - zval_ptr_dtor(tmpzval); + zval tmp = **tmpzval; + + zval_copy_ctor(&tmp); + convert_to_boolean(&tmp); + request_fulluri = Z_BVAL(tmp) ? 1 : 0; + zval_dtor(&tmp); } if (request_fulluri) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard http_fopen_wrapper.c
dmitry Wed Sep 21 11:04:49 2005 EDT Modified files: /php-src/ext/standard http_fopen_wrapper.c Log: Allow fopen() make HTTPS requests throug HTTP proxies http://cvs.php.net/diff.php/php-src/ext/standard/http_fopen_wrapper.c?r1=1.100&r2=1.101&ty=u Index: php-src/ext/standard/http_fopen_wrapper.c diff -u php-src/ext/standard/http_fopen_wrapper.c:1.100 php-src/ext/standard/http_fopen_wrapper.c:1.101 --- php-src/ext/standard/http_fopen_wrapper.c:1.100 Tue Aug 16 02:04:59 2005 +++ php-src/ext/standard/http_fopen_wrapper.c Wed Sep 21 11:04:48 2005 @@ -19,7 +19,7 @@ | Sara Golemon <[EMAIL PROTECTED]> | +--+ */ -/* $Id: http_fopen_wrapper.c,v 1.100 2005/08/16 06:04:59 rolland Exp $ */ +/* $Id: http_fopen_wrapper.c,v 1.101 2005/09/21 15:04:48 dmitry Exp $ */ #include "php.h" #include "php_globals.h" @@ -27,6 +27,7 @@ #include "php_network.h" #include "php_ini.h" #include "ext/standard/basic_functions.h" +#include "ext/standard/php_smart_str.h" #include #include @@ -85,6 +86,7 @@ php_stream *stream = NULL; php_url *resource = NULL; int use_ssl; + int use_proxy = 0; char *scratch = NULL; char *tmp = NULL; char *ua_str = NULL; @@ -126,6 +128,7 @@ /* Called from a non-http wrapper with http proxying requested (i.e. ftp) */ request_fulluri = 1; use_ssl = 0; + use_proxy = 1; transport_len = Z_STRLEN_PP(tmpzval); transport_string = estrndup(Z_STRVAL_PP(tmpzval), Z_STRLEN_PP(tmpzval)); @@ -144,11 +147,11 @@ else if (resource->port == 0) resource->port = 80; - if (context && !use_ssl && + if (context && php_stream_context_get_option(context, wrapper->wops->label, "proxy", &tmpzval) == SUCCESS && Z_TYPE_PP(tmpzval) == IS_STRING && Z_STRLEN_PP(tmpzval) > 0) { - /* Don't use proxy server for SSL resources */ + use_proxy = 1; transport_len = Z_STRLEN_PP(tmpzval); transport_string = estrndup(Z_STRVAL_PP(tmpzval), Z_STRLEN_PP(tmpzval)); } else { @@ -168,6 +171,45 @@ efree(transport_string); + if (stream && use_proxy && use_ssl) { + smart_str header = {0}; + + smart_str_appendl(&header, "CONNECT ", sizeof("CONNECT ")-1); + smart_str_appends(&header, resource->host); + smart_str_appendc(&header, ':'); + smart_str_append_unsigned(&header, resource->port); + smart_str_appendl(&header, " HTTP/1.0\r\n\r\n", sizeof(" HTTP/1.0\r\n\r\n")-1); + if (php_stream_write(stream, header.c, header.len) != header.len) { + php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "Cannot conect to HTTPS server through proxy"); + php_stream_close(stream); + stream = NULL; + } + smart_str_free(&header); + + if (stream) { + char header_line[HTTP_HEADER_BLOCK_SIZE]; + + /* get response header */ + while (php_stream_gets(stream, header_line, HTTP_HEADER_BLOCK_SIZE-1) != NULL) { + if (header_line[0] == '\n' || + header_line[0] == '\r' || + header_line[0] == '\0') { + break; + } + } + } + + /* enable SSL transport layer */ + if (stream) { + if (php_stream_xport_crypto_setup(stream, STREAM_CRYPTO_METHOD_SSLv23_CLIENT, NULL TSRMLS_CC) < 0 || + php_stream_xport_crypto_enable(stream, 1 TSRMLS_CC) < 0) { + php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "Cannot conect to HTTPS server through proxy"); + php_stream_close(stream); + stream = NULL; + } + } + } + if (stream == NULL) goto out; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard http_fopen_wrapper.c
iliaa Thu Jul 14 10:59:19 2005 EDT Modified files: /php-src/ext/standard http_fopen_wrapper.c Log: Properly recognize redirect code 303. When encountering redirect on POST request follow browsers and cURL and perform GET on the specified location field. http://cvs.php.net/diff.php/php-src/ext/standard/http_fopen_wrapper.c?r1=1.97&r2=1.98&ty=u Index: php-src/ext/standard/http_fopen_wrapper.c diff -u php-src/ext/standard/http_fopen_wrapper.c:1.97 php-src/ext/standard/http_fopen_wrapper.c:1.98 --- php-src/ext/standard/http_fopen_wrapper.c:1.97 Mon Jun 6 08:39:57 2005 +++ php-src/ext/standard/http_fopen_wrapper.c Thu Jul 14 10:59:16 2005 @@ -19,7 +19,7 @@ | Sara Golemon <[EMAIL PROTECTED]> | +--+ */ -/* $Id: http_fopen_wrapper.c,v 1.97 2005/06/06 12:39:57 derick Exp $ */ +/* $Id: http_fopen_wrapper.c,v 1.98 2005/07/14 14:59:16 iliaa Exp $ */ #include "php.h" #include "php_globals.h" @@ -190,7 +190,7 @@ redirect_max = Z_LVAL_PP(tmpzval); } - if (context && + if (header_init && context && php_stream_context_get_option(context, "http", "method", &tmpzval) == SUCCESS) { if (Z_TYPE_PP(tmpzval) == IS_STRING && Z_STRLEN_PP(tmpzval) > 0) { scratch_len = strlen(path) + 29 + Z_STRLEN_PP(tmpzval); @@ -267,6 +267,35 @@ php_trim will estrndup() */ tmp = php_trim(Z_STRVAL_PP(tmpzval), Z_STRLEN_PP(tmpzval), NULL, 0, NULL, 3 TSRMLS_CC); if (strlen(tmp) > 0) { + if (!header_init) { /* Remove post headers for redirects */ + int l = strlen(tmp); + char *s, *s2, *tmp_c = estrdup(tmp); + + php_strtolower(tmp_c, l); + if ((s = strstr(tmp_c, "content-length:"))) { + if ((s2 = memchr(s, '\n', tmp_c + l - s))) { + int b = tmp_c + l - 1 - s2; + memmove(tmp, tmp + (s2 + 1 - tmp_c), b); + memmove(tmp_c, s2 + 1, b); + + } else { + tmp[s - tmp_c] = *s = '\0'; + } + l = strlen(tmp_c); + } + if ((s = strstr(tmp_c, "content-type:"))) { + if ((s2 = memchr(s, '\n', tmp_c + l - s))) { + memmove(tmp, tmp + (s2 + 1 - tmp_c), tmp_c + l - 1 - s2); + } else { + tmp[s - tmp_c] = '\0'; + } + } + efree(tmp_c); + tmp_c = php_trim(tmp, strlen(tmp), NULL, 0, NULL, 3 TSRMLS_CC); + efree(tmp); + tmp = tmp_c; + } + /* Output trimmed headers with \r\n at the end */ php_stream_write(stream, tmp, strlen(tmp)); php_stream_write(stream, "\r\n", sizeof("\r\n") - 1); @@ -367,7 +396,7 @@ } /* Request content, such as for POST requests */ - if (context && + if (header_init && context && php_stream_context_get_option(context, "http", "content", &tmpzval) == SUCCESS && Z_STRLEN_PP(tmpzval) > 0) { if (!(have_header & HTTP_HEADER_CONTENT_LENGTH)) { @@ -423,6 +452,7 @@ switch(response_code) { case 200: case 302: + case 303: case 301: reqok = 1; break; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard http_fopen_wrapper.c
derick Mon Jun 6 08:39:57 2005 EDT Modified files: /php-src/ext/standard http_fopen_wrapper.c Log: - Fixed bug #33242 (Mangled error message when stream fails). http://cvs.php.net/diff.php/php-src/ext/standard/http_fopen_wrapper.c?r1=1.96&r2=1.97&ty=u Index: php-src/ext/standard/http_fopen_wrapper.c diff -u php-src/ext/standard/http_fopen_wrapper.c:1.96 php-src/ext/standard/http_fopen_wrapper.c:1.97 --- php-src/ext/standard/http_fopen_wrapper.c:1.96 Thu May 5 22:31:07 2005 +++ php-src/ext/standard/http_fopen_wrapper.c Mon Jun 6 08:39:57 2005 @@ -19,7 +19,7 @@ | Sara Golemon <[EMAIL PROTECTED]> | +--+ */ -/* $Id: http_fopen_wrapper.c,v 1.96 2005/05/06 02:31:07 iliaa Exp $ */ +/* $Id: http_fopen_wrapper.c,v 1.97 2005/06/06 12:39:57 derick Exp $ */ #include "php.h" #include "php_globals.h" @@ -103,6 +103,8 @@ char *protocol_version = NULL; int protocol_version_len = 3; /* Default: "1.0" */ + tmp_line[0] = '\0'; + if (redirect_max < 1) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Redirection limit reached, aborting."); return NULL; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard http_fopen_wrapper.c
iliaa Thu May 5 22:20:00 2005 EDT Modified files: /php-src/ext/standard http_fopen_wrapper.c Log: Missing bit from previous patch. http://cvs.php.net/diff.php/php-src/ext/standard/http_fopen_wrapper.c?r1=1.94&r2=1.95&ty=u Index: php-src/ext/standard/http_fopen_wrapper.c diff -u php-src/ext/standard/http_fopen_wrapper.c:1.94 php-src/ext/standard/http_fopen_wrapper.c:1.95 --- php-src/ext/standard/http_fopen_wrapper.c:1.94 Thu May 5 22:13:46 2005 +++ php-src/ext/standard/http_fopen_wrapper.c Thu May 5 22:20:00 2005 @@ -19,7 +19,7 @@ | Sara Golemon <[EMAIL PROTECTED]> | +--+ */ -/* $Id: http_fopen_wrapper.c,v 1.94 2005/05/06 02:13:46 iliaa Exp $ */ +/* $Id: http_fopen_wrapper.c,v 1.95 2005/05/06 02:20:00 iliaa Exp $ */ #include "php.h" #include "php_globals.h" @@ -611,7 +611,9 @@ efree(scratch); } - php_url_free(resource); + if (resource) { + php_url_free(resource); + } if (stream) { if (header_init) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard http_fopen_wrapper.c
iliaa Thu May 5 22:13:47 2005 EDT Modified files: /php-src/ext/standard http_fopen_wrapper.c Log: Fixed bug #32936 (http redirects URLs are not checked for control chars). http://cvs.php.net/diff.php/php-src/ext/standard/http_fopen_wrapper.c?r1=1.93&r2=1.94&ty=u Index: php-src/ext/standard/http_fopen_wrapper.c diff -u php-src/ext/standard/http_fopen_wrapper.c:1.93 php-src/ext/standard/http_fopen_wrapper.c:1.94 --- php-src/ext/standard/http_fopen_wrapper.c:1.93 Mon Sep 27 11:55:04 2004 +++ php-src/ext/standard/http_fopen_wrapper.c Thu May 5 22:13:46 2005 @@ -19,7 +19,7 @@ | Sara Golemon <[EMAIL PROTECTED]> | +--+ */ -/* $Id: http_fopen_wrapper.c,v 1.93 2004/09/27 15:55:04 hyanantha Exp $ */ +/* $Id: http_fopen_wrapper.c,v 1.94 2005/05/06 02:13:46 iliaa Exp $ */ #include "php.h" #include "php_globals.h" @@ -551,6 +551,34 @@ } else { strlcpy(new_path, location, sizeof(new_path)); } + + php_url_free(resource); + /* check for invalid redirection URLs */ + if ((resource = php_url_parse(new_path)) == NULL) { + php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "Invalid redirect url! %s", new_path); + goto out; + } + +#define CHECK_FOR_CNTRL_CHARS(val) { \ + if (val) { \ + unsigned char *s, *e; \ + int l; \ + l = php_url_decode(val, strlen(val)); \ + s = val; e = s + l; \ + while (s < e) { \ + if (iscntrl(*s)) { \ + php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "Invalid redirect url! %s", new_path); \ + goto out; \ + } \ + s++;\ + } \ + } \ +} \ + /* check for control characters in login, password & path */ + CHECK_FOR_CNTRL_CHARS(resource->user) + CHECK_FOR_CNTRL_CHARS(resource->pass) + CHECK_FOR_CNTRL_CHARS(resource->path) + stream = php_stream_url_wrap_http_ex(wrapper, new_path, mode, options, opened_path, context, --redirect_max, 0 STREAMS_CC TSRMLS_CC); if (stream && stream->wrapperdata) { entryp = &entry; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard http_fopen_wrapper.c
pollita Wed Sep 8 19:37:55 2004 EDT Modified files: /php-src/ext/standard http_fopen_wrapper.c Log: http://cvs.php.net/diff.php/php-src/ext/standard/http_fopen_wrapper.c?r1=1.91&r2=1.92&ty=u Index: php-src/ext/standard/http_fopen_wrapper.c diff -u php-src/ext/standard/http_fopen_wrapper.c:1.91 php-src/ext/standard/http_fopen_wrapper.c:1.92 --- php-src/ext/standard/http_fopen_wrapper.c:1.91 Tue Sep 7 18:46:24 2004 +++ php-src/ext/standard/http_fopen_wrapper.c Wed Sep 8 19:37:55 2004 @@ -19,7 +19,7 @@ | Sara Golemon <[EMAIL PROTECTED]> | +--+ */ -/* $Id: http_fopen_wrapper.c,v 1.91 2004/09/07 22:46:24 pollita Exp $ */ +/* $Id: http_fopen_wrapper.c,v 1.92 2004/09/08 23:37:55 pollita Exp $ */ #include "php.h" #include "php_globals.h" @@ -89,183 +89,6 @@ #define HTTP_HEADER_CONTENT_LENGTH 16 #define HTTP_HEADER_TYPE 32 -/* 8 hexits plus \r\n\0 */ -#define HTTP_CHUNK_SIZE_MAXLEN 11 -#define HTTP_CHUNKED_ENCODING_BUFFER_LEN (HTTP_CHUNK_SIZE_MAXLEN + 1) - -typedef struct _php_http_chunked_encoding_data { - int is_persistent; - size_t chunk_remaining; - char chunksize_buffer[HTTP_CHUNKED_ENCODING_BUFFER_LEN]; - char *chunksize_buffer_pos; -} php_http_chunked_encoding_data; - -static php_stream_filter_status_t php_http_chunked_encoding_filter( -php_stream *stream, -php_stream_filter *thisfilter, -php_stream_bucket_brigade *buckets_in, -php_stream_bucket_brigade *buckets_out, -size_t *bytes_consumed, -int flags -TSRMLS_DC) -{ - php_stream_bucket *bucket; - php_http_chunked_encoding_data *data = (php_http_chunked_encoding_data*)thisfilter->abstract; - size_t consumed = 0; - char *buf; - size_t buflen; - - while (buckets_in->head) { - char *e = NULL; - size_t chunk_remaining; - - bucket = buckets_in->head; - php_stream_bucket_unlink(bucket TSRMLS_CC); - - buf = bucket->buf; - buflen = bucket->buflen; - -continue_bucket: - - if (data->chunk_remaining > 0) { - if ((data->chunk_remaining > buflen) && (bucket->buf == buf)) { - /* This bucket is smaller than our remaining chunksize, - Pass it on unmolested */ - consumed += buflen; - data->chunk_remaining -= buflen; - php_stream_bucket_append(buckets_out, bucket TSRMLS_CC); - - /* Next bucket please */ - continue; - } else if (data->chunk_remaining > buflen) { - php_stream_bucket *newbucket; - char *newbuf; - - /* Previously split bucket can be used en toto */ - consumed += buflen; - data->chunk_remaining -= buflen; - - newbuf = estrndup(buf, buflen); - newbucket = php_stream_bucket_new(stream, newbuf, buflen, 1, stream->is_persistent TSRMLS_CC); - php_stream_bucket_append(buckets_out, newbucket TSRMLS_CC); - php_stream_bucket_delref(bucket TSRMLS_CC); - /* Next bucket please */ - continue; - } else { - php_stream_bucket *newbucket; - char *newbuf; - - /* Consume enough of this bucket to satisfy the current chunk */ - newbuf = pemalloc(data->chunk_remaining, stream->is_persistent); - memcpy(newbuf, buf, data->chunk_remaining); - - newbucket = php_stream_bucket_new(stream, newbuf, data->chunk_remaining, 1, stream->is_persistent TSRMLS_CC); - php_stream_bucket_append(buckets_out, newbucket TSRMLS_CC); - buf += data->chunk_remaining; - buflen -= data->chunk_remaining; - consumed += data->chunk_remaining; - data->chunk_remaining = 0; - /* Fall Through */ - } - } - - while (buflen > 0 && (*buf == '\r' || *buf == '\n')) { - buf++; - buflen--; - } - - if (buflen <= 0) { - php_stream_bucket_delref(bucket TSRMLS_CC); - continue; - } -
[PHP-CVS] cvs: php-src /ext/standard http_fopen_wrapper.c
pollita Tue Sep 7 18:46:25 2004 EDT Modified files: /php-src/ext/standard http_fopen_wrapper.c Log: Chunk Length may optionally be followed by whitespace http://cvs.php.net/diff.php/php-src/ext/standard/http_fopen_wrapper.c?r1=1.90&r2=1.91&ty=u Index: php-src/ext/standard/http_fopen_wrapper.c diff -u php-src/ext/standard/http_fopen_wrapper.c:1.90 php-src/ext/standard/http_fopen_wrapper.c:1.91 --- php-src/ext/standard/http_fopen_wrapper.c:1.90 Tue Sep 7 15:27:11 2004 +++ php-src/ext/standard/http_fopen_wrapper.c Tue Sep 7 18:46:24 2004 @@ -19,7 +19,7 @@ | Sara Golemon <[EMAIL PROTECTED]> | +--+ */ -/* $Id: http_fopen_wrapper.c,v 1.90 2004/09/07 19:27:11 pollita Exp $ */ +/* $Id: http_fopen_wrapper.c,v 1.91 2004/09/07 22:46:24 pollita Exp $ */ #include "php.h" #include "php_globals.h" @@ -186,6 +186,8 @@ memcpy(data->chunksize_buffer_pos, buf, buflen); memset(data->chunksize_buffer_pos + buflen, 0, HTTP_CHUNK_SIZE_MAXLEN - buflen - (data->chunksize_buffer_pos - data->chunksize_buffer)); chunk_remaining = strtoul(data->chunksize_buffer, &e, 16); + /* Skip whitespace */ + while ((*e == ' ') && (e < (data->chunksize_buffer + HTTP_CHUNK_SIZE_MAXLEN))) e++; if (*e != '\r') { if (!((*e >= '0' && *e <= '9') || (*e >= 'a' && *e <= 'f') || @@ -201,6 +203,8 @@ } else { memcpy(data->chunksize_buffer_pos, buf, HTTP_CHUNK_SIZE_MAXLEN - (data->chunksize_buffer_pos - data->chunksize_buffer)); chunk_remaining = strtoul(data->chunksize_buffer, &e, 16); + /* Skip whitespace */ + while ((*e == ' ') && (e < (data->chunksize_buffer + HTTP_CHUNK_SIZE_MAXLEN))) e++; if (*e != '\r') { /* Invalid chunksize */ return PSFS_ERR_FATAL; @@ -799,7 +803,6 @@ php_stream_filter_append(&stream->readfilters, filter); } } - } return stream; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src /ext/standard http_fopen_wrapper.c
Can you please use estrndup() instead of estrdup()? Thanks, Andi At 01:38 PM 5/28/2004 +, Stefan Esser wrote: sesser Fri May 28 09:38:07 2004 EDT Modified files: /php-src/ext/standard http_fopen_wrapper.c Log: Fixed off-by-one in http_fopen_wrapper http://cvs.php.net/diff.php/php-src/ext/standard/http_fopen_wrapper.c?r1=1.87&r2=1.88&ty=u Index: php-src/ext/standard/http_fopen_wrapper.c diff -u php-src/ext/standard/http_fopen_wrapper.c:1.87 php-src/ext/standard/http_fopen_wrapper.c:1.88 --- php-src/ext/standard/http_fopen_wrapper.c:1.87 Thu Apr 22 23:37:20 2004 +++ php-src/ext/standard/http_fopen_wrapper.c Fri May 28 09:38:06 2004 @@ -18,7 +18,7 @@ | Wez Furlong <[EMAIL PROTECTED]> | +--+ */ -/* $Id: http_fopen_wrapper.c,v 1.87 2004/04/23 03:37:20 pollita Exp $ */ +/* $Id: http_fopen_wrapper.c,v 1.88 2004/05/28 13:38:06 sesser Exp $ */ #include "php.h" #include "php_globals.h" @@ -498,7 +498,12 @@ char *s = strrchr(resource->path, '/'); if (!s) { s = resource->path; - *s = '/'; + if (!s[0]) { + efree(s); + s = resource->path = estrdup("/"); + } else { + *s = '/'; + } } s[1] = '\0'; if (resource->path && *(resource->path) == '/' && *(resource->path + 1) == '\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
[PHP-CVS] cvs: php-src /ext/standard http_fopen_wrapper.c
sesser Fri May 28 09:38:07 2004 EDT Modified files: /php-src/ext/standard http_fopen_wrapper.c Log: Fixed off-by-one in http_fopen_wrapper http://cvs.php.net/diff.php/php-src/ext/standard/http_fopen_wrapper.c?r1=1.87&r2=1.88&ty=u Index: php-src/ext/standard/http_fopen_wrapper.c diff -u php-src/ext/standard/http_fopen_wrapper.c:1.87 php-src/ext/standard/http_fopen_wrapper.c:1.88 --- php-src/ext/standard/http_fopen_wrapper.c:1.87 Thu Apr 22 23:37:20 2004 +++ php-src/ext/standard/http_fopen_wrapper.c Fri May 28 09:38:06 2004 @@ -18,7 +18,7 @@ | Wez Furlong <[EMAIL PROTECTED]> | +--+ */ -/* $Id: http_fopen_wrapper.c,v 1.87 2004/04/23 03:37:20 pollita Exp $ */ +/* $Id: http_fopen_wrapper.c,v 1.88 2004/05/28 13:38:06 sesser Exp $ */ #include "php.h" #include "php_globals.h" @@ -498,7 +498,12 @@ char *s = strrchr(resource->path, '/'); if (!s) { s = resource->path; - *s = '/'; + if (!s[0]) { + efree(s); + s = resource->path = estrdup("/"); + } else { + *s = '/'; + } } s[1] = '\0'; if (resource->path && *(resource->path) == '/' && *(resource->path + 1) == '\0') { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard http_fopen_wrapper.c
pollita Thu Apr 22 23:37:20 2004 EDT Modified files: /php-src/ext/standard http_fopen_wrapper.c Log: In-HEAD bugfix# 28115 http://cvs.php.net/diff.php/php-src/ext/standard/http_fopen_wrapper.c?r1=1.86&r2=1.87&ty=u Index: php-src/ext/standard/http_fopen_wrapper.c diff -u php-src/ext/standard/http_fopen_wrapper.c:1.86 php-src/ext/standard/http_fopen_wrapper.c:1.87 --- php-src/ext/standard/http_fopen_wrapper.c:1.86 Fri Mar 19 10:41:26 2004 +++ php-src/ext/standard/http_fopen_wrapper.c Thu Apr 22 23:37:20 2004 @@ -18,7 +18,7 @@ | Wez Furlong <[EMAIL PROTECTED]> | +--+ */ -/* $Id: http_fopen_wrapper.c,v 1.86 2004/03/19 15:41:26 iliaa Exp $ */ +/* $Id: http_fopen_wrapper.c,v 1.87 2004/04/23 03:37:20 pollita Exp $ */ #include "php.h" #include "php_globals.h" @@ -194,6 +194,7 @@ /* Should we send the entire path in the request line, default to no. */ if (context && php_stream_context_get_option(context, "http", "request_fulluri", &tmpzval) == SUCCESS) { + (*tmpzval)->refcount++; SEPARATE_ZVAL(tmpzval); convert_to_boolean_ex(tmpzval); request_fulluri = Z_BVAL_PP(tmpzval) ? 1 : 0; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard http_fopen_wrapper.c
sniper Wed Feb 25 19:13:30 2004 EDT Modified files: /php-src/ext/standard http_fopen_wrapper.c Log: MFB: typofix http://cvs.php.net/diff.php/php-src/ext/standard/http_fopen_wrapper.c?r1=1.84&r2=1.85&ty=u Index: php-src/ext/standard/http_fopen_wrapper.c diff -u php-src/ext/standard/http_fopen_wrapper.c:1.84 php-src/ext/standard/http_fopen_wrapper.c:1.85 --- php-src/ext/standard/http_fopen_wrapper.c:1.84 Wed Feb 25 19:02:27 2004 +++ php-src/ext/standard/http_fopen_wrapper.c Wed Feb 25 19:13:30 2004 @@ -18,7 +18,7 @@ | Wez Furlong <[EMAIL PROTECTED]> | +--+ */ -/* $Id: http_fopen_wrapper.c,v 1.84 2004/02/26 00:02:27 iliaa Exp $ */ +/* $Id: http_fopen_wrapper.c,v 1.85 2004/02/26 00:13:30 sniper Exp $ */ #include "php.h" #include "php_globals.h" @@ -400,7 +400,7 @@ zend_hash_next_index_insert(Z_ARRVAL_PP(response_header), &http_response, sizeof(zval *), NULL); } } else { - php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "HTTP request failed, unexpected end of socket.!"); + php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "HTTP request failed, unexpected end of socket!"); goto out; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard http_fopen_wrapper.c
iliaa Wed Feb 25 19:02:29 2004 EDT Modified files: /php-src/ext/standard http_fopen_wrapper.c Log: Handle situation where feof() occurs before the HTTP header is retrieved. http://cvs.php.net/diff.php/php-src/ext/standard/http_fopen_wrapper.c?r1=1.83&r2=1.84&ty=u Index: php-src/ext/standard/http_fopen_wrapper.c diff -u php-src/ext/standard/http_fopen_wrapper.c:1.83 php-src/ext/standard/http_fopen_wrapper.c:1.84 --- php-src/ext/standard/http_fopen_wrapper.c:1.83 Wed Feb 25 04:36:46 2004 +++ php-src/ext/standard/http_fopen_wrapper.c Wed Feb 25 19:02:27 2004 @@ -18,7 +18,7 @@ | Wez Furlong <[EMAIL PROTECTED]> | +--+ */ -/* $Id: http_fopen_wrapper.c,v 1.83 2004/02/25 09:36:46 sebastian Exp $ */ +/* $Id: http_fopen_wrapper.c,v 1.84 2004/02/26 00:02:27 iliaa Exp $ */ #include "php.h" #include "php_globals.h" @@ -399,6 +399,9 @@ Z_TYPE_P(http_response) = IS_STRING; zend_hash_next_index_insert(Z_ARRVAL_PP(response_header), &http_response, sizeof(zval *), NULL); } + } else { + php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "HTTP request failed, unexpected end of socket.!"); + goto out; } /* read past HTTP headers */ -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard http_fopen_wrapper.c
sebastian Wed Feb 25 04:36:47 2004 EDT Modified files: /php-src/ext/standard http_fopen_wrapper.c Log: ZTS fix. http://cvs.php.net/diff.php/php-src/ext/standard/http_fopen_wrapper.c?r1=1.82&r2=1.83&ty=u Index: php-src/ext/standard/http_fopen_wrapper.c diff -u php-src/ext/standard/http_fopen_wrapper.c:1.82 php-src/ext/standard/http_fopen_wrapper.c:1.83 --- php-src/ext/standard/http_fopen_wrapper.c:1.82 Tue Feb 24 16:52:40 2004 +++ php-src/ext/standard/http_fopen_wrapper.c Wed Feb 25 04:36:46 2004 @@ -18,7 +18,7 @@ | Wez Furlong <[EMAIL PROTECTED]> | +--+ */ -/* $Id: http_fopen_wrapper.c,v 1.82 2004/02/24 21:52:40 iliaa Exp $ */ +/* $Id: http_fopen_wrapper.c,v 1.83 2004/02/25 09:36:46 sebastian Exp $ */ #include "php.h" #include "php_globals.h" @@ -355,7 +355,7 @@ size_t tmp_line_len; /* get response header */ - if (_php_stream_get_line(stream, tmp_line, sizeof(tmp_line) - 1, &tmp_line_len) != NULL) { + if (_php_stream_get_line(stream, tmp_line, sizeof(tmp_line) - 1, &tmp_line_len TSRMLS_CC) != NULL) { zval *http_response; int response_code; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard http_fopen_wrapper.c
iliaa Tue Feb 24 16:52:41 2004 EDT Modified files: /php-src/ext/standard http_fopen_wrapper.c Log: Fixed bug #27383 (Potential crash inside fopen_wrapper, while parsing response code). http://cvs.php.net/diff.php/php-src/ext/standard/http_fopen_wrapper.c?r1=1.81&r2=1.82&ty=u Index: php-src/ext/standard/http_fopen_wrapper.c diff -u php-src/ext/standard/http_fopen_wrapper.c:1.81 php-src/ext/standard/http_fopen_wrapper.c:1.82 --- php-src/ext/standard/http_fopen_wrapper.c:1.81 Thu Jan 29 19:24:17 2004 +++ php-src/ext/standard/http_fopen_wrapper.c Tue Feb 24 16:52:40 2004 @@ -18,7 +18,7 @@ | Wez Furlong <[EMAIL PROTECTED]> | +--+ */ -/* $Id: http_fopen_wrapper.c,v 1.81 2004/01/30 00:24:17 pollita Exp $ */ +/* $Id: http_fopen_wrapper.c,v 1.82 2004/02/24 21:52:40 iliaa Exp $ */ #include "php.h" #include "php_globals.h" @@ -351,17 +351,22 @@ } - if (!php_stream_eof(stream)){ + if (!php_stream_eof(stream)) { + size_t tmp_line_len; /* get response header */ - if (php_stream_gets(stream, tmp_line, sizeof(tmp_line)-1) != NULL) { + if (_php_stream_get_line(stream, tmp_line, sizeof(tmp_line) - 1, &tmp_line_len) != NULL) { zval *http_response; int response_code; MAKE_STD_ZVAL(http_response); ZVAL_NULL(http_response); - response_code = atoi(tmp_line + 9); + if (tmp_line_len > 9) { + response_code = atoi(tmp_line + 9); + } else { + response_code = 0; + } switch(response_code) { case 200: case 302: @@ -373,11 +378,15 @@ tmp_line, response_code); break; default: + /* safety net in the event tmp_line == NULL */ + if (!tmp_line_len) { + tmp_line[0] = '\0'; + } php_stream_notify_error(context, PHP_STREAM_NOTIFY_FAILURE, tmp_line, response_code); } - Z_STRLEN_P(http_response) = strlen(tmp_line); + Z_STRLEN_P(http_response) = tmp_line_len; Z_STRVAL_P(http_response) = estrndup(tmp_line, Z_STRLEN_P(http_response)); if (Z_STRVAL_P(http_response)[Z_STRLEN_P(http_response)-1]=='\n') { Z_STRVAL_P(http_response)[Z_STRLEN_P(http_response)-1]=0; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php