summaryrefslogtreecommitdiff
path: root/main/streams/streams.c
diff options
context:
space:
mode:
authorSara Golemon <pollita@php.net>2005-04-04 19:34:32 +0000
committerSara Golemon <pollita@php.net>2005-04-04 19:34:32 +0000
commit51852db0df8c8f0b7f594d74c85806ba3b12b69e (patch)
tree5de0924f1cebb43e475224184c83a8bf66685f09 /main/streams/streams.c
parent760439567ad05beda0ec990daeaf09e2985db44f (diff)
downloadphp-git-51852db0df8c8f0b7f594d74c85806ba3b12b69e.tar.gz
BugFix #32563
This could have been done in stream_wrapper_register() without introducing the slight performance hit on wrapper registration since anyone registering a wrapper in an extension should know better. The important thing is that since locate_wrapper makes the assumption that all schemes will be /^[a-z0-9+.-]+$/i Anything which registers them should make the same assumption as well.
Diffstat (limited to 'main/streams/streams.c')
-rwxr-xr-xmain/streams/streams.c26
1 files changed, 24 insertions, 2 deletions
diff --git a/main/streams/streams.c b/main/streams/streams.c
index 066662c9b6..1e326f2208 100755
--- a/main/streams/streams.c
+++ b/main/streams/streams.c
@@ -1410,7 +1410,18 @@ int php_shutdown_stream_wrappers(int module_number TSRMLS_DC)
/* API for registering GLOBAL wrappers */
PHPAPI int php_register_url_stream_wrapper(char *protocol, php_stream_wrapper *wrapper TSRMLS_DC)
{
- return zend_hash_add(&url_stream_wrappers_hash, protocol, strlen(protocol), wrapper, sizeof(*wrapper), NULL);
+ int i, protocol_len = strlen(protocol);
+
+ for(i = 0; i < protocol_len; i++) {
+ if (!isalnum((int)protocol[i]) &&
+ protocol[i] != '+' &&
+ protocol[i] != '-' &&
+ protocol[i] != '.') {
+ return FAILURE;
+ }
+ }
+
+ return zend_hash_add(&url_stream_wrappers_hash, protocol, protocol_len, wrapper, sizeof(*wrapper), NULL);
}
PHPAPI int php_unregister_url_stream_wrapper(char *protocol TSRMLS_DC)
@@ -1421,6 +1432,17 @@ PHPAPI int php_unregister_url_stream_wrapper(char *protocol TSRMLS_DC)
/* API for registering VOLATILE wrappers */
PHPAPI int php_register_url_stream_wrapper_volatile(char *protocol, php_stream_wrapper *wrapper TSRMLS_DC)
{
+ int i, protocol_len = strlen(protocol);
+
+ for(i = 0; i < protocol_len; i++) {
+ if (!isalnum((int)protocol[i]) &&
+ protocol[i] != '+' &&
+ protocol[i] != '-' &&
+ protocol[i] != '.') {
+ return FAILURE;
+ }
+ }
+
if (!FG(stream_wrappers)) {
php_stream_wrapper tmpwrapper;
@@ -1429,7 +1451,7 @@ PHPAPI int php_register_url_stream_wrapper_volatile(char *protocol, php_stream_w
zend_hash_copy(FG(stream_wrappers), &url_stream_wrappers_hash, NULL, &tmpwrapper, sizeof(php_stream_wrapper));
}
- return zend_hash_add(FG(stream_wrappers), protocol, strlen(protocol), wrapper, sizeof(*wrapper), NULL);
+ return zend_hash_add(FG(stream_wrappers), protocol, protocol_len, wrapper, sizeof(*wrapper), NULL);
}
PHPAPI int php_unregister_url_stream_wrapper_volatile(char *protocol TSRMLS_DC)