cvs: ZendEngine2 / zend_API.c zend_API.h

From: Date: Mon, 03 Mar 2003 01:22:43 +0000
Subject: cvs: ZendEngine2 / zend_API.c zend_API.h
Groups: php.zend-engine.cvs 
Request: Send a blank email to php-zend-engine-cvs+get-985@lists.php.net to get a copy of this message
phanto Sun Mar 2 20:22:43 2003 EDT Modified files: /ZendEngine2 zend_API.c zend_API.h Log: commiting zend_disable_class patch for George: disabled classes will be replaced by dummy classes that print a warning upon instanciation Index: ZendEngine2/zend_API.c diff -u ZendEngine2/zend_API.c:1.154 ZendEngine2/zend_API.c:1.155 --- ZendEngine2/zend_API.c:1.154 Sun Feb 16 06:34:49 2003 +++ ZendEngine2/zend_API.c Sun Mar 2 20:22:43 2003 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_API.c,v 1.154 2003/02/16 11:34:49 sebastian Exp $ */ +/* $Id: zend_API.c,v 1.155 2003/03/03 01:22:43 phanto Exp $ */ #include "zend.h" #include "zend_execute.h" @@ -1417,6 +1417,34 @@ } disabled_function[0].fname = function_name; return zend_register_functions(NULL, disabled_function, CG(function_table), MODULE_PERSISTENT TSRMLS_CC); +} + +static zend_object_value display_disabled_class(zend_class_entry *class_type TSRMLS_DC) +{ + zend_object_value retval; + zend_object *intern; + retval = zend_objects_new(&intern, class_type); + ALLOC_HASHTABLE(intern->properties); + zend_hash_init(intern->properties, 0, NULL, ZVAL_PTR_DTOR, 0); + zend_error(E_WARNING, "%s() has been disabled for security reasons", class_type->name); + return retval; +} + +static zend_function_entry disabled_class_new[] = { + { NULL, NULL, NULL } +}; + +ZEND_API int zend_disable_class(char *class_name, uint class_name_length TSRMLS_DC) +{ + zend_class_entry *disabled_class; + disabled_class = (zend_class_entry *) emalloc(sizeof(zend_class_entry)); + if (zend_hash_del(CG(class_table), class_name, class_name_length+1)==FAILURE) { + return FAILURE; + } + INIT_CLASS_ENTRY((*disabled_class), class_name, disabled_class_new); + disabled_class->create_object = display_disabled_class; + zend_register_internal_class(disabled_class TSRMLS_CC); + return 1; } zend_bool zend_is_callable(zval *callable, zend_bool syntax_only, char **callable_name) Index: ZendEngine2/zend_API.h diff -u ZendEngine2/zend_API.h:1.130 ZendEngine2/zend_API.h:1.131 --- ZendEngine2/zend_API.h:1.130 Wed Feb 12 11:50:51 2003 +++ ZendEngine2/zend_API.h Sun Mar 2 20:22:43 2003 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_API.h,v 1.130 2003/02/12 16:50:51 iliaa Exp $ */ +/* $Id: zend_API.h,v 1.131 2003/03/03 01:22:43 phanto Exp $ */ #ifndef ZEND_API_H #define ZEND_API_H @@ -90,7 +90,7 @@ #define INIT_OVERLOADED_CLASS_ENTRY(class_container, class_name, functions, handle_fcall, handle_propget, handle_propset) \ { \ class_container.name = strdup(class_name); \ - class_container.name_length = sizeof(class_name)-1; \ + class_container.name_length = strlen(class_name); \ class_container.builtin_functions = functions; \ class_container.constructor = NULL; \ class_container.destructor = NULL; \ @@ -136,6 +136,7 @@ ZEND_API zend_class_entry *zend_register_internal_class_ex(zend_class_entry *class_entry, zend_class_entry *parent_ce, char *parent_name TSRMLS_DC); ZEND_API int zend_disable_function(char *function_name, uint function_name_length TSRMLS_DC); +ZEND_API int zend_disable_class(char *class_name, uint class_name_length TSRMLS_DC); ZEND_API void zend_wrong_param_count(TSRMLS_D); ZEND_API zend_bool zend_is_callable(zval *callable, zend_bool syntax_only, char **callable_name); @@ -250,6 +251,7 @@ #define add_method(arg, key, method) add_assoc_function((arg), (key), (method)) ZEND_API ZEND_FUNCTION(display_disabled_function); +ZEND_API ZEND_FUNCTION(display_disabled_class); #if ZEND_DEBUG #define CHECK_ZVAL_STRING(z) \

« previous php.zend-engine.cvs (#985) next »