summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorSascha Schumann <sas@php.net>1999-09-03 17:46:39 +0000
committerSascha Schumann <sas@php.net>1999-09-03 17:46:39 +0000
commit5b293ecd4dcd22a391784a88cead34d810e7eac7 (patch)
tree368e68e3f30932d16012778b301c2c78fbf5e46a /main
parent690575e51f1866e00074411aae18f98d76cfdf26 (diff)
downloadphp-git-5b293ecd4dcd22a391784a88cead34d810e7eac7.tar.gz
- add global startup/shutdown handlers
- improve genif.sh to also consider all header files for inclusion (checks for phpext_) - use vsnprintf in main.c to avoid buffer overflows - improve sessions's mm module to cope better with OOM situations within the shared memory segment - fix typo wrt session.auto_start
Diffstat (limited to 'main')
-rw-r--r--main/SAPI.c4
-rw-r--r--main/internal_functions.c.in33
-rw-r--r--main/main.c2
-rw-r--r--main/php.h16
4 files changed, 46 insertions, 9 deletions
diff --git a/main/SAPI.c b/main/SAPI.c
index 87fe3dd902..be6a2d5bb3 100644
--- a/main/SAPI.c
+++ b/main/SAPI.c
@@ -75,11 +75,13 @@ SAPI_API void sapi_startup(sapi_module_struct *sf)
#ifdef ZTS
sapi_globals_id = ts_allocate_id(sizeof(sapi_globals_struct), NULL, NULL);
#endif
-}
+ module_global_startup_modules();
+}
SAPI_API void sapi_shutdown()
{
+ module_global_shutdown_modules();
zend_hash_destroy(&known_post_content_types);
}
diff --git a/main/internal_functions.c.in b/main/internal_functions.c.in
index d63679b52d..4f3ec7fac2 100644
--- a/main/internal_functions.c.in
+++ b/main/internal_functions.c.in
@@ -80,7 +80,7 @@ zend_module_entry *php3_builtin_modules[] = {
@EXT_MODULE_PTRS@
};
-
+
int module_startup_modules(void)
{
zend_module_entry **ptr = php3_builtin_modules, **end = ptr+(sizeof(php3_builtin_modules)/sizeof(zend_module_entry *));
@@ -96,6 +96,37 @@ int module_startup_modules(void)
return SUCCESS;
}
+int module_global_startup_modules(void)
+{
+ zend_module_entry **ptr = php3_builtin_modules, **end = ptr+(sizeof(php3_builtin_modules)/sizeof(zend_module_entry *));
+
+ while (ptr < end) {
+ if (*ptr) {
+ if ((*ptr)->global_startup_func &&
+ (*ptr)->global_startup_func()==FAILURE) {
+ return FAILURE;
+ }
+ }
+ ptr++;
+ }
+ return SUCCESS;
+}
+
+int module_global_shutdown_modules(void)
+{
+ zend_module_entry **ptr = php3_builtin_modules, **end = ptr+(sizeof(php3_builtin_modules)/sizeof(zend_module_entry *));
+
+ while (ptr < end) {
+ if (*ptr) {
+ if ((*ptr)->global_shutdown_func &&
+ (*ptr)->global_shutdown_func()==FAILURE) {
+ return FAILURE;
+ }
+ }
+ ptr++;
+ }
+ return SUCCESS;
+}
/*
* Local variables:
diff --git a/main/main.c b/main/main.c
index ac95c88a13..f778212c07 100644
--- a/main/main.c
+++ b/main/main.c
@@ -325,7 +325,7 @@ PHPAPI int php_printf(const char *format,...)
int size;
va_start(args, format);
- size = vsprintf(buffer, format, args);
+ size = vsnprintf(buffer, sizeof(buffer), format, args);
ret = PHPWRITE(buffer, size);
va_end(args);
diff --git a/main/php.h b/main/php.h
index 49966d2a9c..99746fb11f 100644
--- a/main/php.h
+++ b/main/php.h
@@ -259,12 +259,16 @@ extern int ap_vsnprintf(char *, size_t, const char *, va_list);
#define PHP_RINIT(module) php3_rinit_##module
#define PHP_RSHUTDOWN(module) php3_rshutdown_##module
#define PHP_MINFO(module) php3_info_##module
-
-#define PHP_MINIT_FUNCTION(module) int php3_minit_##module(INIT_FUNC_ARGS)
-#define PHP_MSHUTDOWN_FUNCTION(module) int php3_mshutdown_##module(SHUTDOWN_FUNC_ARGS)
-#define PHP_RINIT_FUNCTION(module) int php3_rinit_##module(INIT_FUNC_ARGS)
-#define PHP_RSHUTDOWN_FUNCTION(module) int php3_rshutdown_##module(SHUTDOWN_FUNC_ARGS)
-#define PHP_MINFO_FUNCTION(module) void php3_info_##module(ZEND_MODULE_INFO_FUNC_ARGS)
+#define PHP_GINIT(module) php3_ginit_##module
+#define PHP_GSHUTDOWN(module) php3_gshutdown_##module
+
+#define PHP_MINIT_FUNCTION(module) int PHP_MINIT(module)(INIT_FUNC_ARGS)
+#define PHP_MSHUTDOWN_FUNCTION(module) int PHP_MSHUTDOWN(module)(SHUTDOWN_FUNC_ARGS)
+#define PHP_RINIT_FUNCTION(module) int PHP_RINIT(module)(INIT_FUNC_ARGS)
+#define PHP_RSHUTDOWN_FUNCTION(module) int PHP_RSHUTDOWN(module)(SHUTDOWN_FUNC_ARGS)
+#define PHP_MINFO_FUNCTION(module) void PHP_MINFO(module)(ZEND_MODULE_INFO_FUNC_ARGS)
+#define PHP_GINIT_FUNCTION(module) static int PHP_GINIT(module)(void)
+#define PHP_GSHUTDOWN_FUNCTION(module) static int PHP_GSHUTDOWN(module)(void)
/* global variables */