pollita         Mon Apr  4 15:34:33 2005 EDT

  Modified files:              
    /php-src/main/streams       streams.c 
  Log:
  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.
  
  
http://cvs.php.net/diff.php/php-src/main/streams/streams.c?r1=1.71&r2=1.72&ty=u
Index: php-src/main/streams/streams.c
diff -u php-src/main/streams/streams.c:1.71 php-src/main/streams/streams.c:1.72
--- php-src/main/streams/streams.c:1.71 Mon Feb 21 19:24:13 2005
+++ php-src/main/streams/streams.c      Mon Apr  4 15:34:32 2005
@@ -19,7 +19,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: streams.c,v 1.71 2005/02/22 00:24:13 iliaa Exp $ */
+/* $Id: streams.c,v 1.72 2005/04/04 19:34:32 pollita Exp $ */
 
 #define _GNU_SOURCE
 #include "php.h"
@@ -1410,7 +1410,18 @@
 /* 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 @@
 /* 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 @@
                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)


-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to