Skip to content

Commit ab9a9a6

Browse files
committed
Disallow PHP startup, in case some ext ext/standard sub-module is not initialized sucessfully.
1 parent 2baae68 commit ab9a9a6

File tree

1 file changed

+6
-25
lines changed

1 file changed

+6
-25
lines changed

ext/standard/basic_functions.c

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,6 @@ typedef struct _user_tick_function_entry {
123123
static void user_shutdown_function_dtor(zval *zv);
124124
static void user_tick_function_dtor(user_tick_function_entry *tick_function_entry);
125125

126-
static HashTable basic_submodules;
127-
128126
#undef sprintf
129127

130128
/* {{{ arginfo */
@@ -3579,32 +3577,21 @@ PHPAPI double php_get_inf(void) /* {{{ */
35793577
/* }}} */
35803578

35813579
#define BASIC_MINIT_SUBMODULE(module) \
3582-
if (PHP_MINIT(module)(INIT_FUNC_ARGS_PASSTHRU) == SUCCESS) {\
3583-
BASIC_ADD_SUBMODULE(module); \
3580+
if (PHP_MINIT(module)(INIT_FUNC_ARGS_PASSTHRU) != SUCCESS) {\
3581+
return FAILURE; \
35843582
}
35853583

3586-
#define BASIC_ADD_SUBMODULE(module) \
3587-
zend_hash_str_add_empty_element(&basic_submodules, #module, strlen(#module));
3588-
35893584
#define BASIC_RINIT_SUBMODULE(module) \
3590-
if (zend_hash_str_exists(&basic_submodules, #module, strlen(#module))) { \
3591-
PHP_RINIT(module)(INIT_FUNC_ARGS_PASSTHRU); \
3592-
}
3585+
PHP_RINIT(module)(INIT_FUNC_ARGS_PASSTHRU);
35933586

35943587
#define BASIC_MINFO_SUBMODULE(module) \
3595-
if (zend_hash_str_exists(&basic_submodules, #module, strlen(#module))) { \
3596-
PHP_MINFO(module)(ZEND_MODULE_INFO_FUNC_ARGS_PASSTHRU); \
3597-
}
3588+
PHP_MINFO(module)(ZEND_MODULE_INFO_FUNC_ARGS_PASSTHRU);
35983589

35993590
#define BASIC_RSHUTDOWN_SUBMODULE(module) \
3600-
if (zend_hash_str_exists(&basic_submodules, #module, strlen(#module))) { \
3601-
PHP_RSHUTDOWN(module)(SHUTDOWN_FUNC_ARGS_PASSTHRU); \
3602-
}
3591+
PHP_RSHUTDOWN(module)(SHUTDOWN_FUNC_ARGS_PASSTHRU);
36033592

36043593
#define BASIC_MSHUTDOWN_SUBMODULE(module) \
3605-
if (zend_hash_str_exists(&basic_submodules, #module, strlen(#module))) { \
3606-
PHP_MSHUTDOWN(module)(SHUTDOWN_FUNC_ARGS_PASSTHRU); \
3607-
}
3594+
PHP_MSHUTDOWN(module)(SHUTDOWN_FUNC_ARGS_PASSTHRU);
36083595

36093596
PHP_MINIT_FUNCTION(basic) /* {{{ */
36103597
{
@@ -3620,8 +3607,6 @@ PHP_MINIT_FUNCTION(basic) /* {{{ */
36203607
#endif
36213608
#endif
36223609

3623-
zend_hash_init(&basic_submodules, 0, NULL, NULL, 1);
3624-
36253610
BG(incomplete_class) = incomplete_class_entry = php_create_incomplete_class();
36263611

36273612
REGISTER_LONG_CONSTANT("CONNECTION_ABORTED", PHP_CONNECTION_ABORTED, CONST_CS | CONST_PERSISTENT);
@@ -3682,9 +3667,6 @@ PHP_MINIT_FUNCTION(basic) /* {{{ */
36823667
register_html_constants(INIT_FUNC_ARGS_PASSTHRU);
36833668
register_string_constants(INIT_FUNC_ARGS_PASSTHRU);
36843669

3685-
BASIC_ADD_SUBMODULE(dl)
3686-
BASIC_ADD_SUBMODULE(mail)
3687-
BASIC_ADD_SUBMODULE(streams)
36883670
BASIC_MINIT_SUBMODULE(file)
36893671
BASIC_MINIT_SUBMODULE(pack)
36903672
BASIC_MINIT_SUBMODULE(browscap)
@@ -3784,7 +3766,6 @@ PHP_MSHUTDOWN_FUNCTION(basic) /* {{{ */
37843766
BASIC_MSHUTDOWN_SUBMODULE(random)
37853767
BASIC_MSHUTDOWN_SUBMODULE(password)
37863768

3787-
zend_hash_destroy(&basic_submodules);
37883769
return SUCCESS;
37893770
}
37903771
/* }}} */

0 commit comments

Comments
 (0)