From a58c74f1c7f46a0dbdcbe9d1211902a4a8c755cf Mon Sep 17 00:00:00 2001 From: krakjoe Date: Sun, 2 Feb 2014 13:43:43 +0000 Subject: remove use of zend directly, avoid leaks/bugs in modules etc --- sapi/phpdbg/phpdbg.c | 43 +++++++++---------------------------------- 1 file changed, 9 insertions(+), 34 deletions(-) (limited to 'sapi/phpdbg/phpdbg.c') diff --git a/sapi/phpdbg/phpdbg.c b/sapi/phpdbg/phpdbg.c index e7f841c0bc..7c94ac19dd 100644 --- a/sapi/phpdbg/phpdbg.c +++ b/sapi/phpdbg/phpdbg.c @@ -872,6 +872,7 @@ int main(int argc, char **argv) /* {{{ */ phpdbg_main: if (!cleaning) { bp_tmp_file = malloc(L_tmpnam); + tmpnam(bp_tmp_file); if (bp_tmp_file == NULL) { phpdbg_error("Unable to create temporary file"); @@ -1117,8 +1118,7 @@ phpdbg_main: phpdbg->ini_entries = ini_entries; if (phpdbg->startup(phpdbg) == SUCCESS) { - - zend_activate(TSRMLS_C); + php_request_startup(TSRMLS_C); /* do not install sigint handlers for remote consoles */ /* sending SIGINT then provides a decent way of shutting down the server */ @@ -1186,20 +1186,11 @@ phpdbg_main: /* set default prompt */ phpdbg_set_prompt(PROMPT TSRMLS_CC); - zend_try { - zend_activate_modules(TSRMLS_C); - } zend_end_try(); - if (show_banner) { /* print blurb */ phpdbg_welcome((cleaning > 0) TSRMLS_CC); } - zend_try { - /* activate globals, they can be overwritten */ - zend_activate_auto_globals(TSRMLS_C); - } zend_end_try(); - /* initialize from file */ PHPDBG_G(flags) |= PHPDBG_IS_INITIALIZING; zend_try { @@ -1269,12 +1260,6 @@ phpdbg_interact: } zend_end_try(); } while(!cleaning && !(PHPDBG_G(flags) & PHPDBG_IS_QUITTING)); - /* this must be forced */ - CG(unclean_shutdown) = 0; - - /* this is just helpful */ - PG(report_memleaks) = 0; - phpdbg_out: #ifndef _WIN32 if ((PHPDBG_G(flags) & PHPDBG_IS_DISCONNECTED)) { @@ -1297,24 +1282,14 @@ phpdbg_out: if (ini_override) { free(ini_override); } + + /* this must be forced */ + CG(unclean_shutdown) = 0; + + /* this is just helpful */ + PG(report_memleaks) = 0; - if (PG(modules_activated)) { - zend_try { - zend_deactivate_modules(TSRMLS_C); - } zend_end_try(); - } - - zend_deactivate(TSRMLS_C); - - zend_try { - zend_post_deactivate_modules(TSRMLS_C); - } zend_end_try(); - -#ifdef ZEND_SIGNALS - zend_try { - zend_signal_deactivate(TSRMLS_C); - } zend_end_try(); -#endif + php_request_shutdown((void*)0); zend_try { php_module_shutdown(TSRMLS_C); -- cgit v1.2.1 From 9e84124e2dba2fc652abce076d5d1bbac9ed13bd Mon Sep 17 00:00:00 2001 From: krakjoe Date: Sun, 2 Feb 2014 14:42:31 +0000 Subject: better use of tmpnam/mkstemp --- sapi/phpdbg/phpdbg.c | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) (limited to 'sapi/phpdbg/phpdbg.c') diff --git a/sapi/phpdbg/phpdbg.c b/sapi/phpdbg/phpdbg.c index 7c94ac19dd..9341ad35a5 100644 --- a/sapi/phpdbg/phpdbg.c +++ b/sapi/phpdbg/phpdbg.c @@ -831,7 +831,13 @@ int main(int argc, char **argv) /* {{{ */ zend_bool remote = 0; int run = 0; int step = 0; - char *bp_tmp_file; + +#ifdef _WIN32 + char *bp_tmp_file = NULL; +#else + char bp_tmp_file[] = "/tmp/phpdbg.XXXXXX"; +#endif + #ifndef _WIN32 char *address; int listen[2]; @@ -871,10 +877,23 @@ int main(int argc, char **argv) /* {{{ */ phpdbg_main: if (!cleaning) { + +#ifdef _WIN32 bp_tmp_file = malloc(L_tmpnam); - tmpnam(bp_tmp_file); - if (bp_tmp_file == NULL) { + if (bp_tmp_file) { + if (!tmpnam(bp_tmp_file)) { + free(bp_tmp_file); + bp_tmp_file = NULL; + } + } +#else + if (!mkstemp(bp_tmp_file)) { + memset(bp_tmp_file, 0, sizeof(bp_tmp_file)); + } +#endif + + if (!bp_tmp_file) { phpdbg_error("Unable to create temporary file"); } } @@ -1317,7 +1336,11 @@ phpdbg_out: free(sapi_name); } +#ifdef _WIN32 free(bp_tmp_file); +#else + unlink(bp_tmp_file); +#endif return 0; } /* }}} */ -- cgit v1.2.1 From 6a6bec44add665fc8330eb03161dc36d278ed40d Mon Sep 17 00:00:00 2001 From: krakjoe Date: Sun, 2 Feb 2014 14:50:32 +0000 Subject: woops --- sapi/phpdbg/phpdbg.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'sapi/phpdbg/phpdbg.c') diff --git a/sapi/phpdbg/phpdbg.c b/sapi/phpdbg/phpdbg.c index 9341ad35a5..6cb1645e65 100644 --- a/sapi/phpdbg/phpdbg.c +++ b/sapi/phpdbg/phpdbg.c @@ -892,9 +892,11 @@ phpdbg_main: memset(bp_tmp_file, 0, sizeof(bp_tmp_file)); } #endif - + if (!bp_tmp_file) { - phpdbg_error("Unable to create temporary file"); + phpdbg_error( + "Unable to create temporary file"); + return 1; } } ini_entries = NULL; -- cgit v1.2.1 From ccae70b7650046fd5692a15b7148dac1862a65a3 Mon Sep 17 00:00:00 2001 From: Mateusz Kocielski Date: Tue, 18 Mar 2014 09:51:39 +0100 Subject: Fix phpdbg build on FreeBSD Added missing netinet/in.h header. --- sapi/phpdbg/phpdbg.c | 1 + 1 file changed, 1 insertion(+) (limited to 'sapi/phpdbg/phpdbg.c') diff --git a/sapi/phpdbg/phpdbg.c b/sapi/phpdbg/phpdbg.c index 6cb1645e65..7e0e2bafcd 100644 --- a/sapi/phpdbg/phpdbg.c +++ b/sapi/phpdbg/phpdbg.c @@ -35,6 +35,7 @@ # include # include # include +# include # include # include #endif /* }}} */ -- cgit v1.2.1 From 6c259625c45f4a4137b53a9e3a06677f7c3236ed Mon Sep 17 00:00:00 2001 From: Mateusz Kocielski Date: Tue, 18 Mar 2014 10:49:28 +0100 Subject: Fixed wrong indentation --- sapi/phpdbg/phpdbg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sapi/phpdbg/phpdbg.c') diff --git a/sapi/phpdbg/phpdbg.c b/sapi/phpdbg/phpdbg.c index 7e0e2bafcd..51a328d0b5 100644 --- a/sapi/phpdbg/phpdbg.c +++ b/sapi/phpdbg/phpdbg.c @@ -35,7 +35,7 @@ # include # include # include -# include +# include # include # include #endif /* }}} */ -- cgit v1.2.1