From a4d454fdcfce38d9c4d15907588bc6780012098e Mon Sep 17 00:00:00 2001 From: Sara Golemon Date: Mon, 4 Apr 2005 20:26:49 +0000 Subject: [PATCH] MFH rev 1.72 (of main/streams/streams.c) --- main/streams.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/main/streams.c b/main/streams.c index ebc76c3345..666e3aac8a 100755 --- a/main/streams.c +++ b/main/streams.c @@ -2349,7 +2349,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) @@ -2360,6 +2371,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; @@ -2368,7 +2390,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); } /* }}} */ -- 2.50.1