From c8706331b5511397bee28c676d98672383222f2f Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Mon, 20 Jun 2016 14:58:42 +0300 Subject: Cleanup zend_signal API --- sapi/phpdbg/phpdbg.c | 6 ------ 1 file changed, 6 deletions(-) (limited to 'sapi/phpdbg/phpdbg.c') diff --git a/sapi/phpdbg/phpdbg.c b/sapi/phpdbg/phpdbg.c index 68a164c499..e72b543a42 100644 --- a/sapi/phpdbg/phpdbg.c +++ b/sapi/phpdbg/phpdbg.c @@ -1241,11 +1241,7 @@ void phpdbg_signal_handler(int sig, siginfo_t *info, void *context) /* {{{ */ } is_handled = phpdbg_watchpoint_segfault_handler(info, context); if (is_handled == FAILURE) { -#ifdef ZEND_SIGNALS zend_sigaction(sig, &PHPDBG_G(old_sigsegv_signal), NULL); -#else - sigaction(sig, &PHPDBG_G(old_sigsegv_signal), NULL); -#endif } break; } @@ -1342,9 +1338,7 @@ int main(int argc, char **argv) /* {{{ */ ZEND_TSRMLS_CACHE_UPDATE(); #endif -#ifdef ZEND_SIGNALS zend_signal_startup(); -#endif phpdbg_main: ini_entries = NULL; -- cgit v1.2.1 From c22a1c83f3421683b8386564d44cc1a10e4e93bd Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Mon, 20 Jun 2016 19:19:16 +0300 Subject: Zend signals should be installed after request startup (or regular signals may be installed before zend_signal_startup) --- sapi/phpdbg/phpdbg.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'sapi/phpdbg/phpdbg.c') diff --git a/sapi/phpdbg/phpdbg.c b/sapi/phpdbg/phpdbg.c index e72b543a42..0a45882251 100644 --- a/sapi/phpdbg/phpdbg.c +++ b/sapi/phpdbg/phpdbg.c @@ -1657,14 +1657,6 @@ phpdbg_main: } zend_end_try(); #endif -#if defined(ZEND_SIGNALS) && !defined(_WIN32) - zend_try { zend_sigaction(SIGSEGV, &signal_struct, &PHPDBG_G(old_sigsegv_signal)); } zend_end_try(); - zend_try { zend_sigaction(SIGBUS, &signal_struct, &PHPDBG_G(old_sigsegv_signal)); } zend_end_try(); -#elif !defined(_WIN32) - sigaction(SIGSEGV, &signal_struct, &PHPDBG_G(old_sigsegv_signal)); - sigaction(SIGBUS, &signal_struct, &PHPDBG_G(old_sigsegv_signal)); -#endif - PHPDBG_G(sapi_name_ptr) = sapi_name; if (exec) { /* set execution context */ @@ -1701,6 +1693,14 @@ phpdbg_main: return 1; } +#if defined(ZEND_SIGNALS) && !defined(_WIN32) + zend_try { zend_sigaction(SIGSEGV, &signal_struct, &PHPDBG_G(old_sigsegv_signal)); } zend_end_try(); + zend_try { zend_sigaction(SIGBUS, &signal_struct, &PHPDBG_G(old_sigsegv_signal)); } zend_end_try(); +#elif !defined(_WIN32) + sigaction(SIGSEGV, &signal_struct, &PHPDBG_G(old_sigsegv_signal)); + sigaction(SIGBUS, &signal_struct, &PHPDBG_G(old_sigsegv_signal)); +#endif + /* do not install sigint handlers for remote consoles */ /* sending SIGINT then provides a decent way of shutting down the server */ #ifndef _WIN32 -- cgit v1.2.1 From 85e985f191c228cb6b119ebe223d682c9166fdc2 Mon Sep 17 00:00:00 2001 From: David Carlier Date: Mon, 27 Jun 2016 07:42:49 +0100 Subject: couple of resource leaks fixes and use after free's --- sapi/phpdbg/phpdbg.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'sapi/phpdbg/phpdbg.c') diff --git a/sapi/phpdbg/phpdbg.c b/sapi/phpdbg/phpdbg.c index 0a45882251..ecd3f3974e 100644 --- a/sapi/phpdbg/phpdbg.c +++ b/sapi/phpdbg/phpdbg.c @@ -1433,6 +1433,7 @@ phpdbg_main: case 'i': { /* set init file */ if (init_file) { free(init_file); + init_file = NULL; } init_file_len = strlen(php_optarg); @@ -1786,7 +1787,9 @@ phpdbg_main: /* initialize from file */ PHPDBG_G(flags) |= PHPDBG_IS_INITIALIZING; zend_try { - phpdbg_init(init_file, init_file_len, init_file_default); + if (init_file) { + phpdbg_init(init_file, init_file_len, init_file_default); + } if (bp_tmp) { PHPDBG_G(flags) |= PHPDBG_DISCARD_OUTPUT; phpdbg_string_init(bp_tmp); -- cgit v1.2.1