]> granicus.if.org Git - php/commitdiff
Allow disabling of functions for security reasons
authorZeev Suraski <zeev@php.net>
Mon, 29 May 2000 17:16:52 +0000 (17:16 +0000)
committerZeev Suraski <zeev@php.net>
Mon, 29 May 2000 17:16:52 +0000 (17:16 +0000)
Zend/zend_API.c
Zend/zend_API.h

index 7d4b95c870cffde86efe111519c1ef7dbdbcb4d2..8cb751d066b071c65f1130db54c6b71d515ed637 100644 (file)
@@ -925,3 +925,31 @@ ZEND_API int zend_set_hash_symbol(zval *symbol, char *name, int name_length,
     va_end(symbol_table_list);
     return SUCCESS;
 }
+
+
+
+
+/* Disabled functions support */
+
+static ZEND_FUNCTION(display_disabled_function)
+{
+       zend_error(E_WARNING, "%s() has been disabled for security reasons.", get_active_function_name());
+}
+
+
+static zend_function_entry disabled_function[] =  {
+       ZEND_FE(display_disabled_function,                      NULL)
+       { NULL, NULL, NULL }
+};
+
+
+ZEND_API int zend_disable_function(char *function_name, uint function_name_length)
+{
+       CLS_FETCH();
+
+       if (zend_hash_del(CG(function_table), function_name, function_name_length+1)==FAILURE) {
+               return FAILURE;
+       }
+       disabled_function[0].fname = function_name;
+       return zend_register_functions(disabled_function, CG(function_table));
+}
\ No newline at end of file
index daab74a0a31d10e43c0a17a46925c54ac348adb0..9a19bf21e6a7adab8172e94d9e495020e36d5f5a 100644 (file)
@@ -113,6 +113,7 @@ void zend_unregister_functions(zend_function_entry *functions, int count, HashTa
 ZEND_API int zend_register_module(zend_module_entry *module_entry);
 ZEND_API zend_class_entry *register_internal_class(zend_class_entry *class_entry);
 ZEND_API zend_module_entry *zend_get_module(int module_number);
+ZEND_API int zend_disable_function(char *function_name, uint function_name_length);
 
 ZEND_API void wrong_param_count(void);