com php-src: don't allow conditionals to be executed by eval()'d code: phpdbg.h phpdbg_prompt.c

From: Date: Wed, 13 Nov 2013 14:41:25 +0000
Subject: com php-src: don't allow conditionals to be executed by eval()'d code: phpdbg.h phpdbg_prompt.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-75004@lists.php.net to get a copy of this message
Commit: 072622e799cb5b8632a3933095481b0c3d10f4e7 Author: krakjoe <joe.watkins@live.co.uk> Wed, 13 Nov 2013 14:41:25 +0000 Parents: b81005f94b0d6a8d1c15671c4ceea89e1b725da3 Branches: PHP-5.6 Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=072622e799cb5b8632a3933095481b0c3d10f4e7 Log: don't allow conditionals to be executed by eval()'d code Changed paths: M phpdbg.h M phpdbg_prompt.c Diff: diff --git a/phpdbg.h b/phpdbg.h index 7ebc35a..0730354 100644 --- a/phpdbg.h +++ b/phpdbg.h @@ -74,13 +74,15 @@ #define PHPDBG_HAS_OPLINE_BP 0x000000000100 #define PHPDBG_HAS_METHOD_BP 0x000000001000 #define PHPDBG_HAS_COND_BP 0x000000010000 -#define PHPDBG_IN_COND_BP 0x000000100000 #define PHPDBG_BP_MASK (PHPDBG_HAS_FILE_BP|PHPDBG_HAS_SYM_BP|PHPDBG_HAS_METHOD_BP|PHPDBG_HAS_OPLINE_BP|PHPDBG_HAS_COND_BP) -#define PHPDBG_IS_STEPPING 0x000001000000 -#define PHPDBG_IS_QUIET 0x000010000000 -#define PHPDBG_IS_QUITTING 0x000100000000 -#define PHPDBG_IS_COLOURED 0x001000000000 +#define PHPDBG_IN_COND_BP 0x000000100000 +#define PHPDBG_IN_EVAL 0x000001000000 + +#define PHPDBG_IS_STEPPING 0x000010000000 +#define PHPDBG_IS_QUIET 0x000100000000 +#define PHPDBG_IS_QUITTING 0x001000000000 +#define PHPDBG_IS_COLOURED 0x010000000000 #define PHPDBG_DEFAULT_FLAGS (PHPDBG_IS_QUIET|PHPDBG_IS_COLOURED) /* }}} */ diff --git a/phpdbg_prompt.c b/phpdbg_prompt.c index e9f220a..d4af165 100644 --- a/phpdbg_prompt.c +++ b/phpdbg_prompt..c @@ -172,16 +172,18 @@ static PHPDBG_COMMAND(eval) /* {{{ */ if (expr_len) { zend_bool stepping = (PHPDBG_G(flags) & PHPDBG_IS_STEPPING); - /* disable stepping while eval() in progress */ PHPDBG_G(flags) &= ~ PHPDBG_IS_STEPPING; - + + /* disable stepping while eval() in progress */ + PHPDBG_G(flags) |= PHPDBG_IN_EVAL; if (zend_eval_stringl((char*)expr, expr_len, &retval, "eval()'d code" TSRMLS_CC) == SUCCESS) { zend_print_zval_r(&retval, 0 TSRMLS_CC); zval_dtor(&retval); phpdbg_writeln(EMPTY); } - + PHPDBG_G(flags) &= ~PHPDBG_IN_EVAL; + /* switch stepping back on */ if (stepping) { PHPDBG_G(flags) |= PHPDBG_IS_STEPPING; @@ -689,30 +691,29 @@ zend_vm_enter: } #endif +#define DO_INTERACTIVE() do {\ + switch (phpdbg_interactive(TSRMLS_C)) {\ + case PHPDBG_NEXT:\ + goto next;\ + }\ +} while(!(PHPDBG_G(flags) & PHPDBG_IS_QUITTING)) + phpdbg_print_opline( execute_data, 0 TSRMLS_CC); /* allow conditional breakpoints to access the vm uninterrupted */ if (!(PHPDBG_G(flags) & PHPDBG_IN_COND_BP)) { - if ((PHPDBG_G(flags) & PHPDBG_HAS_COND_BP) + /* conditions cannot be executed by eval()'d code */ + if (!(PHPDBG_G(flags) & PHPDBG_IN_EVAL) + && (PHPDBG_G(flags) & PHPDBG_HAS_COND_BP) && phpdbg_find_conditional_breakpoint(TSRMLS_C) == SUCCESS) { - do { - switch (phpdbg_interactive(TSRMLS_C)) { - case PHPDBG_NEXT: - goto next; - } - } while(!(PHPDBG_G(flags) & PHPDBG_IS_QUITTING)); + DO_INTERACTIVE(); } if ((PHPDBG_G(flags) & PHPDBG_HAS_FILE_BP) && phpdbg_find_breakpoint_file(execute_data->op_array TSRMLS_CC) == SUCCESS) { - do { - switch (phpdbg_interactive(TSRMLS_C)) { - case PHPDBG_NEXT: - goto next; - } - } while(!(PHPDBG_G(flags) & PHPDBG_IS_QUITTING)); + DO_INTERACTIVE(); } if ((PHPDBG_G(flags) & (PHPDBG_HAS_METHOD_BP|PHPDBG_HAS_SYM_BP))) { @@ -725,12 +726,7 @@ zend_vm_enter: case ZEND_DO_FCALL_BY_NAME: case ZEND_INIT_STATIC_METHOD_CALL: { if (phpdbg_find_breakpoint_symbol(previous->function_state.function TSRMLS_CC) == SUCCESS) { - do { - switch (phpdbg_interactive(TSRMLS_C)) { - case PHPDBG_NEXT: - goto next; - } - } while(!(PHPDBG_G(flags) & PHPDBG_IS_QUITTING)); + DO_INTERACTIVE(); } } break; } @@ -740,12 +736,7 @@ zend_vm_enter: if ((PHPDBG_G(flags) & PHPDBG_HAS_OPLINE_BP) && phpdbg_find_breakpoint_opline(execute_data->opline TSRMLS_CC) == SUCCESS) { - do { - switch (phpdbg_interactive(TSRMLS_C)) { - case PHPDBG_NEXT: - goto next; - } - } while(!(PHPDBG_G(flags) & PHPDBG_IS_QUITTING)); + DO_INTERACTIVE(); } } @@ -754,11 +745,7 @@ next: if (!(PHPDBG_G(flags) & PHPDBG_IN_COND_BP)) { if ((PHPDBG_G(flags) & PHPDBG_IS_STEPPING)) { - while (phpdbg_interactive(TSRMLS_C) != PHPDBG_NEXT) { - if (!(PHPDBG_G(flags) & PHPDBG_IS_QUITTING)) { - continue; - } - } + DO_INTERACTIVE(); } }

« previous php.cvs (#75004) next »