- fixed a gotcha in http_chunked_decode (-size_t is always > 0)
authorMichael Wallner <mike@php.net>
Fri, 23 Sep 2005 12:00:30 +0000 (12:00 +0000)
committerMichael Wallner <mike@php.net>
Fri, 23 Sep 2005 12:00:30 +0000 (12:00 +0000)
- avoid unneccessary initialization operations

config.m4
http_api.c
http_headers_api.c
http_message_object.c
http_request_object.c
http_requestpool_object.c
http_response_object.c
package2.xml
php_http_api.h

index cb340f52f45f41654a6e2193c785c714c0065921..ec5b519e701ae60cd64d688900f5cb15cbbb80cd 100644 (file)
--- a/config.m4
+++ b/config.m4
@@ -3,7 +3,7 @@ dnl $Id$
 
 PHP_ARG_ENABLE([http], [whether to enable extended HTTP support],
 [  --enable-http           Enable extended HTTP support])
-PHP_ARG_WITH([http-curl-requests], [wheter to enable cURL HTTP requests],
+PHP_ARG_WITH([http-curl-requests], [whether to enable cURL HTTP requests],
 [  --with-http-curl-requests[=CURLDIR]
                            With cURL HTTP request support])
 PHP_ARG_WITH([http-mhash-etags], [whether to enable mhash ETag generator],
index eec41daa0d7068d964cc26ab7377e15dc6b78fba..eebfeb2ef80840c9f2f53bb46b3782413941dcea 100644 (file)
@@ -295,24 +295,28 @@ PHP_HTTP_API const char *_http_chunked_decode(const char *encoded, size_t encode
 {
        const char *e_ptr;
        char *d_ptr;
+       long rest;
        
        *decoded_len = 0;
        *decoded = ecalloc(1, encoded_len);
        d_ptr = *decoded;
        e_ptr = encoded;
 
-       while (((e_ptr - encoded) - encoded_len) > 0) {
-               size_t chunk_len = 0, EOL_len = 0;
-               int eol_mismatch = 0;
+       while ((rest = encoded + encoded_len - e_ptr) > 0) {
+               long chunk_len = 0;
+               int EOL_len = 0, eol_mismatch = 0;
                char *n_ptr;
 
                chunk_len = strtol(e_ptr, &n_ptr, 16);
 
                /* check if:
                 * - we could not read in chunk size
+                * - we got a negative chunk size
+                * - chunk size is greater then remaining size
                 * - chunk size is not followed by (CR)LF|NUL
                 */
-               if ((n_ptr == e_ptr) || (*n_ptr && (eol_mismatch = n_ptr != http_locate_eol(e_ptr, &EOL_len)))) {
+               if (    (n_ptr == e_ptr) ||     (chunk_len < 0) || (chunk_len > rest) || 
+                               (*n_ptr && (eol_mismatch = (n_ptr != http_locate_eol(e_ptr, &EOL_len))))) {
                        /* don't fail on apperently not encoded data */
                        if (e_ptr == encoded) {
                                memcpy(*decoded, encoded, encoded_len);
index 8a4ecc5591f8d9a9ee8c2b4e918a755c56facd4d..63c46abad58a8d23f2a9004ee568e9f7227062cd 100644 (file)
@@ -154,7 +154,7 @@ PHP_HTTP_API HashTable *_http_negotiate_q(const char *header, HashTable *support
                                        
                                        while (*++ptr && !isdigit(*ptr));
                                        
-                                       quality = strtod(ptr, NULL);
+                                       quality = atof(ptr);
                                        identifier = estrndup(Z_STRVAL_PP(entry), separator - Z_STRVAL_PP(entry));
                                } else {
                                        quality = 1000.0 - i++;
index e3a1617da3de2aed8cee2712e7411701c7bdab9a..058f963d8cb81f8aa045901b352bdadb2188efad 100644 (file)
@@ -160,9 +160,6 @@ zend_object_value _http_message_object_new_ex(zend_class_entry *ce, http_message
 
        o = ecalloc(1, sizeof(http_message_object));
        o->zo.ce = ce;
-       o->message = NULL;
-       o->parent.handle = 0;
-       o->parent.handlers = NULL;
 
        if (msg) {
                o->message = msg;
index f1f2551d0328e4094651256ee1ce3b79b60a587f..9c5e902db0f7dce7d376697fe78ab582237886e9 100644 (file)
@@ -306,7 +306,6 @@ zend_object_value _http_request_object_new(zend_class_entry *ce TSRMLS_DC)
        o = ecalloc(1, sizeof(http_request_object));
        o->zo.ce = ce;
        o->ch = curl_easy_init();
-       o->pool = NULL;
 
        phpstr_init(&o->history);
        phpstr_init(&o->request);
index c917d8615c809713d69d97f8774d16310d58ffa0..f312b7fad55664945205def9337f28af62fa38a3 100644 (file)
@@ -108,7 +108,6 @@ zend_object_value _http_requestpool_object_new(zend_class_entry *ce TSRMLS_DC)
        o->zo.ce = ce;
 
        http_request_pool_init(&o->pool);
-       o->iterator.pos = 0;
 
        ALLOC_HASHTABLE(OBJ_PROP(o));
        zend_hash_init(OBJ_PROP(o), 0, NULL, ZVAL_PTR_DTOR, 0);
index 23071983c12b3c8e6f36413d33a004030196dc2e..93c8f0c82193ca56993cb02928a12f21c017b707 100644 (file)
@@ -41,6 +41,9 @@
 #ifdef HTTP_HAVE_MHASH
 #      include <mhash.h>
 #endif
+#ifdef HTTP_HAVE_MAGIC
+#      include <magic.h>
+#endif
 
 ZEND_EXTERN_MODULE_GLOBALS(http);
 
index 05565037be03c2db1a9fe5de4115eb6efdc64cff..33a0aaaef371a7bc155f9062fcb7c15bed872f25 100644 (file)
@@ -49,8 +49,6 @@
 + Added supported ETag hash algrithms to php_info() output
 + Added ETag hashing through PHPs CRC32() implementation
 + Added new language/charset negotiator
-+ Added HttpMessage::setBody()
-+ Added HttpRequest raw post data support
 
 * Changed HttpMessage::toString([include_parent = true]) to false
 * Renamed HTTP_GET etc. constants to HTTP_METH_GET
index fc34e87a1afeaf5b08d0fa4c6deb15e5b481d49b..826f6cd198572b66b0192f8c26f46e431513f0ea 100644 (file)
@@ -84,7 +84,7 @@ static inline const char *_http_locate_body(const char *message)
 }
 
 #define http_locate_eol _http_locate_eol
-static inline const char *_http_locate_eol(const char *line, size_t *eol_len)
+static inline const char *_http_locate_eol(const char *line, int *eol_len)
 {
        const char *eol = strpbrk(line, "\r\n");