From 902e6583d9f37885c886c768fd3dbce2079e512c Mon Sep 17 00:00:00 2001 From: Antony Dovgal Date: Mon, 15 Jan 2007 17:06:52 +0000 Subject: add trailing '\0' to stream hashes --- main/streams/streams.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'main/streams/streams.c') diff --git a/main/streams/streams.c b/main/streams/streams.c index ddddd29f7f..cba7765734 100755 --- a/main/streams/streams.c +++ b/main/streams/streams.c @@ -1997,12 +1997,12 @@ PHPAPI int php_register_url_stream_wrapper(char *protocol, php_stream_wrapper *w return FAILURE; } - return zend_hash_add(&url_stream_wrappers_hash, protocol, protocol_len, &wrapper, sizeof(wrapper), NULL); + return zend_hash_add(&url_stream_wrappers_hash, protocol, protocol_len + 1, &wrapper, sizeof(wrapper), NULL); } PHPAPI int php_unregister_url_stream_wrapper(char *protocol TSRMLS_DC) { - return zend_hash_del(&url_stream_wrappers_hash, protocol, strlen(protocol)); + return zend_hash_del(&url_stream_wrappers_hash, protocol, strlen(protocol) + 1); } static void clone_wrapper_hash(TSRMLS_D) @@ -2027,7 +2027,7 @@ PHPAPI int php_register_url_stream_wrapper_volatile(char *protocol, php_stream_w clone_wrapper_hash(TSRMLS_C); } - return zend_hash_add(FG(stream_wrappers), protocol, protocol_len, &wrapper, sizeof(wrapper), NULL); + return zend_hash_add(FG(stream_wrappers), protocol, protocol_len + 1, &wrapper, sizeof(wrapper), NULL); } PHPAPI int php_unregister_url_stream_wrapper_volatile(char *protocol TSRMLS_DC) @@ -2036,7 +2036,7 @@ PHPAPI int php_unregister_url_stream_wrapper_volatile(char *protocol TSRMLS_DC) clone_wrapper_hash(TSRMLS_C); } - return zend_hash_del(FG(stream_wrappers), protocol, strlen(protocol)); + return zend_hash_del(FG(stream_wrappers), protocol, strlen(protocol) + 1); } /* }}} */ @@ -2070,10 +2070,10 @@ PHPAPI php_stream_wrapper *php_stream_locate_url_wrapper(const char *path, char } if (protocol) { - if (FAILURE == zend_hash_find(wrapper_hash, (char*)protocol, n, (void**)&wrapperpp)) { - char *tmp = estrndup(protocol, n); + char *tmp = estrndup(protocol, n); + if (FAILURE == zend_hash_find(wrapper_hash, (char*)tmp, n + 1, (void**)&wrapperpp)) { php_strtolower(tmp, n); - if (FAILURE == zend_hash_find(wrapper_hash, (char*)tmp, n, (void**)&wrapperpp)) { + if (FAILURE == zend_hash_find(wrapper_hash, (char*)tmp, n + 1, (void**)&wrapperpp)) { char wrapper_name[32]; if (n >= sizeof(wrapper_name)) { @@ -2086,8 +2086,8 @@ PHPAPI php_stream_wrapper *php_stream_locate_url_wrapper(const char *path, char wrapperpp = NULL; protocol = NULL; } - efree(tmp); } + efree(tmp); } /* TODO: curl based streams probably support file:// properly */ if (!protocol || !strncasecmp(protocol, "file", n)) { @@ -2136,7 +2136,7 @@ PHPAPI php_stream_wrapper *php_stream_locate_url_wrapper(const char *path, char } /* Check again, the original check might have not known the protocol name */ - if (zend_hash_find(wrapper_hash, "file", sizeof("file")-1, (void**)&wrapperpp) == SUCCESS) { + if (zend_hash_find(wrapper_hash, "file", sizeof("file"), (void**)&wrapperpp) == SUCCESS) { return *wrapperpp; } -- cgit v1.2.1