cvs: Zend / zend_API.c zend_API.h zend_builtin_functions.c

From: Date: Tue, 10 Sep 2002 15:33:45 +0000
Subject: cvs: Zend / zend_API.c zend_API.h zend_builtin_functions.c
Groups: php.zend-engine.cvs 
Request: Send a blank email to php-zend-engine-cvs+get-418@lists.php.net to get a copy of this message
andrei Tue Sep 10 11:33:45 2002 EDT Modified files: /Zend zend_API.c zend_API.h zend_builtin_functions.c Log: Make function_exists() respect disabled functions. Index: Zend/zend_API.c diff -u Zend/zend_API.c:1.110 Zend/zend_API.c:1.111 --- Zend/zend_API.c:1.110 Wed Apr 24 07:19:20 2002 +++ Zend/zend_API.c Tue Sep 10 11:33:44 2002 @@ -1270,7 +1270,7 @@ /* Disabled functions support */ -static ZEND_FUNCTION(display_disabled_function) +ZEND_API ZEND_FUNCTION(display_disabled_function) { zend_error(E_WARNING, "%s() has been disabled for security reasons", get_active_function_name(TSRMLS_C)); } Index: Zend/zend_API.h diff -u Zend/zend_API.h:1.112 Zend/zend_API.h:1.113 --- Zend/zend_API.h:1.112 Mon May 20 03:16:42 2002 +++ Zend/zend_API.h Tue Sep 10 11:33:45 2002 @@ -248,6 +248,8 @@ #define add_method(arg, key, method) add_assoc_function((arg), (key), (method)) +ZEND_API ZEND_FUNCTION(display_disabled_function); + #if ZEND_DEBUG #define CHECK_ZVAL_STRING(z) \ if ((z)->value.str.val[ (z)->value.str.len ] != '\0') zend_error(E_WARNING, "String is not zero-terminated (%s)", (z)->value.str.val); Index: Zend/zend_builtin_functions.c diff -u Zend/zend_builtin_functions.c:1.120 Zend/zend_builtin_functions.c:1.121 --- Zend/zend_builtin_functions.c:1.120 Tue Sep 3 10:42:03 2002 +++ Zend/zend_builtin_functions.c Tue Sep 10 11:33:45 2002 @@ -742,8 +742,9 @@ ZEND_FUNCTION(function_exists) { zval **function_name; + zend_function *func; char *lcname; - int retval; + zend_bool retval; if (ZEND_NUM_ARGS()!=1 || zend_get_parameters_ex(1, &function_name)==FAILURE) { ZEND_WRONG_PARAM_COUNT(); @@ -752,8 +753,17 @@ lcname = estrndup((*function_name)->value.str.val, (*function_name)->value.str.len); zend_str_tolower(lcname, (*function_name)->value.str.len); - retval = zend_hash_exists(EG(function_table), lcname, (*function_name)->value.str.len+1); + retval = (zend_hash_find(EG(function_table), lcname, (*function_name)->value.str.len+1, (void **)&func) == SUCCESS); efree(lcname); + + /* + * A bit of a hack, but not a bad one: we see if the handler of the function + * is actually one that displays "function is disabled" message. + */ + if (retval && + func->internal_function.handler == zif_display_disabled_function) { + retval = 0; + } RETURN_BOOL(retval); }

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