summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Fuhrmannek2015-01-22 12:19:09 +0100
committerBen Fuhrmannek2015-01-22 12:19:09 +0100
commit432e8f9ab8a3029b16e03676aa643f3788faf14c (patch)
tree27e99ec0af706b4820c4d9472a01dff4c4bea5eb
parent8affcacdbeba5fd95e1b26a6bcfc9c3030a1d893 (diff)
removed #ifdef ZEND_ENGINE_2 as it is always defined anyway
-rw-r--r--ex_imp.c4
-rw-r--r--execute.c43
-rw-r--r--ifilter.c6
-rw-r--r--log.c13
-rw-r--r--php_suhosin.h7
5 files changed, 4 insertions, 69 deletions
diff --git a/ex_imp.c b/ex_imp.c
index 1c01191..a46eb43 100644
--- a/ex_imp.c
+++ b/ex_imp.c
@@ -263,11 +263,7 @@ void suhosin_hook_ex_imp(TSRMLS_D)
263{ 263{
264 /* replace the extract and import_request_variables functions */ 264 /* replace the extract and import_request_variables functions */
265 zend_hash_del(CG(function_table), "extract", sizeof("extract")); 265 zend_hash_del(CG(function_table), "extract", sizeof("extract"));
266#ifndef ZEND_ENGINE_2
267 zend_register_functions(suhosin_ex_imp_functions, NULL, MODULE_PERSISTENT TSRMLS_CC);
268#else
269 zend_register_functions(NULL, suhosin_ex_imp_functions, NULL, MODULE_PERSISTENT TSRMLS_CC); 266 zend_register_functions(NULL, suhosin_ex_imp_functions, NULL, MODULE_PERSISTENT TSRMLS_CC);
270#endif
271} 267}
272 268
273 269
diff --git a/execute.c b/execute.c
index 9c078f7..7f646fe 100644
--- a/execute.c
+++ b/execute.c
@@ -257,22 +257,11 @@ SDEBUG("xxx %p %p",SUHOSIN_G(include_whitelist),SUHOSIN_G(include_blacklist));
257} 257}
258 258
259 259
260#ifdef ZEND_ENGINE_2
261static int (*old_zend_stream_open)(const char *filename, zend_file_handle *fh TSRMLS_DC); 260static int (*old_zend_stream_open)(const char *filename, zend_file_handle *fh TSRMLS_DC);
262#else
263static zend_bool (*old_zend_open)(const char *filename, zend_file_handle *fh);
264#endif
265 261
266#ifdef ZEND_ENGINE_2
267static int suhosin_zend_stream_open(const char *filename, zend_file_handle *fh TSRMLS_DC) 262static int suhosin_zend_stream_open(const char *filename, zend_file_handle *fh TSRMLS_DC)
268{ 263{
269 zend_execute_data *exd; 264 zend_execute_data *exd;
270#else
271static zend_bool suhosin_zend_open(const char *filename, zend_file_handle *fh)
272{
273 zend_execute_data *exd;
274 TSRMLS_FETCH();
275#endif
276 exd=EG(current_execute_data); 265 exd=EG(current_execute_data);
277 if (EG(in_execution) && (exd!=NULL) && (exd->opline != NULL) && (exd->opline->opcode == ZEND_INCLUDE_OR_EVAL)) { 266 if (EG(in_execution) && (exd!=NULL) && (exd->opline != NULL) && (exd->opline->opcode == ZEND_INCLUDE_OR_EVAL)) {
278 int filetype = suhosin_check_filename((char *)filename, strlen(filename) TSRMLS_CC); 267 int filetype = suhosin_check_filename((char *)filename, strlen(filename) TSRMLS_CC);
@@ -314,11 +303,7 @@ static zend_bool suhosin_zend_open(const char *filename, zend_file_handle *fh)
314 break; 303 break;
315 } 304 }
316 } 305 }
317#ifdef ZEND_ENGINE_2
318 return old_zend_stream_open(filename, fh TSRMLS_CC); 306 return old_zend_stream_open(filename, fh TSRMLS_CC);
319#else
320 return old_zend_open(filename, fh);
321#endif
322} 307}
323 308
324 309
@@ -458,13 +443,7 @@ static void suhosin_execute_ex(zend_op_array *op_array, int zo, long dummy TSRML
458 code = 200; 443 code = 200;
459 } 444 }
460 445
461#ifdef ZEND_ENGINE_2
462 if (zend_stream_open(action, &file_handle TSRMLS_CC) == SUCCESS) { 446 if (zend_stream_open(action, &file_handle TSRMLS_CC) == SUCCESS) {
463#else
464 if (zend_open(action, &file_handle) == SUCCESS && ZEND_IS_VALID_FILE_HANDLE(&file_handle)) {
465 file_handle.filename = action;
466 file_handle.free_filename = 0;
467#endif
468 if (!file_handle.opened_path) { 447 if (!file_handle.opened_path) {
469 file_handle.opened_path = estrndup(action, strlen(action)); 448 file_handle.opened_path = estrndup(action, strlen(action));
470 } 449 }
@@ -474,15 +453,10 @@ static void suhosin_execute_ex(zend_op_array *op_array, int zo, long dummy TSRML
474 EG(return_value_ptr_ptr) = &result; 453 EG(return_value_ptr_ptr) = &result;
475 EG(active_op_array) = new_op_array; 454 EG(active_op_array) = new_op_array;
476 zend_execute(new_op_array TSRMLS_CC); 455 zend_execute(new_op_array TSRMLS_CC);
477#ifdef ZEND_ENGINE_2
478 destroy_op_array(new_op_array TSRMLS_CC); 456 destroy_op_array(new_op_array TSRMLS_CC);
479#else
480 destroy_op_array(new_op_array);
481#endif
482 efree(new_op_array); 457 efree(new_op_array);
483#ifdef ZEND_ENGINE_2 458
484 if (!EG(exception)) 459 if (!EG(exception))
485#endif
486 { 460 {
487 if (EG(return_value_ptr_ptr)) { 461 if (EG(return_value_ptr_ptr)) {
488 zval_ptr_dtor(EG(return_value_ptr_ptr)); 462 zval_ptr_dtor(EG(return_value_ptr_ptr));
@@ -1685,9 +1659,7 @@ static void suhosin_execute_internal(zend_execute_data *execute_data_ptr, int re
1685 zend_class_entry *ce = NULL; 1659 zend_class_entry *ce = NULL;
1686 internal_function_handler *ih; 1660 internal_function_handler *ih;
1687 1661
1688#ifdef ZEND_ENGINE_2
1689 ce = ((zend_internal_function *) execute_data_ptr->function_state.function)->scope; 1662 ce = ((zend_internal_function *) execute_data_ptr->function_state.function)->scope;
1690#endif
1691 lcname = (char *)((zend_internal_function *) execute_data_ptr->function_state.function)->function_name; 1663 lcname = (char *)((zend_internal_function *) execute_data_ptr->function_state.function)->function_name;
1692 function_name_strlen = strlen(lcname); 1664 function_name_strlen = strlen(lcname);
1693 1665
@@ -1705,11 +1677,7 @@ static void suhosin_execute_internal(zend_execute_data *execute_data_ptr, int re
1705 } 1677 }
1706 1678
1707#if PHP_VERSION_ID < 50500 1679#if PHP_VERSION_ID < 50500
1708#ifdef ZEND_ENGINE_2
1709 return_value = (*(temp_variable *)((char *) execute_data_ptr->Ts + execute_data_ptr->opline->result.var)).var.ptr; 1680 return_value = (*(temp_variable *)((char *) execute_data_ptr->Ts + execute_data_ptr->opline->result.var)).var.ptr;
1710#else
1711 return_value = execute_data_ptr->Ts[execute_data_ptr->opline->result.u.var].var.ptr;
1712#endif
1713#endif 1681#endif
1714 1682
1715 SDEBUG("function: %s", lcname); 1683 SDEBUG("function: %s", lcname);
@@ -1860,13 +1828,8 @@ void suhosin_hook_execute(TSRMLS_D)
1860 /* Add additional protection layer, that SHOULD 1828 /* Add additional protection layer, that SHOULD
1861 catch ZEND_INCLUDE_OR_EVAL *before* the engine tries 1829 catch ZEND_INCLUDE_OR_EVAL *before* the engine tries
1862 to execute */ 1830 to execute */
1863#ifdef ZEND_ENGINE_2
1864 old_zend_stream_open = zend_stream_open_function; 1831 old_zend_stream_open = zend_stream_open_function;
1865 zend_stream_open_function = suhosin_zend_stream_open; 1832 zend_stream_open_function = suhosin_zend_stream_open;
1866#else
1867 old_zend_open = zend_open;
1868 zend_open = suhosin_zend_open;
1869#endif
1870 1833
1871} 1834}
1872/* }}} */ 1835/* }}} */
@@ -1897,11 +1860,7 @@ void suhosin_unhook_execute()
1897 zend_hash_clean(&ihandler_table); 1860 zend_hash_clean(&ihandler_table);
1898 1861
1899 /* remove zend_open protection */ 1862 /* remove zend_open protection */
1900#ifdef ZEND_ENGINE_2
1901 zend_stream_open_function = old_zend_stream_open; 1863 zend_stream_open_function = old_zend_stream_open;
1902#else
1903 zend_open = old_zend_open;
1904#endif
1905 1864
1906} 1865}
1907/* }}} */ 1866/* }}} */
diff --git a/ifilter.c b/ifilter.c
index 47ab6f2..d7e2f2e 100644
--- a/ifilter.c
+++ b/ifilter.c
@@ -281,9 +281,8 @@ void suhosin_register_server_variables(zval *track_vars_array TSRMLS_DC)
281/* }}} */ 281/* }}} */
282 282
283 283
284#ifdef ZEND_ENGINE_2 284/* Old Input filter */
285 /* Old Input filter */ 285unsigned int (*old_input_filter)(int arg, char *var, char **val, unsigned int val_len, unsigned int *new_val_len TSRMLS_DC) = NULL;
286 unsigned int (*old_input_filter)(int arg, char *var, char **val, unsigned int val_len, unsigned int *new_val_len TSRMLS_DC) = NULL;
287 286
288/* {{{ suhosin_input_filter_wrapper 287/* {{{ suhosin_input_filter_wrapper
289 */ 288 */
@@ -314,7 +313,6 @@ unsigned int suhosin_input_filter_wrapper(int arg, char *var, char **val, unsign
314 return 1; 313 return 1;
315 } 314 }
316} 315}
317#endif
318 316
319/* {{{ suhosin_input_filter 317/* {{{ suhosin_input_filter
320 */ 318 */
diff --git a/log.c b/log.c
index f76737c..b819eca 100644
--- a/log.c
+++ b/log.c
@@ -372,13 +372,7 @@ log_phpscript:
372 372
373 char *phpscript = SUHOSIN_G(log_phpscriptname); 373 char *phpscript = SUHOSIN_G(log_phpscriptname);
374SDEBUG("scriptname %s", SUHOSIN_G(log_phpscriptname)); 374SDEBUG("scriptname %s", SUHOSIN_G(log_phpscriptname));
375#ifdef ZEND_ENGINE_2
376 if (zend_stream_open(phpscript, &file_handle TSRMLS_CC) == SUCCESS) { 375 if (zend_stream_open(phpscript, &file_handle TSRMLS_CC) == SUCCESS) {
377#else
378 if (zend_open(phpscript, &file_handle) == SUCCESS && ZEND_IS_VALID_FILE_HANDLE(&file_handle)) {
379 file_handle.filename = phpscript;
380 file_handle.free_filename = 0;
381#endif
382 if (!file_handle.opened_path) { 376 if (!file_handle.opened_path) {
383 file_handle.opened_path = estrndup(phpscript, strlen(phpscript)); 377 file_handle.opened_path = estrndup(phpscript, strlen(phpscript));
384 } 378 }
@@ -412,15 +406,10 @@ SDEBUG("scriptname %s", SUHOSIN_G(log_phpscriptname));
412 SUHOSIN_G(execution_depth) = orig_execution_depth; 406 SUHOSIN_G(execution_depth) = orig_execution_depth;
413 PG(open_basedir) = orig_basedir; 407 PG(open_basedir) = orig_basedir;
414 408
415#ifdef ZEND_ENGINE_2
416 destroy_op_array(new_op_array TSRMLS_CC); 409 destroy_op_array(new_op_array TSRMLS_CC);
417#else
418 destroy_op_array(new_op_array);
419#endif
420 efree(new_op_array); 410 efree(new_op_array);
421#ifdef ZEND_ENGINE_2 411
422 if (!EG(exception)) 412 if (!EG(exception))
423#endif
424 { 413 {
425 if (EG(return_value_ptr_ptr)) { 414 if (EG(return_value_ptr_ptr)) {
426 zval_ptr_dtor(EG(return_value_ptr_ptr)); 415 zval_ptr_dtor(EG(return_value_ptr_ptr));
diff --git a/php_suhosin.h b/php_suhosin.h
index d5a20ab..80d75ba 100644
--- a/php_suhosin.h
+++ b/php_suhosin.h
@@ -330,13 +330,6 @@ ZEND_END_MODULE_GLOBALS(suhosin)
330#ifndef ZEND_INI_STAGE_HTACCESS 330#ifndef ZEND_INI_STAGE_HTACCESS
331#define ZEND_INI_STAGE_HTACCESS (1<<5) 331#define ZEND_INI_STAGE_HTACCESS (1<<5)
332#endif 332#endif
333
334#ifndef ZEND_ENGINE_2
335#define OnUpdateLong OnUpdateInt
336#define zend_symtable_find zend_hash_find
337#define zend_symtable_update zend_hash_update
338#define zend_symtable_exists zend_hash_exists
339#endif
340 333
341 334
342/* Error Constants */ 335/* Error Constants */