From: Sara Golemon Date: Mon, 4 Apr 2005 19:48:14 +0000 (+0000) Subject: MFH rev 1.72 X-Git-Tag: php-5.0.5RC1~485 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=62eceedcc4617ec13161170f7a7398cb691ccbfb;p=php MFH rev 1.72 --- diff --git a/main/streams/streams.c b/main/streams/streams.c index 701520c2b8..b5a84808f8 100755 --- a/main/streams/streams.c +++ b/main/streams/streams.c @@ -1396,7 +1396,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) @@ -1407,6 +1418,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; @@ -1415,7 +1437,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); } /* }}} */