diff options
-rw-r--r-- | main/streams/memory.c | 8 | ||||
-rw-r--r-- | main/streams/streams.c | 15 | ||||
-rw-r--r-- | main/streams/transports.c | 5 |
3 files changed, 11 insertions, 17 deletions
diff --git a/main/streams/memory.c b/main/streams/memory.c index c212778151..d6b0e5604b 100644 --- a/main/streams/memory.c +++ b/main/streams/memory.c @@ -638,7 +638,7 @@ static php_stream * php_stream_url_wrap_rfc2397(php_stream_wrapper *wrapper, con { php_stream *stream; php_stream_temp_data *ts; - char *comma, *semi, *sep, *key; + char *comma, *semi, *sep; size_t mlen, dlen, plen, vlen, ilen; zend_off_t newoffs; zval meta; @@ -710,11 +710,9 @@ static php_stream * php_stream_url_wrap_rfc2397(php_stream_wrapper *wrapper, con /* found parameter ... the heart of cs ppl lies in +1/-1 or was it +2 this time? */ plen = sep - path; vlen = (semi ? (size_t)(semi - sep) : (mlen - plen)) - 1 /* '=' */; - key = estrndup(path, plen); - if (plen != sizeof("mediatype")-1 || memcmp(key, "mediatype", sizeof("mediatype")-1)) { - add_assoc_stringl_ex(&meta, key, plen, sep + 1, vlen); + if (plen != sizeof("mediatype")-1 || memcmp(path, "mediatype", sizeof("mediatype")-1)) { + add_assoc_stringl_ex(&meta, path, plen, sep + 1, vlen); } - efree(key); plen += vlen + 1; mlen -= plen; path += plen; diff --git a/main/streams/streams.c b/main/streams/streams.c index 5f8acfde69..c97ebd0239 100644 --- a/main/streams/streams.c +++ b/main/streams/streams.c @@ -1742,10 +1742,11 @@ PHPAPI php_stream_wrapper *php_stream_locate_url_wrapper(const char *path, const } if (protocol) { - char *tmp = estrndup(protocol, n); - if (NULL == (wrapper = zend_hash_str_find_ptr(wrapper_hash, (char*)tmp, n))) { + if (NULL == (wrapper = zend_hash_str_find_ptr(wrapper_hash, protocol, n))) { + char *tmp = estrndup(protocol, n); + php_strtolower(tmp, n); - if (NULL == (wrapper = zend_hash_str_find_ptr(wrapper_hash, (char*)tmp, n))) { + if (NULL == (wrapper = zend_hash_str_find_ptr(wrapper_hash, tmp, n))) { char wrapper_name[32]; if (n >= sizeof(wrapper_name)) { @@ -1758,8 +1759,8 @@ PHPAPI php_stream_wrapper *php_stream_locate_url_wrapper(const char *path, const wrapper = NULL; protocol = NULL; } + efree(tmp); } - efree(tmp); } /* TODO: curl based streams probably support file:// properly */ if (!protocol || !strncasecmp(protocol, "file", n)) { @@ -1833,13 +1834,11 @@ PHPAPI php_stream_wrapper *php_stream_locate_url_wrapper(const char *path, const PG(in_user_include)) && !PG(allow_url_include)))) { if (options & REPORT_ERRORS) { /* protocol[n] probably isn't '\0' */ - char *protocol_dup = estrndup(protocol, n); if (!PG(allow_url_fopen)) { - php_error_docref(NULL, E_WARNING, "%s:// wrapper is disabled in the server configuration by allow_url_fopen=0", protocol_dup); + php_error_docref(NULL, E_WARNING, "%.*s:// wrapper is disabled in the server configuration by allow_url_fopen=0", (int)n, protocol); } else { - php_error_docref(NULL, E_WARNING, "%s:// wrapper is disabled in the server configuration by allow_url_include=0", protocol_dup); + php_error_docref(NULL, E_WARNING, "%.*s:// wrapper is disabled in the server configuration by allow_url_include=0", (int)n, protocol); } - efree(protocol_dup); } return NULL; } diff --git a/main/streams/transports.c b/main/streams/transports.c index 2bf4230870..5a73aea1c0 100644 --- a/main/streams/transports.c +++ b/main/streams/transports.c @@ -112,8 +112,7 @@ PHPAPI php_stream *_php_stream_xport_create(const char *name, size_t namelen, in } if (protocol) { - char *tmp = estrndup(protocol, n); - if (NULL == (factory = zend_hash_str_find_ptr(&xport_hash, tmp, n))) { + if (NULL == (factory = zend_hash_str_find_ptr(&xport_hash, protocol, n))) { char wrapper_name[32]; if (n >= sizeof(wrapper_name)) @@ -123,10 +122,8 @@ PHPAPI php_stream *_php_stream_xport_create(const char *name, size_t namelen, in ERR_REPORT(error_string, "Unable to find the socket transport \"%s\" - did you forget to enable it when you configured PHP?", wrapper_name); - efree(tmp); return NULL; } - efree(tmp); } if (factory == NULL) { |