[xdebug-dev] svn: /xdebug/trunk/ xdebug.c xdebug_private.h xdebug_stack.c

From: Derick Rethans <derick[@]derickrethans.nl>
Date: Fri, 11 Feb 2011 00:15:57 +0000

derick Fri, 11 Feb 2011 00:15:57 +0000

Revision: http://svn.xdebug.org/cgi-bin/viewvc.cgi?view=rev&revision=3397&root=xdebug

Log:
- Issue #660: Check X-HTTP-FORWARDED-FOR before falling back to REMOTE_ADDR.
  (Patch by Hannes Magnusson <bjori[@]php.net>)

Changed paths:
    U xdebug/trunk/xdebug.c
    U xdebug/trunk/xdebug_private.h
    U xdebug/trunk/xdebug_stack.c

Modified: xdebug/trunk/xdebug.c
===================================================================
--- xdebug/trunk/xdebug.c 2011-02-11 00:15:57 UTC (rev 3396)
+++ xdebug/trunk/xdebug.c 2011-02-11 00:15:57 UTC (rev 3397)
@@ -1194,34 +1194,7 @@
                         XG(remote_enable) &&
                         (XG(remote_mode) == XDEBUG_REQ)
                 ) {
- /* Initialize debugging session */
- if (XG(remote_connect_back)) {
- zval **remote_addr = NULL;
- zend_hash_find(Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_SERVER]), "REMOTE_ADDR", 12, (void**)&remote_addr);
- if (remote_addr) {
- XG(context).socket = xdebug_create_socket(Z_STRVAL_PP(remote_addr), XG(remote_port));
- } else {
- XG(context).socket = xdebug_create_socket(XG(remote_host), XG(remote_port));
- }
- } else {
- XG(context).socket = xdebug_create_socket(XG(remote_host), XG(remote_port));
- }
- if (XG(context).socket >= 0) {
- XG(remote_enabled) = 1;
-
- /* Get handler from mode */
- XG(context).handler = xdebug_handler_get(XG(remote_handler));
- if (!XG(context).handler) {
- XG(remote_enabled) = 0;
- zend_error(E_WARNING, "The remote debug handler '%s' is not supported.", XG(remote_handler));
- } else if (!XG(context).handler->remote_init(&(XG(context)), XDEBUG_REQ)) {
- /* The request could not be started, ignore it then */
- XG(remote_enabled) = 0;
- } else {
- /* All is well, turn off script time outs */
- zend_alter_ini_entry("max_execution_time", sizeof("max_execution_time"), "0", strlen("0"), PHP_INI_SYSTEM, PHP_INI_STAGE_ACTIVATE);
- }
- }
+ xdebug_init_debugger(TSRMLS_C);
                 }
                 if (magic_cookie) {
                         xdfree(magic_cookie);

Modified: xdebug/trunk/xdebug_private.h
===================================================================
--- xdebug/trunk/xdebug_private.h 2011-02-11 00:15:57 UTC (rev 3396)
+++ xdebug/trunk/xdebug_private.h 2011-02-11 00:15:57 UTC (rev 3397)
@@ -201,6 +201,7 @@
 function_stack_entry *xdebug_get_stack_tail(TSRMLS_D);

 xdebug_hash* xdebug_used_var_hash_from_llist(xdebug_llist *list);
+void xdebug_init_debugger(TSRMLS_D);

 #endif


Modified: xdebug/trunk/xdebug_stack.c
===================================================================
--- xdebug/trunk/xdebug_stack.c 2011-02-11 00:15:57 UTC (rev 3396)
+++ xdebug/trunk/xdebug_stack.c 2011-02-11 00:15:57 UTC (rev 3397)
@@ -442,35 +442,45 @@
         return str.d;
 }

-void xdebug_do_jit(TSRMLS_D)
+void xdebug_init_debugger(TSRMLS_D)
 {
- if (!XG(remote_enabled) && XG(remote_enable) && (XG(remote_mode) == XDEBUG_JIT)) {
- if (XG(remote_connect_back)) {
- zval **remote_addr = NULL;
+ if (XG(remote_connect_back)) {
+ zval **remote_addr = NULL;
+ if (zend_hash_find(Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_SERVER]), "X_HTTP_FORWARDED_FOR", 21, (void**)&remote_addr) == FAILURE) {
                         zend_hash_find(Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_SERVER]), "REMOTE_ADDR", 12, (void**)&remote_addr);
+ }
+ if (remote_addr) {
                         XG(context).socket = xdebug_create_socket(Z_STRVAL_PP(remote_addr), XG(remote_port));
                 } else {
                         XG(context).socket = xdebug_create_socket(XG(remote_host), XG(remote_port));
                 }
- if (XG(context).socket >= 0) {
- XG(remote_enabled) = 0;
+ } else {
+ XG(context).socket = xdebug_create_socket(XG(remote_host), XG(remote_port));
+ }
+ if (XG(context).socket >= 0) {
+ XG(remote_enabled) = 0;

- /* Get handler from mode */
- XG(context).handler = xdebug_handler_get(XG(remote_handler));
- if (!XG(context).handler) {
- zend_error(E_WARNING, "The remote debug handler '%s' is not supported.", XG(remote_handler));
- } else if (!XG(context).handler->remote_init(&(XG(context)), XDEBUG_JIT)) {
- /* The request could not be started, ignore it then */
- } else {
- /* All is well, turn off script time outs */
- zend_alter_ini_entry("max_execution_time", sizeof("max_execution_time"), "0", strlen("0"), PHP_INI_SYSTEM, PHP_INI_STAGE_ACTIVATE);
- XG(remote_enabled) = 1;
- }
+ /* Get handler from mode */
+ XG(context).handler = xdebug_handler_get(XG(remote_handler));
+ if (!XG(context).handler) {
+ zend_error(E_WARNING, "The remote debug handler '%s' is not supported.", XG(remote_handler));
+ } else if (!XG(context).handler->remote_init(&(XG(context)), XDEBUG_REQ)) {
+ /* The request could not be started, ignore it then */
+ } else {
+ /* All is well, turn off script time outs */
+ XG(remote_endbled) = 1;
                 }
         }
 }

+void xdebug_do_jit(TSRMLS_D)
+{
+ if (!XG(remote_enabled) && XG(remote_enable) && (XG(remote_mode) == XDEBUG_JIT)) {
+ xdebug_init_debugger(TSRMLS_C);
+ }
+}

+
 /* Error callback for formatting stack traces */
 void xdebug_error_cb(int type, const char *error_filename, const uint error_lineno, const char *format, va_list args)
 {
Received on Fri Feb 11 2011 - 00:15:57 GMT

This archive was generated by hypermail 2.2.0 : Sun Jun 24 2018 - 04:00:03 BST