summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntony Dovgal <tony2001@php.net>2007-01-15 17:06:52 +0000
committerAntony Dovgal <tony2001@php.net>2007-01-15 17:06:52 +0000
commit902e6583d9f37885c886c768fd3dbce2079e512c (patch)
tree3411214069e7dbe1d8d666dd6a60c6714029b6a1
parent3868c1533efce05a9dee1e0212d8913a59c4e972 (diff)
downloadphp-git-902e6583d9f37885c886c768fd3dbce2079e512c.tar.gz
add trailing '\0' to stream hashes
-rw-r--r--ext/standard/user_filters.c6
-rwxr-xr-xmain/streams/streams.c18
-rw-r--r--main/streams/transports.c9
-rw-r--r--main/streams/userspace.c2
4 files changed, 19 insertions, 16 deletions
diff --git a/ext/standard/user_filters.c b/ext/standard/user_filters.c
index ac03f4c1ae..b92d952538 100644
--- a/ext/standard/user_filters.c
+++ b/ext/standard/user_filters.c
@@ -270,7 +270,7 @@ static php_stream_filter *user_filter_factory_create(const char *filtername,
/* determine the classname/class entry */
if (FAILURE == zend_hash_find(BG(user_filter_map), (char*)filtername,
- strlen(filtername), (void**)&fdat)) {
+ strlen(filtername) + 1, (void**)&fdat)) {
char *period;
/* Userspace Filters using ambiguous wildcards could cause problems.
@@ -287,7 +287,7 @@ static php_stream_filter *user_filter_factory_create(const char *filtername,
while (period) {
*period = '\0';
strcat(wildcard, ".*");
- if (SUCCESS == zend_hash_find(BG(user_filter_map), wildcard, strlen(wildcard), (void**)&fdat)) {
+ if (SUCCESS == zend_hash_find(BG(user_filter_map), wildcard, strlen(wildcard) + 1, (void**)&fdat)) {
period = NULL;
} else {
*period = '\0';
@@ -617,7 +617,7 @@ PHP_FUNCTION(stream_filter_register)
fdat->classname = ezstrndup(classname_type, classname, classname_len);
fdat->classname_len = classname_len;
- if (zend_hash_add(BG(user_filter_map), filtername, filtername_len, (void*)fdat,
+ if (zend_hash_add(BG(user_filter_map), filtername, filtername_len + 1, (void*)fdat,
sizeof(*fdat) + classname_len, NULL) == SUCCESS &&
php_stream_filter_register_factory_volatile(filtername, &user_filter_factory TSRMLS_CC) == SUCCESS) {
RETVAL_TRUE;
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;
}
diff --git a/main/streams/transports.c b/main/streams/transports.c
index 39dbea0f6a..dcc2abf565 100644
--- a/main/streams/transports.c
+++ b/main/streams/transports.c
@@ -31,12 +31,12 @@ PHPAPI HashTable *php_stream_xport_get_hash(void)
PHPAPI int php_stream_xport_register(char *protocol, php_stream_transport_factory factory TSRMLS_DC)
{
- return zend_hash_update(&xport_hash, protocol, strlen(protocol), &factory, sizeof(factory), NULL);
+ return zend_hash_update(&xport_hash, protocol, strlen(protocol) + 1, &factory, sizeof(factory), NULL);
}
PHPAPI int php_stream_xport_unregister(char *protocol TSRMLS_DC)
{
- return zend_hash_del(&xport_hash, protocol, strlen(protocol));
+ return zend_hash_del(&xport_hash, protocol, strlen(protocol) + 1);
}
#define ERR_REPORT(out_err, fmt, arg) \
@@ -106,7 +106,8 @@ PHPAPI php_stream *_php_stream_xport_create(const char *name, long namelen, int
}
if (protocol) {
- if (FAILURE == zend_hash_find(&xport_hash, (char*)protocol, n, (void**)&factory)) {
+ char *tmp = estrndup(protocol, n);
+ if (FAILURE == zend_hash_find(&xport_hash, tmp, n + 1, (void**)&factory)) {
char wrapper_name[32];
if (n >= sizeof(wrapper_name))
@@ -116,8 +117,10 @@ PHPAPI php_stream *_php_stream_xport_create(const char *name, long namelen, int
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) {
diff --git a/main/streams/userspace.c b/main/streams/userspace.c
index b74476a7d0..5aeeb2f47d 100644
--- a/main/streams/userspace.c
+++ b/main/streams/userspace.c
@@ -511,7 +511,7 @@ PHP_FUNCTION(stream_wrapper_restore)
RETURN_TRUE;
}
- if ((zend_hash_find(global_wrapper_hash, protocol, protocol_len, (void**)&wrapperpp) == FAILURE) || !wrapperpp) {
+ if ((zend_hash_find(global_wrapper_hash, protocol, protocol_len + 1, (void**)&wrapperpp) == FAILURE) || !wrapperpp) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s:// never existed, nothing to restore", protocol);
RETURN_FALSE;
}