[PHP-CVS] svn: /php/php-src/ branches/PHP_5_4/sapi/cli/php_cli_server.c trunk/sapi/cli/php_cli_server.c

2012-01-31 Thread Michael Wallner
mike Tue, 31 Jan 2012 10:47:21 +

Revision: http://svn.php.net/viewvc?view=revisionrevision=322966

Log:
fix usage of php_output_(de)activate; I guess this code doesn't bother about 
one more hack;

Changed paths:
U   php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c
U   php/php-src/trunk/sapi/cli/php_cli_server.c

Modified: php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c
===
--- php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c  2012-01-31 
10:47:11 UTC (rev 322965)
+++ php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c  2012-01-31 
10:47:21 UTC (rev 322966)
@@ -1755,11 +1755,22 @@
int err = 0;
zval *style = NULL;
zend_try {
+   if (!SG(sapi_started)) {
+   php_output_activate(TSRMLS_C);
+   }
php_output_start_user(NULL, 0, 
PHP_OUTPUT_HANDLER_STDFLAGS TSRMLS_CC);
php_info_print_style(TSRMLS_C);
MAKE_STD_ZVAL(style);
php_output_get_contents(style TSRMLS_CC);
php_output_discard(TSRMLS_C);
+   if (!SG(sapi_started)) {
+   static int 
(*send_header_func)(sapi_headers_struct * TSRMLS_DC);
+   send_header_func = sapi_module.send_headers;
+   /* we don't want the header to be sent now */
+   sapi_module.send_headers = 
sapi_cli_server_discard_headers;
+   php_output_deactivate(TSRMLS_C);
+   sapi_module.send_headers = send_header_func;
+   }
if (style  Z_STRVAL_P(style)) {
char *block = pestrndup(Z_STRVAL_P(style), 
Z_STRLEN_P(style), 1);
php_cli_server_chunk *chunk = 
php_cli_server_chunk_heap_new(block, block, Z_STRLEN_P(style));

Modified: php/php-src/trunk/sapi/cli/php_cli_server.c
===
--- php/php-src/trunk/sapi/cli/php_cli_server.c 2012-01-31 10:47:11 UTC (rev 
322965)
+++ php/php-src/trunk/sapi/cli/php_cli_server.c 2012-01-31 10:47:21 UTC (rev 
322966)
@@ -1755,11 +1755,22 @@
int err = 0;
zval *style = NULL;
zend_try {
+   if (!SG(sapi_started)) {
+   php_output_activate(TSRMLS_C);
+   }
php_output_start_user(NULL, 0, 
PHP_OUTPUT_HANDLER_STDFLAGS TSRMLS_CC);
php_info_print_style(TSRMLS_C);
MAKE_STD_ZVAL(style);
php_output_get_contents(style TSRMLS_CC);
php_output_discard(TSRMLS_C);
+   if (!SG(sapi_started)) {
+   static int 
(*send_header_func)(sapi_headers_struct * TSRMLS_DC);
+   send_header_func = sapi_module.send_headers;
+   /* we don't want the header to be sent now */
+   sapi_module.send_headers = 
sapi_cli_server_discard_headers;
+   php_output_deactivate(TSRMLS_C);
+   sapi_module.send_headers = send_header_func;
+   }
if (style  Z_STRVAL_P(style)) {
char *block = pestrndup(Z_STRVAL_P(style), 
Z_STRLEN_P(style), 1);
php_cli_server_chunk *chunk = 
php_cli_server_chunk_heap_new(block, block, Z_STRLEN_P(style));

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[PHP-CVS] svn: /php/php-src/ branches/PHP_5_4/sapi/cli/php_cli_server.c trunk/sapi/cli/php_cli_server.c

2011-12-09 Thread Xinchen Hui
laruence Fri, 09 Dec 2011 14:05:26 +

Revision: http://svn.php.net/viewvc?view=revisionrevision=320780

Log:
fix memory leak

Changed paths:
U   php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c
U   php/php-src/trunk/sapi/cli/php_cli_server.c

Modified: php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c
===
--- php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c  2011-12-09 
13:36:02 UTC (rev 320779)
+++ php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c  2011-12-09 
14:05:26 UTC (rev 320780)
@@ -581,6 +581,7 @@
char *tmp;
spprintf(tmp, 0, %i,  client-server-port);
sapi_cli_server_register_variable(track_vars_array, 
SERVER_PORT, tmp TSRMLS_CC);
+   efree(tmp);
}

sapi_cli_server_register_variable(track_vars_array, REQUEST_URI, 
client-request.request_uri TSRMLS_CC);

Modified: php/php-src/trunk/sapi/cli/php_cli_server.c
===
--- php/php-src/trunk/sapi/cli/php_cli_server.c 2011-12-09 13:36:02 UTC (rev 
320779)
+++ php/php-src/trunk/sapi/cli/php_cli_server.c 2011-12-09 14:05:26 UTC (rev 
320780)
@@ -581,6 +581,7 @@
char *tmp;
spprintf(tmp, 0, %i,  client-server-port);
sapi_cli_server_register_variable(track_vars_array, 
SERVER_PORT, tmp TSRMLS_CC);
+   efree(tmp);
}

sapi_cli_server_register_variable(track_vars_array, REQUEST_URI, 
client-request.request_uri TSRMLS_CC);

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[PHP-CVS] svn: /php/php-src/ branches/PHP_5_4/sapi/cli/php_cli_server.c branches/PHP_5_4/sapi/cli/tests/php_cli_server_002.phpt trunk/sapi/cli/php_cli_server.c trunk/sapi/cli/tests/php_cli_server_002.

2011-12-09 Thread Xinchen Hui
laruence Fri, 09 Dec 2011 16:16:31 +

Revision: http://svn.php.net/viewvc?view=revisionrevision=320796

Log:
add $_SERVER[SERVER_NAME] since it's handy

Changed paths:
U   php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c
U   php/php-src/branches/PHP_5_4/sapi/cli/tests/php_cli_server_002.phpt
U   php/php-src/trunk/sapi/cli/php_cli_server.c
U   php/php-src/trunk/sapi/cli/tests/php_cli_server_002.phpt

Modified: php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c
===
--- php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c  2011-12-09 
16:10:33 UTC (rev 320795)
+++ php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c  2011-12-09 
16:16:31 UTC (rev 320796)
@@ -577,6 +577,7 @@
sapi_cli_server_register_variable(track_vars_array, 
SERVER_PROTOCOL, tmp TSRMLS_CC);
efree(tmp);
}
+   sapi_cli_server_register_variable(track_vars_array, SERVER_NAME, 
client-server-host TSRMLS_CC);
{
char *tmp;
spprintf(tmp, 0, %i,  client-server-port);

Modified: php/php-src/branches/PHP_5_4/sapi/cli/tests/php_cli_server_002.phpt
===
--- php/php-src/branches/PHP_5_4/sapi/cli/tests/php_cli_server_002.phpt 
2011-12-09 16:10:33 UTC (rev 320795)
+++ php/php-src/branches/PHP_5_4/sapi/cli/tests/php_cli_server_002.phpt 
2011-12-09 16:16:31 UTC (rev 320796)
@@ -9,10 +9,12 @@
 --FILE--
 ?php
 include php_cli_server.inc;
-php_cli_server_start('var_dump($_SERVER[DOCUMENT_ROOT], 
$_SERVER[SERVER_SOFTWARE]);');
+php_cli_server_start('var_dump($_SERVER[DOCUMENT_ROOT], 
$_SERVER[SERVER_SOFTWARE], $_SERVER[SERVER_NAME], 
$_SERVER[SERVER_PORT]);');
 var_dump(file_get_contents(http://; . PHP_CLI_SERVER_ADDRESS));
 ?
 --EXPECTF--
 string(%d) string(%d) %stests
 string(%d) PHP %s Development Server
+string(%d) localhost
+string(%d) 8964
 

Modified: php/php-src/trunk/sapi/cli/php_cli_server.c
===
--- php/php-src/trunk/sapi/cli/php_cli_server.c 2011-12-09 16:10:33 UTC (rev 
320795)
+++ php/php-src/trunk/sapi/cli/php_cli_server.c 2011-12-09 16:16:31 UTC (rev 
320796)
@@ -577,6 +577,7 @@
sapi_cli_server_register_variable(track_vars_array, 
SERVER_PROTOCOL, tmp TSRMLS_CC);
efree(tmp);
}
+   sapi_cli_server_register_variable(track_vars_array, SERVER_NAME, 
client-server-host TSRMLS_CC);
{
char *tmp;
spprintf(tmp, 0, %i,  client-server-port);

Modified: php/php-src/trunk/sapi/cli/tests/php_cli_server_002.phpt
===
--- php/php-src/trunk/sapi/cli/tests/php_cli_server_002.phpt2011-12-09 
16:10:33 UTC (rev 320795)
+++ php/php-src/trunk/sapi/cli/tests/php_cli_server_002.phpt2011-12-09 
16:16:31 UTC (rev 320796)
@@ -9,10 +9,12 @@
 --FILE--
 ?php
 include php_cli_server.inc;
-php_cli_server_start('var_dump($_SERVER[DOCUMENT_ROOT], 
$_SERVER[SERVER_SOFTWARE]);');
+php_cli_server_start('var_dump($_SERVER[DOCUMENT_ROOT], 
$_SERVER[SERVER_SOFTWARE], $_SERVER[SERVER_NAME], 
$_SERVER[SERVER_PORT]);');
 var_dump(file_get_contents(http://; . PHP_CLI_SERVER_ADDRESS));
 ?
 --EXPECTF--
 string(%d) string(%d) %stests
 string(%d) PHP %s Development Server
+string(%d) localhost
+string(%d) 8964
 

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[PHP-CVS] svn: /php/php-src/ branches/PHP_5_4/sapi/cli/php_cli_server.c trunk/sapi/cli/php_cli_server.c

2011-11-25 Thread Pierre Joye
pajoye   Fri, 25 Nov 2011 21:18:40 +

Revision: http://svn.php.net/viewvc?view=revisionrevision=319846

Log:
- implement FR #60390, SERVER_PORT missing

Bug: https://bugs.php.net/60390 (Open) Missing _SERVER[SERVER_PORT]
  
Changed paths:
U   php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c
U   php/php-src/trunk/sapi/cli/php_cli_server.c

Modified: php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c
===
--- php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c  2011-11-25 
21:10:33 UTC (rev 319845)
+++ php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c  2011-11-25 
21:18:40 UTC (rev 319846)
@@ -577,6 +577,12 @@
sapi_cli_server_register_variable(track_vars_array, 
SERVER_PROTOCOL, tmp TSRMLS_CC);
efree(tmp);
}
+   {
+   char *tmp;
+   spprintf(tmp, 0, %i,  client-server-port);
+   sapi_cli_server_register_variable(track_vars_array, 
SERVER_PORT, tmp TSRMLS_CC);
+   }
+
sapi_cli_server_register_variable(track_vars_array, REQUEST_URI, 
client-request.request_uri TSRMLS_CC);
sapi_cli_server_register_variable(track_vars_array, REQUEST_METHOD, 
SG(request_info).request_method TSRMLS_CC);
sapi_cli_server_register_variable(track_vars_array, SCRIPT_NAME, 
client-request.vpath TSRMLS_CC);

Modified: php/php-src/trunk/sapi/cli/php_cli_server.c
===
--- php/php-src/trunk/sapi/cli/php_cli_server.c 2011-11-25 21:10:33 UTC (rev 
319845)
+++ php/php-src/trunk/sapi/cli/php_cli_server.c 2011-11-25 21:18:40 UTC (rev 
319846)
@@ -577,6 +577,12 @@
sapi_cli_server_register_variable(track_vars_array, 
SERVER_PROTOCOL, tmp TSRMLS_CC);
efree(tmp);
}
+   {
+   char *tmp;
+   spprintf(tmp, 0, %i,  client-server-port);
+   sapi_cli_server_register_variable(track_vars_array, 
SERVER_PORT, tmp TSRMLS_CC);
+   }
+
sapi_cli_server_register_variable(track_vars_array, REQUEST_URI, 
client-request.request_uri TSRMLS_CC);
sapi_cli_server_register_variable(track_vars_array, REQUEST_METHOD, 
SG(request_info).request_method TSRMLS_CC);
sapi_cli_server_register_variable(track_vars_array, SCRIPT_NAME, 
client-request.vpath TSRMLS_CC);

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP-CVS] svn: /php/php-src/ branches/PHP_5_4/sapi/cli/php_cli_server.c trunk/sapi/cli/php_cli_server.c

2011-10-24 Thread Ferenc Kovacs
Hi Laruence,

I'm still seeing sapi/cli/tests/php_cli_server_009.phpt fail for 5.4 on both
32 and 64bit debian lenny, and for trunk on 32bit:

001- [%s] %s
017+ [Mon Oct 24 12:27:40 2011] 127.0.0.1:48770 [404]: /foo/bar.js - No such
file or directory

can you reproduce this?


On Mon, Oct 24, 2011 at 5:47 AM, Xinchen Hui larue...@php.net wrote:

 laruence Mon, 24 Oct 2011 03:47:42 +

 Revision: http://svn.php.net/viewvc?view=revisionrevision=318356

 Log:
 A better fix, sorry for previous thoughtlessness commit.

 Changed paths:
U   php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c
U   php/php-src/trunk/sapi/cli/php_cli_server.c

 Modified: php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c
 ===
 --- php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c  2011-10-24
 03:28:59 UTC (rev 318355)
 +++ php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c  2011-10-24
 03:47:42 UTC (rev 318356)
 @@ -1292,14 +1292,10 @@
}
file++;
}
 -   if (!*file) {
 +   if (!*file || is_static_file) {
pefree(buf, 1);
return;
}
 -   if (is_static_file) {
 -   pefree(buf, 1);
 -   return;
 -   }
}
 break; /* regular file */
}

 Modified: php/php-src/trunk/sapi/cli/php_cli_server.c
 ===
 --- php/php-src/trunk/sapi/cli/php_cli_server.c 2011-10-24 03:28:59 UTC
 (rev 318355)
 +++ php/php-src/trunk/sapi/cli/php_cli_server.c 2011-10-24 03:47:42 UTC
 (rev 318356)
 @@ -1292,14 +1292,10 @@
}
file++;
}
 -   if (!*file) {
 +   if (!*file || is_static_file) {
pefree(buf, 1);
return;
}
 -   if (is_static_file) {
 -   pefree(buf, 1);
 -   return;
 -   }
}
 break; /* regular file */
}


 --
 PHP CVS Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




-- 
Ferenc Kovács
@Tyr43l - http://tyrael.hu


Re: [PHP-CVS] svn: /php/php-src/ branches/PHP_5_4/sapi/cli/php_cli_server.c trunk/sapi/cli/php_cli_server.c

2011-10-24 Thread Laruence
Hi:
   it looks like %s didn't match the whole string.

   it is pass in my environ,  I will try to find out the different,  :)

thanks

2011/10/24 Ferenc Kovacs tyr...@gmail.com:
 Hi Laruence,
 I'm still seeing sapi/cli/tests/php_cli_server_009.phpt fail for 5.4 on both
 32 and 64bit debian lenny, and for trunk on 32bit:
 001- [%s] %s
 017+ [Mon Oct 24 12:27:40 2011] 127.0.0.1:48770 [404]: /foo/bar.js - No such
 file or directory
 can you reproduce this?

 On Mon, Oct 24, 2011 at 5:47 AM, Xinchen Hui larue...@php.net wrote:

 laruence                                 Mon, 24 Oct 2011 03:47:42 +

 Revision: http://svn.php.net/viewvc?view=revisionrevision=318356

 Log:
 A better fix, sorry for previous thoughtlessness commit.

 Changed paths:
    U   php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c
    U   php/php-src/trunk/sapi/cli/php_cli_server.c

 Modified: php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c
 ===
 --- php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c      2011-10-24
 03:28:59 UTC (rev 318355)
 +++ php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c      2011-10-24
 03:47:42 UTC (rev 318356)
 @@ -1292,14 +1292,10 @@
                                        }
                                        file++;
                                }
 -                               if (!*file) {
 +                               if (!*file || is_static_file) {
                                        pefree(buf, 1);
                                        return;
                                }
 -                               if (is_static_file) {
 -                                       pefree(buf, 1);
 -                                       return;
 -                               }
                        }
                        break; /* regular file */
                }

 Modified: php/php-src/trunk/sapi/cli/php_cli_server.c
 ===
 --- php/php-src/trunk/sapi/cli/php_cli_server.c 2011-10-24 03:28:59 UTC
 (rev 318355)
 +++ php/php-src/trunk/sapi/cli/php_cli_server.c 2011-10-24 03:47:42 UTC
 (rev 318356)
 @@ -1292,14 +1292,10 @@
                                        }
                                        file++;
                                }
 -                               if (!*file) {
 +                               if (!*file || is_static_file) {
                                        pefree(buf, 1);
                                        return;
                                }
 -                               if (is_static_file) {
 -                                       pefree(buf, 1);
 -                                       return;
 -                               }
                        }
                        break; /* regular file */
                }


 --
 PHP CVS Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



 --
 Ferenc Kovács
 @Tyr43l - http://tyrael.hu




-- 
Laruence  Xinchen Hui
http://www.laruence.com/


[PHP-CVS] svn: /php/php-src/ branches/PHP_5_4/sapi/cli/php_cli_server.c trunk/sapi/cli/php_cli_server.c

2011-10-23 Thread Xinchen Hui
laruence Mon, 24 Oct 2011 03:28:59 +

Revision: http://svn.php.net/viewvc?view=revisionrevision=318355

Log:
Fixed PATH_INFO of /index.php/foo/bar

Changed paths:
U   php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c
U   php/php-src/trunk/sapi/cli/php_cli_server.c

Modified: php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c
===
--- php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c  2011-10-24 
00:36:56 UTC (rev 318354)
+++ php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c  2011-10-24 
03:28:59 UTC (rev 318355)
@@ -1296,12 +1296,13 @@
pefree(buf, 1);
return;
}
+   if (is_static_file) {
+   pefree(buf, 1);
+   return;
+   }
}
break; /* regular file */
-   } else if (is_static_file) {
-   pefree(buf, 1);
-   return;
-   }
+   }
if (prev_patch) {
pefree(prev_patch, 1);
*q = DEFAULT_SLASH;

Modified: php/php-src/trunk/sapi/cli/php_cli_server.c
===
--- php/php-src/trunk/sapi/cli/php_cli_server.c 2011-10-24 00:36:56 UTC (rev 
318354)
+++ php/php-src/trunk/sapi/cli/php_cli_server.c 2011-10-24 03:28:59 UTC (rev 
318355)
@@ -1296,12 +1296,13 @@
pefree(buf, 1);
return;
}
+   if (is_static_file) {
+   pefree(buf, 1);
+   return;
+   }
}
break; /* regular file */
-   } else if (is_static_file) {
-   pefree(buf, 1);
-   return;
-   }
+   }
if (prev_patch) {
pefree(prev_patch, 1);
*q = DEFAULT_SLASH;

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[PHP-CVS] svn: /php/php-src/ branches/PHP_5_4/sapi/cli/php_cli_server.c trunk/sapi/cli/php_cli_server.c

2011-10-23 Thread Xinchen Hui
laruence Mon, 24 Oct 2011 03:47:42 +

Revision: http://svn.php.net/viewvc?view=revisionrevision=318356

Log:
A better fix, sorry for previous thoughtlessness commit.

Changed paths:
U   php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c
U   php/php-src/trunk/sapi/cli/php_cli_server.c

Modified: php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c
===
--- php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c  2011-10-24 
03:28:59 UTC (rev 318355)
+++ php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c  2011-10-24 
03:47:42 UTC (rev 318356)
@@ -1292,14 +1292,10 @@
}
file++;
}
-   if (!*file) {
+   if (!*file || is_static_file) {
pefree(buf, 1);
return;
}
-   if (is_static_file) {
-   pefree(buf, 1);
-   return;
-   }
}
break; /* regular file */
}

Modified: php/php-src/trunk/sapi/cli/php_cli_server.c
===
--- php/php-src/trunk/sapi/cli/php_cli_server.c 2011-10-24 03:28:59 UTC (rev 
318355)
+++ php/php-src/trunk/sapi/cli/php_cli_server.c 2011-10-24 03:47:42 UTC (rev 
318356)
@@ -1292,14 +1292,10 @@
}
file++;
}
-   if (!*file) {
+   if (!*file || is_static_file) {
pefree(buf, 1);
return;
}
-   if (is_static_file) {
-   pefree(buf, 1);
-   return;
-   }
}
break; /* regular file */
}

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[PHP-CVS] svn: /php/php-src/ branches/PHP_5_4/sapi/cli/php_cli_server.c branches/PHP_5_4/sapi/cli/tests/php_cli_server_008.phpt trunk/sapi/cli/php_cli_server.c trunk/sapi/cli/tests/php_cli_server_008.

2011-10-20 Thread Moriyoshi Koizumi
moriyoshiFri, 21 Oct 2011 05:24:30 +

Revision: http://svn.php.net/viewvc?view=revisionrevision=318283

Log:
Add SERVER_PROTOCOL variable to $_SERVER.  Patch by kuzuha.  Thanks.

Changed paths:
U   php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c
A   php/php-src/branches/PHP_5_4/sapi/cli/tests/php_cli_server_008.phpt
U   php/php-src/trunk/sapi/cli/php_cli_server.c
A   php/php-src/trunk/sapi/cli/tests/php_cli_server_008.phpt

Modified: php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c
===
--- php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c  2011-10-21 
01:39:45 UTC (rev 318282)
+++ php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c  2011-10-21 
05:24:30 UTC (rev 318283)
@@ -571,6 +571,12 @@
sapi_cli_server_register_variable(track_vars_array, 
SERVER_SOFTWARE, tmp TSRMLS_CC);
efree(tmp);
}
+   {
+   char *tmp;
+   spprintf(tmp, 0, HTTP/%d.%d, 
client-request.protocol_version / 100, client-request.protocol_version % 100);
+   sapi_cli_server_register_variable(track_vars_array, 
SERVER_PROTOCOL, tmp TSRMLS_CC);
+   efree(tmp);
+   }
sapi_cli_server_register_variable(track_vars_array, REQUEST_URI, 
client-request.request_uri TSRMLS_CC);
sapi_cli_server_register_variable(track_vars_array, REQUEST_METHOD, 
SG(request_info).request_method TSRMLS_CC);
sapi_cli_server_register_variable(track_vars_array, PHP_SELF, 
client-request.vpath TSRMLS_CC);

Added: php/php-src/branches/PHP_5_4/sapi/cli/tests/php_cli_server_008.phpt
===
--- php/php-src/branches/PHP_5_4/sapi/cli/tests/php_cli_server_008.phpt 
(rev 0)
+++ php/php-src/branches/PHP_5_4/sapi/cli/tests/php_cli_server_008.phpt 
2011-10-21 05:24:30 UTC (rev 318283)
@@ -0,0 +1,71 @@
+--TEST--
+SERVER_PROTOCOL header availability
+--SKIPIF--
+?php
+include skipif.inc;
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+die (skip not for Windows);
+}
+?
+--FILE--
+?php
+include php_cli_server.inc;
+php_cli_server_start('var_dump($_SERVER[SERVER_PROTOCOL]);');
+
+list($host, $port) = explode(':', PHP_CLI_SERVER_ADDRESS);
+$port = intval($port)?:80;
+
+$fp = fsockopen($host, $port, $errno, $errstr, 0.5);
+if (!$fp) {
+  die(connect failed);
+}
+
+if(fwrite($fp, HEADER
+GET / HTTP/1.1
+Host: {$host}
+
+
+HEADER
+)) {
+   while (!feof($fp)) {
+   echo fgets($fp);
+   }
+}
+
+fclose($fp);
+
+$fp = fsockopen($host, $port, $errno, $errstr, 0.5);
+if (!$fp) {
+  die(connect failed);
+}
+
+
+if(fwrite($fp, HEADER
+GET / HTTP/1.0
+Host: {$host}
+
+
+HEADER
+)) {
+   while (!feof($fp)) {
+   echo fgets($fp);
+   }
+}
+
+fclose($fp);
+?
+--EXPECTF--
+HTTP/1.1 200 OK
+Host: %s
+Connection: closed
+X-Powered-By: PHP/%s-dev
+Content-type: text/html
+
+string(8) HTTP/1.1
+HTTP/1.0 200 OK
+Host: %s
+Connection: closed
+X-Powered-By: PHP/%s-dev
+Content-type: text/html
+
+string(8) HTTP/1.0

Modified: php/php-src/trunk/sapi/cli/php_cli_server.c
===
--- php/php-src/trunk/sapi/cli/php_cli_server.c 2011-10-21 01:39:45 UTC (rev 
318282)
+++ php/php-src/trunk/sapi/cli/php_cli_server.c 2011-10-21 05:24:30 UTC (rev 
318283)
@@ -571,6 +571,12 @@
sapi_cli_server_register_variable(track_vars_array, 
SERVER_SOFTWARE, tmp TSRMLS_CC);
efree(tmp);
}
+   {
+   char *tmp;
+   spprintf(tmp, 0, HTTP/%d.%d, 
client-request.protocol_version / 100, client-request.protocol_version % 100);
+   sapi_cli_server_register_variable(track_vars_array, 
SERVER_PROTOCOL, tmp TSRMLS_CC);
+   efree(tmp);
+   }
sapi_cli_server_register_variable(track_vars_array, REQUEST_URI, 
client-request.request_uri TSRMLS_CC);
sapi_cli_server_register_variable(track_vars_array, REQUEST_METHOD, 
SG(request_info).request_method TSRMLS_CC);
sapi_cli_server_register_variable(track_vars_array, PHP_SELF, 
client-request.vpath TSRMLS_CC);

Added: php/php-src/trunk/sapi/cli/tests/php_cli_server_008.phpt
===
--- php/php-src/trunk/sapi/cli/tests/php_cli_server_008.phpt
(rev 0)
+++ php/php-src/trunk/sapi/cli/tests/php_cli_server_008.phpt2011-10-21 
05:24:30 UTC (rev 318283)
@@ -0,0 +1,71 @@
+--TEST--
+SERVER_PROTOCOL header availability
+--SKIPIF--
+?php
+include skipif.inc;
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+die (skip not for Windows);
+}
+?
+--FILE--
+?php
+include php_cli_server.inc;
+php_cli_server_start('var_dump($_SERVER[SERVER_PROTOCOL]);');
+
+list($host, $port) = explode(':', PHP_CLI_SERVER_ADDRESS);
+$port = intval($port)?:80;
+
+$fp = fsockopen($host, $port, $errno, $errstr, 

Re: [PHP-CVS] svn: /php/php-src/ branches/PHP_5_4/sapi/cli/php_cli_server.c trunk/sapi/cli/php_cli_server.c

2011-09-21 Thread Pierre Joye
VCWD_GETCWD is sufficient.

On Wed, Sep 21, 2011 at 1:49 AM, Moriyoshi Koizumi m...@mozo.jp wrote:
 Hi,

 Where does HAVE_BROKEN_GETCWD come from? Isn't simply using VCWD_GETCWD 
 sufficient?

 Moriyoshi

 On 2011/09/20, at 16:06, Xinchen Hui wrote:

 laruence                                 Tue, 20 Sep 2011 07:06:55 +

 Revision: http://svn.php.net/viewvc?view=revisionrevision=317040

 Log:
 Fix Bug #55726 (Changing the working directory makes router script 
 inaccessible)

 Bug: https://bugs.php.net/55726 (Assigned) Changing the working directory 
 makes router script inaccessible

 Changed paths:
    U   php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c
    U   php/php-src/trunk/sapi/cli/php_cli_server.c

 Modified: php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c
 ===
 --- php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c    2011-09-20 
 05:42:36 UTC (rev 317039)
 +++ php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c    2011-09-20 
 07:06:55 UTC (rev 317040)
 @@ -1877,11 +1877,24 @@
       }
       {
               zend_file_handle zfd;
 +#if HAVE_BROKEN_GETCWD
 +             int old_cwd_fd = -1;
 +             old_cwd_fd = open(., 0);
 +#else
 +             char *old_cwd;
 +             ALLOCA_FLAG(use_heap)
 +#define OLD_CWD_SIZE 4096
 +             old_cwd = do_alloca(OLD_CWD_SIZE, use_heap);
 +             old_cwd[0] = '\0';
 +             php_ignore_value(VCWD_GETCWD(old_cwd, OLD_CWD_SIZE-1));
 +#endif
 +
               zfd.type = ZEND_HANDLE_FILENAME;
               zfd.filename = server-router;
               zfd.handle.fp = NULL;
               zfd.free_filename = 0;
               zfd.opened_path = NULL;
 +
               zend_try {
                       zval *retval = NULL;
                       if (SUCCESS == zend_execute_scripts(ZEND_REQUIRE 
 TSRMLS_CC, retval, 1, zfd)) {
 @@ -1893,6 +1906,18 @@
                               decline = 1;
                       }
               } zend_end_try();
 +
 +#if HAVE_BROKEN_GETCWD
 +             if (old_cwd_fd != -1) {
 +                     fchdir(old_cwd_fd);
 +                     close(old_cwd_fd);
 +             }
 +#else
 +             if (old_cwd[0] != '\0') {
 +                     php_ignore_value(VCWD_CHDIR(old_cwd));
 +             }
 +             free_alloca(old_cwd, use_heap);
 +#endif
       }

       if (decline) {

 Modified: php/php-src/trunk/sapi/cli/php_cli_server.c
 ===
 --- php/php-src/trunk/sapi/cli/php_cli_server.c       2011-09-20 05:42:36 
 UTC (rev 317039)
 +++ php/php-src/trunk/sapi/cli/php_cli_server.c       2011-09-20 07:06:55 
 UTC (rev 317040)
 @@ -1877,11 +1877,24 @@
       }
       {
               zend_file_handle zfd;
 +#if HAVE_BROKEN_GETCWD
 +             int old_cwd_fd = -1;
 +             old_cwd_fd = open(., 0);
 +#else
 +             char *old_cwd;
 +             ALLOCA_FLAG(use_heap)
 +#define OLD_CWD_SIZE 4096
 +             old_cwd = do_alloca(OLD_CWD_SIZE, use_heap);
 +             old_cwd[0] = '\0';
 +             php_ignore_value(VCWD_GETCWD(old_cwd, OLD_CWD_SIZE-1));
 +#endif
 +
               zfd.type = ZEND_HANDLE_FILENAME;
               zfd.filename = server-router;
               zfd.handle.fp = NULL;
               zfd.free_filename = 0;
               zfd.opened_path = NULL;
 +
               zend_try {
                       zval *retval = NULL;
                       if (SUCCESS == zend_execute_scripts(ZEND_REQUIRE 
 TSRMLS_CC, retval, 1, zfd)) {
 @@ -1893,6 +1906,18 @@
                               decline = 1;
                       }
               } zend_end_try();
 +
 +#if HAVE_BROKEN_GETCWD
 +             if (old_cwd_fd != -1) {
 +                     fchdir(old_cwd_fd);
 +                     close(old_cwd_fd);
 +             }
 +#else
 +             if (old_cwd[0] != '\0') {
 +                     php_ignore_value(VCWD_CHDIR(old_cwd));
 +             }
 +             free_alloca(old_cwd, use_heap);
 +#endif
       }

       if (decline) {

 --
 PHP CVS Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php

 --
 Moriyoshi Koizumi
 m...@mozo.jp




 --
 PHP CVS Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php





-- 
Pierre

@pierrejoye | http://blog.thepimp.net | http://www.libgd.org

--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] svn: /php/php-src/ branches/PHP_5_4/sapi/cli/php_cli_server.c trunk/sapi/cli/php_cli_server.c

2011-09-21 Thread Xinchen Hui
laruence Wed, 21 Sep 2011 06:59:47 +

Revision: http://svn.php.net/viewvc?view=revisionrevision=317078

Log:
Remove double checking, and use MAXPATHLEN instead of a fixed length

Changed paths:
U   php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c
U   php/php-src/trunk/sapi/cli/php_cli_server.c

Modified: php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c
===
--- php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c  2011-09-21 
05:20:12 UTC (rev 317077)
+++ php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c  2011-09-21 
06:59:47 UTC (rev 317078)
@@ -1880,17 +1880,12 @@
}
{
zend_file_handle zfd;
-#if HAVE_BROKEN_GETCWD
-   int old_cwd_fd = -1;
-   old_cwd_fd = open(., 0);
-#else
char *old_cwd;
+
ALLOCA_FLAG(use_heap)
-#define OLD_CWD_SIZE 4096
-   old_cwd = do_alloca(OLD_CWD_SIZE, use_heap);
+   old_cwd = do_alloca(MAXPATHLEN, use_heap);
old_cwd[0] = '\0';
-   php_ignore_value(VCWD_GETCWD(old_cwd, OLD_CWD_SIZE-1));
-#endif
+   php_ignore_value(VCWD_GETCWD(old_cwd, MAXPATHLEN - 1));

zfd.type = ZEND_HANDLE_FILENAME;
zfd.filename = server-router;
@@ -1910,17 +1905,11 @@
}
} zend_end_try();

-#if HAVE_BROKEN_GETCWD
-   if (old_cwd_fd != -1) {
-   fchdir(old_cwd_fd);
-   close(old_cwd_fd);
-   }
-#else
if (old_cwd[0] != '\0') {
php_ignore_value(VCWD_CHDIR(old_cwd));
}
+
free_alloca(old_cwd, use_heap);
-#endif
}

if (decline) {

Modified: php/php-src/trunk/sapi/cli/php_cli_server.c
===
--- php/php-src/trunk/sapi/cli/php_cli_server.c 2011-09-21 05:20:12 UTC (rev 
317077)
+++ php/php-src/trunk/sapi/cli/php_cli_server.c 2011-09-21 06:59:47 UTC (rev 
317078)
@@ -1880,17 +1880,12 @@
}
{
zend_file_handle zfd;
-#if HAVE_BROKEN_GETCWD
-   int old_cwd_fd = -1;
-   old_cwd_fd = open(., 0);
-#else
char *old_cwd;
+
ALLOCA_FLAG(use_heap)
-#define OLD_CWD_SIZE 4096
-   old_cwd = do_alloca(OLD_CWD_SIZE, use_heap);
+   old_cwd = do_alloca(MAXPATHLEN, use_heap);
old_cwd[0] = '\0';
-   php_ignore_value(VCWD_GETCWD(old_cwd, OLD_CWD_SIZE-1));
-#endif
+   php_ignore_value(VCWD_GETCWD(old_cwd, MAXPATHLEN - 1));

zfd.type = ZEND_HANDLE_FILENAME;
zfd.filename = server-router;
@@ -1910,17 +1905,11 @@
}
} zend_end_try();

-#if HAVE_BROKEN_GETCWD
-   if (old_cwd_fd != -1) {
-   fchdir(old_cwd_fd);
-   close(old_cwd_fd);
-   }
-#else
if (old_cwd[0] != '\0') {
php_ignore_value(VCWD_CHDIR(old_cwd));
}
+
free_alloca(old_cwd, use_heap);
-#endif
}

if (decline) {

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP-CVS] svn: /php/php-src/ branches/PHP_5_4/sapi/cli/php_cli_server.c trunk/sapi/cli/php_cli_server.c

2011-09-21 Thread Laruence
Hi:
   okey,

   in this case , I will remove it .


thanks

2011/9/21 Pierre Joye pierre@gmail.com:
 VCWD_GETCWD is sufficient.

 On Wed, Sep 21, 2011 at 1:49 AM, Moriyoshi Koizumi m...@mozo.jp wrote:
 Hi,

 Where does HAVE_BROKEN_GETCWD come from? Isn't simply using VCWD_GETCWD 
 sufficient?

 Moriyoshi

 On 2011/09/20, at 16:06, Xinchen Hui wrote:

 laruence                                 Tue, 20 Sep 2011 07:06:55 +

 Revision: http://svn.php.net/viewvc?view=revisionrevision=317040

 Log:
 Fix Bug #55726 (Changing the working directory makes router script 
 inaccessible)

 Bug: https://bugs.php.net/55726 (Assigned) Changing the working directory 
 makes router script inaccessible

 Changed paths:
    U   php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c
    U   php/php-src/trunk/sapi/cli/php_cli_server.c

 Modified: php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c
 ===
 --- php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c    2011-09-20 
 05:42:36 UTC (rev 317039)
 +++ php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c    2011-09-20 
 07:06:55 UTC (rev 317040)
 @@ -1877,11 +1877,24 @@
       }
       {
               zend_file_handle zfd;
 +#if HAVE_BROKEN_GETCWD
 +             int old_cwd_fd = -1;
 +             old_cwd_fd = open(., 0);
 +#else
 +             char *old_cwd;
 +             ALLOCA_FLAG(use_heap)
 +#define OLD_CWD_SIZE 4096
 +             old_cwd = do_alloca(OLD_CWD_SIZE, use_heap);
 +             old_cwd[0] = '\0';
 +             php_ignore_value(VCWD_GETCWD(old_cwd, OLD_CWD_SIZE-1));
 +#endif
 +
               zfd.type = ZEND_HANDLE_FILENAME;
               zfd.filename = server-router;
               zfd.handle.fp = NULL;
               zfd.free_filename = 0;
               zfd.opened_path = NULL;
 +
               zend_try {
                       zval *retval = NULL;
                       if (SUCCESS == zend_execute_scripts(ZEND_REQUIRE 
 TSRMLS_CC, retval, 1, zfd)) {
 @@ -1893,6 +1906,18 @@
                               decline = 1;
                       }
               } zend_end_try();
 +
 +#if HAVE_BROKEN_GETCWD
 +             if (old_cwd_fd != -1) {
 +                     fchdir(old_cwd_fd);
 +                     close(old_cwd_fd);
 +             }
 +#else
 +             if (old_cwd[0] != '\0') {
 +                     php_ignore_value(VCWD_CHDIR(old_cwd));
 +             }
 +             free_alloca(old_cwd, use_heap);
 +#endif
       }

       if (decline) {

 Modified: php/php-src/trunk/sapi/cli/php_cli_server.c
 ===
 --- php/php-src/trunk/sapi/cli/php_cli_server.c       2011-09-20 05:42:36 
 UTC (rev 317039)
 +++ php/php-src/trunk/sapi/cli/php_cli_server.c       2011-09-20 07:06:55 
 UTC (rev 317040)
 @@ -1877,11 +1877,24 @@
       }
       {
               zend_file_handle zfd;
 +#if HAVE_BROKEN_GETCWD
 +             int old_cwd_fd = -1;
 +             old_cwd_fd = open(., 0);
 +#else
 +             char *old_cwd;
 +             ALLOCA_FLAG(use_heap)
 +#define OLD_CWD_SIZE 4096
 +             old_cwd = do_alloca(OLD_CWD_SIZE, use_heap);
 +             old_cwd[0] = '\0';
 +             php_ignore_value(VCWD_GETCWD(old_cwd, OLD_CWD_SIZE-1));
 +#endif
 +
               zfd.type = ZEND_HANDLE_FILENAME;
               zfd.filename = server-router;
               zfd.handle.fp = NULL;
               zfd.free_filename = 0;
               zfd.opened_path = NULL;
 +
               zend_try {
                       zval *retval = NULL;
                       if (SUCCESS == zend_execute_scripts(ZEND_REQUIRE 
 TSRMLS_CC, retval, 1, zfd)) {
 @@ -1893,6 +1906,18 @@
                               decline = 1;
                       }
               } zend_end_try();
 +
 +#if HAVE_BROKEN_GETCWD
 +             if (old_cwd_fd != -1) {
 +                     fchdir(old_cwd_fd);
 +                     close(old_cwd_fd);
 +             }
 +#else
 +             if (old_cwd[0] != '\0') {
 +                     php_ignore_value(VCWD_CHDIR(old_cwd));
 +             }
 +             free_alloca(old_cwd, use_heap);
 +#endif
       }

       if (decline) {

 --
 PHP CVS Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php

 --
 Moriyoshi Koizumi
 m...@mozo.jp




 --
 PHP CVS Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php





 --
 Pierre

 @pierrejoye | http://blog.thepimp.net | http://www.libgd.org




-- 
Laruence  Xinchen Hui
http://www.laruence.com/


[PHP-CVS] svn: /php/php-src/ branches/PHP_5_4/sapi/cli/php_cli_server.c trunk/sapi/cli/php_cli_server.c

2011-09-20 Thread Xinchen Hui
laruence Tue, 20 Sep 2011 07:06:55 +

Revision: http://svn.php.net/viewvc?view=revisionrevision=317040

Log:
Fix Bug #55726 (Changing the working directory makes router script inaccessible)

Bug: https://bugs.php.net/55726 (Assigned) Changing the working directory makes 
router script inaccessible
  
Changed paths:
U   php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c
U   php/php-src/trunk/sapi/cli/php_cli_server.c

Modified: php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c
===
--- php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c  2011-09-20 
05:42:36 UTC (rev 317039)
+++ php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c  2011-09-20 
07:06:55 UTC (rev 317040)
@@ -1877,11 +1877,24 @@
}
{
zend_file_handle zfd;
+#if HAVE_BROKEN_GETCWD
+   int old_cwd_fd = -1;
+   old_cwd_fd = open(., 0);
+#else
+   char *old_cwd;
+   ALLOCA_FLAG(use_heap)
+#define OLD_CWD_SIZE 4096
+   old_cwd = do_alloca(OLD_CWD_SIZE, use_heap);
+   old_cwd[0] = '\0';
+   php_ignore_value(VCWD_GETCWD(old_cwd, OLD_CWD_SIZE-1));
+#endif
+
zfd.type = ZEND_HANDLE_FILENAME;
zfd.filename = server-router;
zfd.handle.fp = NULL;
zfd.free_filename = 0;
zfd.opened_path = NULL;
+
zend_try {
zval *retval = NULL;
if (SUCCESS == zend_execute_scripts(ZEND_REQUIRE 
TSRMLS_CC, retval, 1, zfd)) {
@@ -1893,6 +1906,18 @@
decline = 1;
}
} zend_end_try();
+
+#if HAVE_BROKEN_GETCWD
+   if (old_cwd_fd != -1) {
+   fchdir(old_cwd_fd);
+   close(old_cwd_fd);
+   }
+#else
+   if (old_cwd[0] != '\0') {
+   php_ignore_value(VCWD_CHDIR(old_cwd));
+   }
+   free_alloca(old_cwd, use_heap);
+#endif
}

if (decline) {

Modified: php/php-src/trunk/sapi/cli/php_cli_server.c
===
--- php/php-src/trunk/sapi/cli/php_cli_server.c 2011-09-20 05:42:36 UTC (rev 
317039)
+++ php/php-src/trunk/sapi/cli/php_cli_server.c 2011-09-20 07:06:55 UTC (rev 
317040)
@@ -1877,11 +1877,24 @@
}
{
zend_file_handle zfd;
+#if HAVE_BROKEN_GETCWD
+   int old_cwd_fd = -1;
+   old_cwd_fd = open(., 0);
+#else
+   char *old_cwd;
+   ALLOCA_FLAG(use_heap)
+#define OLD_CWD_SIZE 4096
+   old_cwd = do_alloca(OLD_CWD_SIZE, use_heap);
+   old_cwd[0] = '\0';
+   php_ignore_value(VCWD_GETCWD(old_cwd, OLD_CWD_SIZE-1));
+#endif
+
zfd.type = ZEND_HANDLE_FILENAME;
zfd.filename = server-router;
zfd.handle.fp = NULL;
zfd.free_filename = 0;
zfd.opened_path = NULL;
+
zend_try {
zval *retval = NULL;
if (SUCCESS == zend_execute_scripts(ZEND_REQUIRE 
TSRMLS_CC, retval, 1, zfd)) {
@@ -1893,6 +1906,18 @@
decline = 1;
}
} zend_end_try();
+
+#if HAVE_BROKEN_GETCWD
+   if (old_cwd_fd != -1) {
+   fchdir(old_cwd_fd);
+   close(old_cwd_fd);
+   }
+#else
+   if (old_cwd[0] != '\0') {
+   php_ignore_value(VCWD_CHDIR(old_cwd));
+   }
+   free_alloca(old_cwd, use_heap);
+#endif
}

if (decline) {

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP-CVS] svn: /php/php-src/ branches/PHP_5_4/sapi/cli/php_cli_server.c trunk/sapi/cli/php_cli_server.c

2011-09-20 Thread Moriyoshi Koizumi
Hi,

Where does HAVE_BROKEN_GETCWD come from? Isn't simply using VCWD_GETCWD 
sufficient?

Moriyoshi

On 2011/09/20, at 16:06, Xinchen Hui wrote:

 laruence Tue, 20 Sep 2011 07:06:55 +
 
 Revision: http://svn.php.net/viewvc?view=revisionrevision=317040
 
 Log:
 Fix Bug #55726 (Changing the working directory makes router script 
 inaccessible)
 
 Bug: https://bugs.php.net/55726 (Assigned) Changing the working directory 
 makes router script inaccessible
 
 Changed paths:
U   php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c
U   php/php-src/trunk/sapi/cli/php_cli_server.c
 
 Modified: php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c
 ===
 --- php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c2011-09-20 
 05:42:36 UTC (rev 317039)
 +++ php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c2011-09-20 
 07:06:55 UTC (rev 317040)
 @@ -1877,11 +1877,24 @@
   }
   {
   zend_file_handle zfd;
 +#if HAVE_BROKEN_GETCWD
 + int old_cwd_fd = -1;
 + old_cwd_fd = open(., 0);
 +#else
 + char *old_cwd;
 + ALLOCA_FLAG(use_heap)
 +#define OLD_CWD_SIZE 4096
 + old_cwd = do_alloca(OLD_CWD_SIZE, use_heap);
 + old_cwd[0] = '\0';
 + php_ignore_value(VCWD_GETCWD(old_cwd, OLD_CWD_SIZE-1));
 +#endif
 +
   zfd.type = ZEND_HANDLE_FILENAME;
   zfd.filename = server-router;
   zfd.handle.fp = NULL;
   zfd.free_filename = 0;
   zfd.opened_path = NULL;
 +
   zend_try {
   zval *retval = NULL;
   if (SUCCESS == zend_execute_scripts(ZEND_REQUIRE 
 TSRMLS_CC, retval, 1, zfd)) {
 @@ -1893,6 +1906,18 @@
   decline = 1;
   }
   } zend_end_try();
 +
 +#if HAVE_BROKEN_GETCWD
 + if (old_cwd_fd != -1) {
 + fchdir(old_cwd_fd);
 + close(old_cwd_fd);
 + }
 +#else
 + if (old_cwd[0] != '\0') {
 + php_ignore_value(VCWD_CHDIR(old_cwd));
 + }
 + free_alloca(old_cwd, use_heap);
 +#endif
   }
 
   if (decline) {
 
 Modified: php/php-src/trunk/sapi/cli/php_cli_server.c
 ===
 --- php/php-src/trunk/sapi/cli/php_cli_server.c   2011-09-20 05:42:36 UTC 
 (rev 317039)
 +++ php/php-src/trunk/sapi/cli/php_cli_server.c   2011-09-20 07:06:55 UTC 
 (rev 317040)
 @@ -1877,11 +1877,24 @@
   }
   {
   zend_file_handle zfd;
 +#if HAVE_BROKEN_GETCWD
 + int old_cwd_fd = -1;
 + old_cwd_fd = open(., 0);
 +#else
 + char *old_cwd;
 + ALLOCA_FLAG(use_heap)
 +#define OLD_CWD_SIZE 4096
 + old_cwd = do_alloca(OLD_CWD_SIZE, use_heap);
 + old_cwd[0] = '\0';
 + php_ignore_value(VCWD_GETCWD(old_cwd, OLD_CWD_SIZE-1));
 +#endif
 +
   zfd.type = ZEND_HANDLE_FILENAME;
   zfd.filename = server-router;
   zfd.handle.fp = NULL;
   zfd.free_filename = 0;
   zfd.opened_path = NULL;
 +
   zend_try {
   zval *retval = NULL;
   if (SUCCESS == zend_execute_scripts(ZEND_REQUIRE 
 TSRMLS_CC, retval, 1, zfd)) {
 @@ -1893,6 +1906,18 @@
   decline = 1;
   }
   } zend_end_try();
 +
 +#if HAVE_BROKEN_GETCWD
 + if (old_cwd_fd != -1) {
 + fchdir(old_cwd_fd);
 + close(old_cwd_fd);
 + }
 +#else
 + if (old_cwd[0] != '\0') {
 + php_ignore_value(VCWD_CHDIR(old_cwd));
 + }
 + free_alloca(old_cwd, use_heap);
 +#endif
   }
 
   if (decline) {
 
 -- 
 PHP CVS Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php

-- 
Moriyoshi Koizumi
m...@mozo.jp




--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-CVS] svn: /php/php-src/ branches/PHP_5_4/sapi/cli/php_cli_server.c trunk/sapi/cli/php_cli_server.c

2011-09-20 Thread Xinchen Hui
hi:
  I wam only use VCWD At the first time,then I found broken_get Ed in
main/main.c , so I added it too, I think this would be safer.

Thanks

Sent from my iPhone

在 2011-9-21,7:50,Moriyoshi Koizumi m...@mozo.jp 写道:

 Hi,

 Where does HAVE_BROKEN_GETCWD come from? Isn't simply using VCWD_GETCWD 
 sufficient?

 Moriyoshi

 On 2011/09/20, at 16:06, Xinchen Hui wrote:

 laruence Tue, 20 Sep 2011 07:06:55 +

 Revision: http://svn.php.net/viewvc?view=revisionrevision=317040

 Log:
 Fix Bug #55726 (Changing the working directory makes router script 
 inaccessible)

 Bug: https://bugs.php.net/55726 (Assigned) Changing the working directory 
 makes router script inaccessible

 Changed paths:
   U   php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c
   U   php/php-src/trunk/sapi/cli/php_cli_server.c

 Modified: php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c
 ===
 --- php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c2011-09-20 
 05:42:36 UTC (rev 317039)
 +++ php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c2011-09-20 
 07:06:55 UTC (rev 317040)
 @@ -1877,11 +1877,24 @@
}
{
zend_file_handle zfd;
 +#if HAVE_BROKEN_GETCWD
 +int old_cwd_fd = -1;
 +old_cwd_fd = open(., 0);
 +#else
 +char *old_cwd;
 +ALLOCA_FLAG(use_heap)
 +#define OLD_CWD_SIZE 4096
 +old_cwd = do_alloca(OLD_CWD_SIZE, use_heap);
 +old_cwd[0] = '\0';
 +php_ignore_value(VCWD_GETCWD(old_cwd, OLD_CWD_SIZE-1));
 +#endif
 +
zfd.type = ZEND_HANDLE_FILENAME;
zfd.filename = server-router;
zfd.handle.fp = NULL;
zfd.free_filename = 0;
zfd.opened_path = NULL;
 +
zend_try {
zval *retval = NULL;
if (SUCCESS == zend_execute_scripts(ZEND_REQUIRE TSRMLS_CC, 
 retval, 1, zfd)) {
 @@ -1893,6 +1906,18 @@
decline = 1;
}
} zend_end_try();
 +
 +#if HAVE_BROKEN_GETCWD
 +if (old_cwd_fd != -1) {
 +fchdir(old_cwd_fd);
 +close(old_cwd_fd);
 +}
 +#else
 +if (old_cwd[0] != '\0') {
 +php_ignore_value(VCWD_CHDIR(old_cwd));
 +}
 +free_alloca(old_cwd, use_heap);
 +#endif
}

if (decline) {

 Modified: php/php-src/trunk/sapi/cli/php_cli_server.c
 ===
 --- php/php-src/trunk/sapi/cli/php_cli_server.c2011-09-20 05:42:36 UTC 
 (rev 317039)
 +++ php/php-src/trunk/sapi/cli/php_cli_server.c2011-09-20 07:06:55 UTC 
 (rev 317040)
 @@ -1877,11 +1877,24 @@
}
{
zend_file_handle zfd;
 +#if HAVE_BROKEN_GETCWD
 +int old_cwd_fd = -1;
 +old_cwd_fd = open(., 0);
 +#else
 +char *old_cwd;
 +ALLOCA_FLAG(use_heap)
 +#define OLD_CWD_SIZE 4096
 +old_cwd = do_alloca(OLD_CWD_SIZE, use_heap);
 +old_cwd[0] = '\0';
 +php_ignore_value(VCWD_GETCWD(old_cwd, OLD_CWD_SIZE-1));
 +#endif
 +
zfd.type = ZEND_HANDLE_FILENAME;
zfd.filename = server-router;
zfd.handle.fp = NULL;
zfd.free_filename = 0;
zfd.opened_path = NULL;
 +
zend_try {
zval *retval = NULL;
if (SUCCESS == zend_execute_scripts(ZEND_REQUIRE TSRMLS_CC, 
 retval, 1, zfd)) {
 @@ -1893,6 +1906,18 @@
decline = 1;
}
} zend_end_try();
 +
 +#if HAVE_BROKEN_GETCWD
 +if (old_cwd_fd != -1) {
 +fchdir(old_cwd_fd);
 +close(old_cwd_fd);
 +}
 +#else
 +if (old_cwd[0] != '\0') {
 +php_ignore_value(VCWD_CHDIR(old_cwd));
 +}
 +free_alloca(old_cwd, use_heap);
 +#endif
}

if (decline) {

 --
 PHP CVS Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php

 --
 Moriyoshi Koizumi
 m...@mozo.jp




--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-CVS] svn: /php/php-src/ branches/PHP_5_4/sapi/cli/php_cli_server.c trunk/sapi/cli/php_cli_server.c

2011-09-20 Thread Xinchen Hui
s ,wam,was,
s ,get Ed, getcwd,

Thanks

Sent from my iPhone

在 2011-9-21,9:30,Xinchen Hui larue...@gmail.com 写道:

 hi:
  I wam only use VCWD At the first time,then I found broken_get Ed in
 main/main.c , so I added it too, I think this would be safer.

 Thanks

 Sent from my iPhone

 在 2011-9-21,7:50,Moriyoshi Koizumi m...@mozo.jp 写道:

 Hi,

 Where does HAVE_BROKEN_GETCWD come from? Isn't simply using VCWD_GETCWD 
 sufficient?

 Moriyoshi

 On 2011/09/20, at 16:06, Xinchen Hui wrote:

 laruence Tue, 20 Sep 2011 07:06:55 +

 Revision: http://svn.php.net/viewvc?view=revisionrevision=317040

 Log:
 Fix Bug #55726 (Changing the working directory makes router script 
 inaccessible)

 Bug: https://bugs.php.net/55726 (Assigned) Changing the working directory 
 makes router script inaccessible

 Changed paths:
  U   php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c
  U   php/php-src/trunk/sapi/cli/php_cli_server.c

 Modified: php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c
 ===
 --- php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c2011-09-20 
 05:42:36 UTC (rev 317039)
 +++ php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c2011-09-20 
 07:06:55 UTC (rev 317040)
 @@ -1877,11 +1877,24 @@
   }
   {
   zend_file_handle zfd;
 +#if HAVE_BROKEN_GETCWD
 +int old_cwd_fd = -1;
 +old_cwd_fd = open(., 0);
 +#else
 +char *old_cwd;
 +ALLOCA_FLAG(use_heap)
 +#define OLD_CWD_SIZE 4096
 +old_cwd = do_alloca(OLD_CWD_SIZE, use_heap);
 +old_cwd[0] = '\0';
 +php_ignore_value(VCWD_GETCWD(old_cwd, OLD_CWD_SIZE-1));
 +#endif
 +
   zfd.type = ZEND_HANDLE_FILENAME;
   zfd.filename = server-router;
   zfd.handle.fp = NULL;
   zfd.free_filename = 0;
   zfd.opened_path = NULL;
 +
   zend_try {
   zval *retval = NULL;
   if (SUCCESS == zend_execute_scripts(ZEND_REQUIRE TSRMLS_CC, 
 retval, 1, zfd)) {
 @@ -1893,6 +1906,18 @@
   decline = 1;
   }
   } zend_end_try();
 +
 +#if HAVE_BROKEN_GETCWD
 +if (old_cwd_fd != -1) {
 +fchdir(old_cwd_fd);
 +close(old_cwd_fd);
 +}
 +#else
 +if (old_cwd[0] != '\0') {
 +php_ignore_value(VCWD_CHDIR(old_cwd));
 +}
 +free_alloca(old_cwd, use_heap);
 +#endif
   }

   if (decline) {

 Modified: php/php-src/trunk/sapi/cli/php_cli_server.c
 ===
 --- php/php-src/trunk/sapi/cli/php_cli_server.c2011-09-20 05:42:36 UTC 
 (rev 317039)
 +++ php/php-src/trunk/sapi/cli/php_cli_server.c2011-09-20 07:06:55 UTC 
 (rev 317040)
 @@ -1877,11 +1877,24 @@
   }
   {
   zend_file_handle zfd;
 +#if HAVE_BROKEN_GETCWD
 +int old_cwd_fd = -1;
 +old_cwd_fd = open(., 0);
 +#else
 +char *old_cwd;
 +ALLOCA_FLAG(use_heap)
 +#define OLD_CWD_SIZE 4096
 +old_cwd = do_alloca(OLD_CWD_SIZE, use_heap);
 +old_cwd[0] = '\0';
 +php_ignore_value(VCWD_GETCWD(old_cwd, OLD_CWD_SIZE-1));
 +#endif
 +
   zfd.type = ZEND_HANDLE_FILENAME;
   zfd.filename = server-router;
   zfd.handle.fp = NULL;
   zfd.free_filename = 0;
   zfd.opened_path = NULL;
 +
   zend_try {
   zval *retval = NULL;
   if (SUCCESS == zend_execute_scripts(ZEND_REQUIRE TSRMLS_CC, 
 retval, 1, zfd)) {
 @@ -1893,6 +1906,18 @@
   decline = 1;
   }
   } zend_end_try();
 +
 +#if HAVE_BROKEN_GETCWD
 +if (old_cwd_fd != -1) {
 +fchdir(old_cwd_fd);
 +close(old_cwd_fd);
 +}
 +#else
 +if (old_cwd[0] != '\0') {
 +php_ignore_value(VCWD_CHDIR(old_cwd));
 +}
 +free_alloca(old_cwd, use_heap);
 +#endif
   }

   if (decline) {

 --
 PHP CVS Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php

 --
 Moriyoshi Koizumi
 m...@mozo.jp




--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] svn: /php/php-src/ branches/PHP_5_4/sapi/cli/php_cli_server.c trunk/sapi/cli/php_cli_server.c

2011-09-20 Thread Xinchen Hui
laruence Wed, 21 Sep 2011 03:16:35 +

Revision: http://svn.php.net/viewvc?view=revisionrevision=317075

Log:
Change to a more appropriate name

Changed paths:
U   php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c
U   php/php-src/trunk/sapi/cli/php_cli_server.c

Modified: php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c
===
--- php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c  2011-09-21 
03:09:42 UTC (rev 317074)
+++ php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c  2011-09-21 
03:16:35 UTC (rev 317075)
@@ -524,7 +524,7 @@
}
 } /* }}} */

-static int sapi_cli_server_register_client_headers(char **entry TSRMLS_DC, int 
num_args, va_list args, zend_hash_key *hash_key) /* {{{ */ {
+static int sapi_cli_server_register_entry_cb(char **entry TSRMLS_DC, int 
num_args, va_list args, zend_hash_key *hash_key) /* {{{ */ {
zval *track_vars_array = va_arg(args, zval *);
if (hash_key-nKeyLength) {
char *real_key, *key;
@@ -583,7 +583,7 @@
if (client-request.query_string) {
sapi_cli_server_register_variable(track_vars_array, 
QUERY_STRING, client-request.query_string TSRMLS_CC);
}
-   zend_hash_apply_with_arguments(client-request.headers TSRMLS_CC, 
(apply_func_args_t)sapi_cli_server_register_client_headers, 1, 
track_vars_array);
+   zend_hash_apply_with_arguments(client-request.headers TSRMLS_CC, 
(apply_func_args_t)sapi_cli_server_register_entry_cb, 1, track_vars_array);
 } /* }}} */

 static void sapi_cli_server_log_message(char *msg TSRMLS_DC) /* {{{ */

Modified: php/php-src/trunk/sapi/cli/php_cli_server.c
===
--- php/php-src/trunk/sapi/cli/php_cli_server.c 2011-09-21 03:09:42 UTC (rev 
317074)
+++ php/php-src/trunk/sapi/cli/php_cli_server.c 2011-09-21 03:16:35 UTC (rev 
317075)
@@ -524,7 +524,7 @@
}
 } /* }}} */

-static int sapi_cli_server_register_client_headers(char **entry TSRMLS_DC, int 
num_args, va_list args, zend_hash_key *hash_key) /* {{{ */ {
+static int sapi_cli_server_register_entry_cb(char **entry TSRMLS_DC, int 
num_args, va_list args, zend_hash_key *hash_key) /* {{{ */ {
zval *track_vars_array = va_arg(args, zval *);
if (hash_key-nKeyLength) {
char *real_key, *key;
@@ -583,7 +583,7 @@
if (client-request.query_string) {
sapi_cli_server_register_variable(track_vars_array, 
QUERY_STRING, client-request.query_string TSRMLS_CC);
}
-   zend_hash_apply_with_arguments(client-request.headers TSRMLS_CC, 
(apply_func_args_t)sapi_cli_server_register_client_headers, 1, 
track_vars_array);
+   zend_hash_apply_with_arguments(client-request.headers TSRMLS_CC, 
(apply_func_args_t)sapi_cli_server_register_entry_cb, 1, track_vars_array);
 } /* }}} */

 static void sapi_cli_server_log_message(char *msg TSRMLS_DC) /* {{{ */

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[PHP-CVS] svn: /php/php-src/ branches/PHP_5_4/sapi/cli/php_cli_server.c trunk/sapi/cli/php_cli_server.c

2011-09-19 Thread Xinchen Hui
laruence Tue, 20 Sep 2011 05:07:15 +

Revision: http://svn.php.net/viewvc?view=revisionrevision=317037

Log:
Fix folder

Changed paths:
U   php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c
U   php/php-src/trunk/sapi/cli/php_cli_server.c

Modified: php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c
===
--- php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c  2011-09-20 
03:02:49 UTC (rev 317036)
+++ php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c  2011-09-20 
05:07:15 UTC (rev 317037)
@@ -1537,7 +1537,7 @@
 }
 /* }}} */

-static size_t php_cli_server_client_send_through(php_cli_server_client 
*client, const char *str, size_t str_len) /* }}} */
+static size_t php_cli_server_client_send_through(php_cli_server_client 
*client, const char *str, size_t str_len) /* {{{ */
 {
struct timeval tv = { 10, 0 };
ssize_t nbytes_left = str_len;
@@ -1935,6 +1935,7 @@
php_cli_server_close_connection(server, client TSRMLS_CC);
return SUCCESS;
 }
+/* }}} */

 static void php_cli_server_dtor(php_cli_server *server TSRMLS_DC) /* {{{ */
 {
@@ -2133,7 +2134,7 @@
int(*whandler)(php_cli_server*, php_cli_server_client* TSRMLS_DC);
 } php_cli_server_do_event_for_each_fd_callback_params;

-static int php_cli_server_do_event_for_each_fd_callback(void *_params, int fd, 
int event)
+static int php_cli_server_do_event_for_each_fd_callback(void *_params, int fd, 
int event) /* {{{ */
 {
php_cli_server_do_event_for_each_fd_callback_params *params = _params;
 #ifdef ZTS
@@ -2185,7 +2186,7 @@
}
}
return SUCCESS;
-}
+} /* }}} */

 static void php_cli_server_do_event_for_each_fd(php_cli_server *server, 
int(*rhandler)(php_cli_server*, php_cli_server_client* TSRMLS_DC), 
int(*whandler)(php_cli_server*, php_cli_server_client* TSRMLS_DC) TSRMLS_DC) /* 
{{{ */
 {
@@ -2228,13 +2229,13 @@
return retval;
 } /* }}} */

-
 static php_cli_server server;

-static void php_cli_server_sigint_handler(int sig)
+static void php_cli_server_sigint_handler(int sig) /* {{{ */
 {
server.is_running = 0;
-};
+}
+/* }}} */

 int do_cli_server(int argc, char **argv TSRMLS_DC) /* {{{ */
 {

Modified: php/php-src/trunk/sapi/cli/php_cli_server.c
===
--- php/php-src/trunk/sapi/cli/php_cli_server.c 2011-09-20 03:02:49 UTC (rev 
317036)
+++ php/php-src/trunk/sapi/cli/php_cli_server.c 2011-09-20 05:07:15 UTC (rev 
317037)
@@ -1537,7 +1537,7 @@
 }
 /* }}} */

-static size_t php_cli_server_client_send_through(php_cli_server_client 
*client, const char *str, size_t str_len) /* }}} */
+static size_t php_cli_server_client_send_through(php_cli_server_client 
*client, const char *str, size_t str_len) /* {{{ */
 {
struct timeval tv = { 10, 0 };
ssize_t nbytes_left = str_len;
@@ -1935,6 +1935,7 @@
php_cli_server_close_connection(server, client TSRMLS_CC);
return SUCCESS;
 }
+/* }}} */

 static void php_cli_server_dtor(php_cli_server *server TSRMLS_DC) /* {{{ */
 {
@@ -2133,7 +2134,7 @@
int(*whandler)(php_cli_server*, php_cli_server_client* TSRMLS_DC);
 } php_cli_server_do_event_for_each_fd_callback_params;

-static int php_cli_server_do_event_for_each_fd_callback(void *_params, int fd, 
int event)
+static int php_cli_server_do_event_for_each_fd_callback(void *_params, int fd, 
int event) /* {{{ */
 {
php_cli_server_do_event_for_each_fd_callback_params *params = _params;
 #ifdef ZTS
@@ -2185,7 +2186,7 @@
}
}
return SUCCESS;
-}
+} /* }}} */

 static void php_cli_server_do_event_for_each_fd(php_cli_server *server, 
int(*rhandler)(php_cli_server*, php_cli_server_client* TSRMLS_DC), 
int(*whandler)(php_cli_server*, php_cli_server_client* TSRMLS_DC) TSRMLS_DC) /* 
{{{ */
 {
@@ -2228,13 +2229,13 @@
return retval;
 } /* }}} */

-
 static php_cli_server server;

-static void php_cli_server_sigint_handler(int sig)
+static void php_cli_server_sigint_handler(int sig) /* {{{ */
 {
server.is_running = 0;
-};
+}
+/* }}} */

 int do_cli_server(int argc, char **argv TSRMLS_DC) /* {{{ */
 {

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[PHP-CVS] svn: /php/php-src/ branches/PHP_5_4/sapi/cli/php_cli_server.c trunk/sapi/cli/php_cli_server.c

2011-09-06 Thread Xinchen Hui
laruence Wed, 07 Sep 2011 05:14:54 +

Revision: http://svn.php.net/viewvc?view=revisionrevision=316298

Log:
Fixed Bug #55423(cli-server could not output correctly in some case)

Bug: https://bugs.php.net/55423 (Open) cli-server could not output correctly in 
some case.
  
Changed paths:
U   php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c
U   php/php-src/trunk/sapi/cli/php_cli_server.c

Modified: php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c
===
--- php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c  2011-09-07 
01:06:30 UTC (rev 316297)
+++ php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c  2011-09-07 
05:14:54 UTC (rev 316298)
@@ -1542,7 +1542,7 @@
struct timeval tv = { 10, 0 };
ssize_t nbytes_left = str_len;
do {
-   ssize_t nbytes_sent = send(client-sock, str, str_len, 0);
+   ssize_t nbytes_sent = send(client-sock, str + str_len - 
nbytes_left, nbytes_left, 0);
if (nbytes_sent  0) {
int err = php_socket_errno();
if (err == EAGAIN) {

Modified: php/php-src/trunk/sapi/cli/php_cli_server.c
===
--- php/php-src/trunk/sapi/cli/php_cli_server.c 2011-09-07 01:06:30 UTC (rev 
316297)
+++ php/php-src/trunk/sapi/cli/php_cli_server.c 2011-09-07 05:14:54 UTC (rev 
316298)
@@ -1542,7 +1542,7 @@
struct timeval tv = { 10, 0 };
ssize_t nbytes_left = str_len;
do {
-   ssize_t nbytes_sent = send(client-sock, str, str_len, 0);
+   ssize_t nbytes_sent = send(client-sock, str + str_len - 
nbytes_left, nbytes_left, 0);
if (nbytes_sent  0) {
int err = php_socket_errno();
if (err == EAGAIN) {

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[PHP-CVS] svn: /php/php-src/ branches/PHP_5_4/sapi/cli/php_cli_server.c trunk/sapi/cli/php_cli_server.c

2011-08-22 Thread Xinchen Hui
laruence Mon, 22 Aug 2011 15:51:49 +

Revision: http://svn.php.net/viewvc?view=revisionrevision=315300

Log:
Added _SERVER[SERVER_SOFTWARE] for built-in server

Changed paths:
U   php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c
U   php/php-src/trunk/sapi/cli/php_cli_server.c

Modified: php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c
===
--- php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c  2011-08-22 
15:27:22 UTC (rev 315299)
+++ php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c  2011-08-22 
15:51:49 UTC (rev 315300)
@@ -509,6 +509,12 @@
} else {
sapi_cli_server_register_variable(track_vars_array, 
REMOTE_ADDR, client-addr_str TSRMLS_CC);
}
+   }
+   {
+   char *tmp;
+   spprintf(tmp, 0, PHP %s Development Server, PHP_VERSION);
+   sapi_cli_server_register_variable(track_vars_array, 
SERVER_SOFTWARE, tmp TSRMLS_CC);
+   efree(tmp);
}
sapi_cli_server_register_variable(track_vars_array, REQUEST_URI, 
client-request.request_uri TSRMLS_CC);
sapi_cli_server_register_variable(track_vars_array, REQUEST_METHOD, 
SG(request_info).request_method TSRMLS_CC);

Modified: php/php-src/trunk/sapi/cli/php_cli_server.c
===
--- php/php-src/trunk/sapi/cli/php_cli_server.c 2011-08-22 15:27:22 UTC (rev 
315299)
+++ php/php-src/trunk/sapi/cli/php_cli_server.c 2011-08-22 15:51:49 UTC (rev 
315300)
@@ -509,6 +509,12 @@
} else {
sapi_cli_server_register_variable(track_vars_array, 
REMOTE_ADDR, client-addr_str TSRMLS_CC);
}
+   }
+   {
+   char *tmp;
+   spprintf(tmp, 0, PHP %s Development Server, PHP_VERSION);
+   sapi_cli_server_register_variable(track_vars_array, 
SERVER_SOFTWARE, tmp TSRMLS_CC);
+   efree(tmp);
}
sapi_cli_server_register_variable(track_vars_array, REQUEST_URI, 
client-request.request_uri TSRMLS_CC);
sapi_cli_server_register_variable(track_vars_array, REQUEST_METHOD, 
SG(request_info).request_method TSRMLS_CC);

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[PHP-CVS] svn: /php/php-src/ branches/PHP_5_4/sapi/cli/php_cli_server.c trunk/sapi/cli/php_cli_server.c

2011-08-19 Thread Xinchen Hui
laruence Fri, 19 Aug 2011 08:30:26 +

Revision: http://svn.php.net/viewvc?view=revisionrevision=315162

Log:
Fixed #55450 (Built in web server not accepting file uploads), which might 
break #55121 fixing(r313677)
Reopened #55121 to let somebody redone the fixing(as I can't reproduce 55121 in 
redhat 64-bit).

Bugs: https://bugs.php.net/55450 (Assigned) Built in web server not accepting 
file uploads
  https://bugs.php.net/55121 (Re-Opened) Segfault with multipart/form-data 
POST / 404 request
  
Changed paths:
U   php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c
U   php/php-src/trunk/sapi/cli/php_cli_server.c

Modified: php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c
===
--- php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c  2011-08-19 
07:50:25 UTC (rev 315161)
+++ php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c  2011-08-19 
08:30:26 UTC (rev 315162)
@@ -1401,6 +1401,8 @@

 static void php_cli_server_client_populate_request_info(const 
php_cli_server_client *client, sapi_request_info *request_info) /* {{{ */
 {
+   char **val;
+
request_info-request_method = 
php_http_method_str(client-request.request_method);
request_info-proto_num = client-request.protocol_version;
request_info-request_uri = client-request.request_uri;
@@ -1408,12 +1410,8 @@
request_info-query_string = client-request.query_string;
request_info-post_data = client-request.content;
request_info-content_length = request_info-post_data_length = 
client-request.content_len;
-   {
-   char **val;
-   const char delimiter[] = ;;
-   if (SUCCESS == zend_hash_find(client-request.headers, 
Content-Type, sizeof(Content-Type), (void**)val)) {
-   request_info-content_type = strtok(*val, delimiter);
-   }
+   if (SUCCESS == zend_hash_find(client-request.headers, Content-Type, 
sizeof(Content-Type), (void**)val)) {
+   request_info-content_type = strtok(*val, delimiter);
}
 } /* }}} */


Modified: php/php-src/trunk/sapi/cli/php_cli_server.c
===
--- php/php-src/trunk/sapi/cli/php_cli_server.c 2011-08-19 07:50:25 UTC (rev 
315161)
+++ php/php-src/trunk/sapi/cli/php_cli_server.c 2011-08-19 08:30:26 UTC (rev 
315162)
@@ -1401,6 +1401,8 @@

 static void php_cli_server_client_populate_request_info(const 
php_cli_server_client *client, sapi_request_info *request_info) /* {{{ */
 {
+   char **val;
+
request_info-request_method = 
php_http_method_str(client-request.request_method);
request_info-proto_num = client-request.protocol_version;
request_info-request_uri = client-request.request_uri;
@@ -1408,12 +1410,8 @@
request_info-query_string = client-request.query_string;
request_info-post_data = client-request.content;
request_info-content_length = request_info-post_data_length = 
client-request.content_len;
-   {
-   char **val;
-   const char delimiter[] = ;;
-   if (SUCCESS == zend_hash_find(client-request.headers, 
Content-Type, sizeof(Content-Type), (void**)val)) {
-   request_info-content_type = strtok(*val, delimiter);
-   }
+   if (SUCCESS == zend_hash_find(client-request.headers, Content-Type, 
sizeof(Content-Type), (void**)val)) {
+   request_info-content_type = *val;
}
 } /* }}} */


-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[PHP-CVS] svn: /php/php-src/branches/PHP_5_4/sapi/cli/ php_cli_server.c

2011-08-19 Thread Xinchen Hui
laruence Fri, 19 Aug 2011 08:35:43 +

Revision: http://svn.php.net/viewvc?view=revisionrevision=315163

Log:
Fixed typo when syncing changes to branch

Changed paths:
U   php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c

Modified: php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c
===
--- php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c  2011-08-19 
08:30:26 UTC (rev 315162)
+++ php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c  2011-08-19 
08:35:43 UTC (rev 315163)
@@ -1411,7 +1411,7 @@
request_info-post_data = client-request.content;
request_info-content_length = request_info-post_data_length = 
client-request.content_len;
if (SUCCESS == zend_hash_find(client-request.headers, Content-Type, 
sizeof(Content-Type), (void**)val)) {
-   request_info-content_type = strtok(*val, delimiter);
+   request_info-content_type = *val;
}
 } /* }}} */


-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[PHP-CVS] svn: /php/php-src/ branches/PHP_5_4/sapi/cli/php_cli_server.c trunk/sapi/cli/php_cli_server.c

2011-08-07 Thread Rasmus Lerdorf
rasmus   Sun, 07 Aug 2011 15:52:46 +

Revision: http://svn.php.net/viewvc?view=revisionrevision=314436

Log:
Signed 1-bit bitfields make no sense

Changed paths:
U   php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c
U   php/php-src/trunk/sapi/cli/php_cli_server.c

Modified: php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c
===
--- php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c  2011-08-07 
15:45:18 UTC (rev 314435)
+++ php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c  2011-08-07 
15:52:46 UTC (rev 314436)
@@ -169,7 +169,7 @@
int content_sender_initialized:1;
php_cli_server_content_sender content_sender;
php_cli_server_buffer capture_buffer;
-   int capturing:1;
+   unsigned int capturing:1;
int file_fd;
 } php_cli_server_client;


Modified: php/php-src/trunk/sapi/cli/php_cli_server.c
===
--- php/php-src/trunk/sapi/cli/php_cli_server.c 2011-08-07 15:45:18 UTC (rev 
314435)
+++ php/php-src/trunk/sapi/cli/php_cli_server.c 2011-08-07 15:52:46 UTC (rev 
314436)
@@ -169,7 +169,7 @@
int content_sender_initialized:1;
php_cli_server_content_sender content_sender;
php_cli_server_buffer capture_buffer;
-   int capturing:1;
+   unsigned int capturing:1;
int file_fd;
 } php_cli_server_client;


-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[PHP-CVS] svn: /php/php-src/ branches/PHP_5_4/sapi/cli/php_cli_server.c trunk/sapi/cli/php_cli_server.c

2011-08-06 Thread Rasmus Lerdorf
rasmus   Sat, 06 Aug 2011 23:42:52 +

Revision: http://svn.php.net/viewvc?view=revisionrevision=314386

Log:
Avoid a potential double-free here

Changed paths:
U   php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c
U   php/php-src/trunk/sapi/cli/php_cli_server.c

Modified: php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c
===
--- php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c  2011-08-06 
23:34:13 UTC (rev 314385)
+++ php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c  2011-08-06 
23:42:52 UTC (rev 314386)
@@ -910,6 +910,7 @@
for (p = sal; *p; p++) {
if (sa) {
pefree(sa, 1);
+   sa = NULL;
}

retval = socket((*p)-sa_family, socktype, 0);

Modified: php/php-src/trunk/sapi/cli/php_cli_server.c
===
--- php/php-src/trunk/sapi/cli/php_cli_server.c 2011-08-06 23:34:13 UTC (rev 
314385)
+++ php/php-src/trunk/sapi/cli/php_cli_server.c 2011-08-06 23:42:52 UTC (rev 
314386)
@@ -910,6 +910,7 @@
for (p = sal; *p; p++) {
if (sa) {
pefree(sa, 1);
+   sa = NULL;
}

retval = socket((*p)-sa_family, socktype, 0);

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[PHP-CVS] svn: /php/php-src/ branches/PHP_5_4/sapi/cli/php_cli_server.c trunk/sapi/cli/php_cli_server.c

2011-07-25 Thread Florian Anderiasch
fa   Mon, 25 Jul 2011 16:45:39 +

Revision: http://svn.php.net/viewvc?view=revisionrevision=313677

Log:
Fix #55121 Segfault with multipart/form-data POST

Bug: https://bugs.php.net/55121 (Assigned) Segfault with multipart/form-data 
POST / 404 request
  
Changed paths:
U   php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c
U   php/php-src/trunk/sapi/cli/php_cli_server.c

Modified: php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c
===
--- php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c  2011-07-25 
15:35:10 UTC (rev 313676)
+++ php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c  2011-07-25 
16:45:39 UTC (rev 313677)
@@ -1409,8 +1409,9 @@
request_info-content_length = request_info-post_data_length = 
client-request.content_len;
{
char **val;
+   const char delimiter[] = ;;
if (SUCCESS == zend_hash_find(client-request.headers, 
Content-Type, sizeof(Content-Type), (void**)val)) {
-   request_info-content_type = *val;
+   request_info-content_type = strtok(*val, delimiter);
}
}
 } /* }}} */

Modified: php/php-src/trunk/sapi/cli/php_cli_server.c
===
--- php/php-src/trunk/sapi/cli/php_cli_server.c 2011-07-25 15:35:10 UTC (rev 
313676)
+++ php/php-src/trunk/sapi/cli/php_cli_server.c 2011-07-25 16:45:39 UTC (rev 
313677)
@@ -1409,8 +1409,9 @@
request_info-content_length = request_info-post_data_length = 
client-request.content_len;
{
char **val;
+   const char delimiter[] = ;;
if (SUCCESS == zend_hash_find(client-request.headers, 
Content-Type, sizeof(Content-Type), (void**)val)) {
-   request_info-content_type = *val;
+   request_info-content_type = strtok(*val, delimiter);
}
}
 } /* }}} */

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[PHP-CVS] svn: /php/php-src/ branches/PHP_5_4/sapi/cli/php_cli_server.c trunk/sapi/cli/php_cli_server.c

2011-07-23 Thread Moriyoshi Koizumi
moriyoshiSat, 23 Jul 2011 11:29:26 +

Revision: http://svn.php.net/viewvc?view=revisionrevision=313627

Log:
- Give index.php a precedence over index.html.  Patch by davidc.

Changed paths:
U   php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c
U   php/php-src/trunk/sapi/cli/php_cli_server.c

Modified: php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c
===
--- php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c  2011-07-23 
09:27:15 UTC (rev 313626)
+++ php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c  2011-07-23 
11:29:26 UTC (rev 313627)
@@ -1065,7 +1065,7 @@
 static void php_cli_server_request_translate_vpath(php_cli_server_request 
*request, const char *document_root, size_t document_root_len) /* {{{ */
 {
struct stat sb;
-   static const char *index_files[] = { index.html, index.php, NULL };
+   static const char *index_files[] = { index.php, index.html, NULL };
char *buf = safe_pemalloc(1, request-vpath_len, 1 + document_root_len 
+ 1 + sizeof(index.html), 1);
char *p = buf, *prev_patch = 0, *q, *vpath;
memmove(p, document_root, document_root_len);

Modified: php/php-src/trunk/sapi/cli/php_cli_server.c
===
--- php/php-src/trunk/sapi/cli/php_cli_server.c 2011-07-23 09:27:15 UTC (rev 
313626)
+++ php/php-src/trunk/sapi/cli/php_cli_server.c 2011-07-23 11:29:26 UTC (rev 
313627)
@@ -1065,7 +1065,7 @@
 static void php_cli_server_request_translate_vpath(php_cli_server_request 
*request, const char *document_root, size_t document_root_len) /* {{{ */
 {
struct stat sb;
-   static const char *index_files[] = { index.html, index.php, NULL };
+   static const char *index_files[] = { index.php, index.html, NULL };
char *buf = safe_pemalloc(1, request-vpath_len, 1 + document_root_len 
+ 1 + sizeof(index.html), 1);
char *p = buf, *prev_patch = 0, *q, *vpath;
memmove(p, document_root, document_root_len);

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[PHP-CVS] svn: /php/php-src/ branches/PHP_5_4/sapi/cli/php_cli_server.c trunk/sapi/cli/php_cli_server.c

2011-07-21 Thread Moriyoshi Koizumi
moriyoshiThu, 21 Jul 2011 07:31:29 +

Revision: http://svn.php.net/viewvc?view=revisionrevision=313496

Log:
- Show PHP_VERSION in the banner. Suggested by Chris and others.

Changed paths:
U   php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c
U   php/php-src/trunk/sapi/cli/php_cli_server.c

Modified: php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c
===
--- php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c  2011-07-21 
03:41:21 UTC (rev 313495)
+++ php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c  2011-07-21 
07:31:29 UTC (rev 313496)
@@ -2134,11 +2134,11 @@
gettimeofday(tv, NULL);
php_localtime_r(tv.tv_sec, tm);
php_asctime_r(tm, buf);
-   printf(PHP Development Server started at %s
+   printf(PHP %s Development Server started at %s
Listening on %s\n
Document root is %s\n
Press Ctrl-C to quit.\n,
-   buf, server_bind_address, document_root);
+   PHP_VERSION, buf, server_bind_address, 
document_root);
}

 #if defined(HAVE_SIGNAL_H)  defined(SIGINT)

Modified: php/php-src/trunk/sapi/cli/php_cli_server.c
===
--- php/php-src/trunk/sapi/cli/php_cli_server.c 2011-07-21 03:41:21 UTC (rev 
313495)
+++ php/php-src/trunk/sapi/cli/php_cli_server.c 2011-07-21 07:31:29 UTC (rev 
313496)
@@ -2134,11 +2134,11 @@
gettimeofday(tv, NULL);
php_localtime_r(tv.tv_sec, tm);
php_asctime_r(tm, buf);
-   printf(PHP Development Server started at %s
+   printf(PHP %s Development Server started at %s
Listening on %s\n
Document root is %s\n
Press Ctrl-C to quit.\n,
-   buf, server_bind_address, document_root);
+   PHP_VERSION, buf, server_bind_address, 
document_root);
}

 #if defined(HAVE_SIGNAL_H)  defined(SIGINT)

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[PHP-CVS] svn: /php/php-src/ branches/PHP_5_4/sapi/cli/php_cli_server.c trunk/sapi/cli/php_cli_server.c

2011-07-20 Thread Moriyoshi Koizumi
moriyoshiWed, 20 Jul 2011 08:43:12 +

Revision: http://svn.php.net/viewvc?view=revisionrevision=313466

Log:
- Better error handling.

Changed paths:
U   php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c
U   php/php-src/trunk/sapi/cli/php_cli_server.c

Modified: php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c
===
--- php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c  2011-07-20 
07:48:08 UTC (rev 313465)
+++ php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c  2011-07-20 
08:43:12 UTC (rev 313466)
@@ -1805,9 +1805,9 @@
int err = 0;
int port = 3000;
php_socket_t server_sock = SOCK_ERR;
+   char *p = NULL;

if (addr[0] == '[') {
-   char *p;
host = pestrdup(addr + 1, 1);
if (!host) {
return FAILURE;
@@ -1817,27 +1817,32 @@
*p++ = '\0';
if (*p == ':') {
port = strtol(p + 1, p, 10);
+   if (port = 0) {
+   p = NULL;
+   }
} else if (*p != '\0') {
p = NULL;
}
}
-   if (!p) {
-   fprintf(stderr, Invalid IPv6 address: %s\n, host);
-   retval = FAILURE;
-   goto out;
-   }
} else {
-   char *p;
host = pestrdup(addr, 1);
if (!host) {
return FAILURE;
}
-   p = strrchr(host, ':');
+   p = strchr(host, ':');
if (p) {
*p++ = '\0';
port = strtol(p, p, 10);
+   if (port = 0) {
+   p = NULL;
+   }
}
}
+   if (!p) {
+   fprintf(stderr, Invalid address: %s\n, addr);
+   retval = FAILURE;
+   goto out;
+   }

server_sock = php_network_listen_socket(host, port, SOCK_STREAM, 
server-address_family, server-socklen, errstr TSRMLS_CC);
if (server_sock == SOCK_ERR) {

Modified: php/php-src/trunk/sapi/cli/php_cli_server.c
===
--- php/php-src/trunk/sapi/cli/php_cli_server.c 2011-07-20 07:48:08 UTC (rev 
313465)
+++ php/php-src/trunk/sapi/cli/php_cli_server.c 2011-07-20 08:43:12 UTC (rev 
313466)
@@ -1805,9 +1805,9 @@
int err = 0;
int port = 3000;
php_socket_t server_sock = SOCK_ERR;
+   char *p = NULL;

if (addr[0] == '[') {
-   char *p;
host = pestrdup(addr + 1, 1);
if (!host) {
return FAILURE;
@@ -1817,27 +1817,32 @@
*p++ = '\0';
if (*p == ':') {
port = strtol(p + 1, p, 10);
+   if (port = 0) {
+   p = NULL;
+   }
} else if (*p != '\0') {
p = NULL;
}
}
-   if (!p) {
-   fprintf(stderr, Invalid IPv6 address: %s\n, host);
-   retval = FAILURE;
-   goto out;
-   }
} else {
-   char *p;
host = pestrdup(addr, 1);
if (!host) {
return FAILURE;
}
-   p = strrchr(host, ':');
+   p = strchr(host, ':');
if (p) {
*p++ = '\0';
port = strtol(p, p, 10);
+   if (port = 0) {
+   p = NULL;
+   }
}
}
+   if (!p) {
+   fprintf(stderr, Invalid address: %s\n, addr);
+   retval = FAILURE;
+   goto out;
+   }

server_sock = php_network_listen_socket(host, port, SOCK_STREAM, 
server-address_family, server-socklen, errstr TSRMLS_CC);
if (server_sock == SOCK_ERR) {

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[PHP-CVS] svn: /php/php-src/ branches/PHP_5_4/sapi/cli/php_cli_server.c trunk/sapi/cli/php_cli_server.c

2011-07-20 Thread Moriyoshi Koizumi
moriyoshiWed, 20 Jul 2011 09:00:20 +

Revision: http://svn.php.net/viewvc?view=revisionrevision=313467

Log:
Fixed bug #55071.  Maybe a bit overkill?

Bug: https://bugs.php.net/55071 (Re-Opened) Change in-built web server 
description
  
Changed paths:
U   php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c
U   php/php-src/trunk/sapi/cli/php_cli_server.c

Modified: php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c
===
--- php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c  2011-07-20 
08:43:12 UTC (rev 313466)
+++ php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c  2011-07-20 
09:00:20 UTC (rev 313467)
@@ -2127,7 +2127,19 @@
}
sapi_module.phpinfo_as_text = 0;

-   printf(PHP Development Server is listening on %s in %s ... Press 
Ctrl-C to quit.\n, server_bind_address, document_root);
+   {
+   struct timeval tv;
+   struct tm tm;
+   char buf[52];
+   gettimeofday(tv, NULL);
+   php_localtime_r(tv.tv_sec, tm);
+   php_asctime_r(tm, buf);
+   printf(PHP Development Server started at %s
+   Listening on %s\n
+   Document root is %s\n
+   Press Ctrl-C to quit.\n,
+   buf, server_bind_address, document_root);
+   }

 #if defined(HAVE_SIGNAL_H)  defined(SIGINT)
signal(SIGINT, php_cli_server_sigint_handler);

Modified: php/php-src/trunk/sapi/cli/php_cli_server.c
===
--- php/php-src/trunk/sapi/cli/php_cli_server.c 2011-07-20 08:43:12 UTC (rev 
313466)
+++ php/php-src/trunk/sapi/cli/php_cli_server.c 2011-07-20 09:00:20 UTC (rev 
313467)
@@ -2127,7 +2127,19 @@
}
sapi_module.phpinfo_as_text = 0;

-   printf(PHP Development Server is listening on %s in %s ... Press 
Ctrl-C to quit.\n, server_bind_address, document_root);
+   {
+   struct timeval tv;
+   struct tm tm;
+   char buf[52];
+   gettimeofday(tv, NULL);
+   php_localtime_r(tv.tv_sec, tm);
+   php_asctime_r(tm, buf);
+   printf(PHP Development Server started at %s
+   Listening on %s\n
+   Document root is %s\n
+   Press Ctrl-C to quit.\n,
+   buf, server_bind_address, document_root);
+   }

 #if defined(HAVE_SIGNAL_H)  defined(SIGINT)
signal(SIGINT, php_cli_server_sigint_handler);

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[PHP-CVS] svn: /php/php-src/ branches/PHP_5_4/sapi/cli/php_cli_server.c trunk/sapi/cli/php_cli_server.c

2011-07-19 Thread Moriyoshi Koizumi
moriyoshiTue, 19 Jul 2011 17:47:34 +

Revision: http://svn.php.net/viewvc?view=revisionrevision=313441

Log:
- Print HTTP method as well in the log.
- Print response code also when the request is processed by a script.
- Those changes partly closes #55109.

Bug: https://bugs.php.net/55109 (Assigned) Friendly log messages
  
Changed paths:
U   php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c
U   php/php-src/trunk/sapi/cli/php_cli_server.c

Modified: php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c
===
--- php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c  2011-07-19 
16:17:07 UTC (rev 313440)
+++ php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c  2011-07-19 
17:47:34 UTC (rev 313441)
@@ -1479,7 +1479,7 @@
 static void php_cli_server_close_connection(php_cli_server *server, 
php_cli_server_client *client TSRMLS_DC) /* {{{ */
 {
 #ifdef DEBUG
-   php_cli_server_logf(%s: Closing TSRMLS_CC, client-addr_str);
+   php_cli_server_logf(%s Closing TSRMLS_CC, client-addr_str);
 #endif
zend_hash_index_del(server-clients, client-sock);
 } /* }}} */
@@ -1575,7 +1575,7 @@
php_cli_server_buffer_prepend(client-content_sender.buffer, 
chunk);
}

-   php_cli_server_logf(%s: %s - Sending error page (%d) TSRMLS_CC, 
client-addr_str, client-request.request_uri, status);
+   php_cli_server_logf(%s %s %s - Sending error page (%d) TSRMLS_CC, 
client-addr_str, php_http_method_str(client-request.request_method), 
client-request.request_uri, status);
php_cli_server_poller_add(server-poller, POLLOUT, client-sock);
efree(escaped_request_uri);
return SUCCESS;
@@ -1612,6 +1612,8 @@
} zend_end_try();
}

+   php_cli_server_logf(%s %s %s - Response sent successfully (%d) 
TSRMLS_CC, client-addr_str, 
php_http_method_str(client-request.request_method), 
client-request.request_uri, SG(sapi_headers).http_response_code);
+
php_request_shutdown(0);
php_cli_server_close_connection(server, client TSRMLS_CC);
destroy_request_info(SG(request_info));
@@ -1627,10 +1629,10 @@
if (fd  0) {
char *errstr = get_last_error();
if (errstr) {
-   php_cli_server_logf(%s: %s - %s TSRMLS_CC, 
client-addr_str, client-request.request_uri, errstr);
+   php_cli_server_logf(%s %s %s - %s TSRMLS_CC, 
client-addr_str, php_http_method_str(client-request.request_method), 
client-request.request_uri, errstr);
pefree(errstr, 1);
} else {
-   php_cli_server_logf(%s: %s - ? TSRMLS_CC, 
client-addr_str, client-request.request_uri);
+   php_cli_server_logf(%s %s %s - ? TSRMLS_CC, 
client-addr_str, php_http_method_str(client-request.request_method), 
client-request.request_uri);
}
return php_cli_server_send_error_page(server, client, 404 
TSRMLS_CC);
}
@@ -1880,12 +1882,12 @@
char *errstr = NULL;
int status = php_cli_server_client_read_request(client, errstr 
TSRMLS_CC);
if (status  0) {
-   php_cli_server_logf(%s: Invalid request (%s) TSRMLS_CC, 
client-addr_str, errstr);
+   php_cli_server_logf(%s Invalid request (%s) TSRMLS_CC, 
client-addr_str, errstr);
efree(errstr);
php_cli_server_close_connection(server, client TSRMLS_CC);
return FAILURE;
} else if (status == 1) {
-   php_cli_server_logf(%s: %s TSRMLS_CC, client-addr_str, 
client-request.request_uri);
+   php_cli_server_logf(%s %s %s - Request read TSRMLS_CC, 
client-addr_str, php_http_method_str(client-request.request_method), 
client-request.request_uri);
php_cli_server_poller_remove(server-poller, POLLIN, 
client-sock);
php_cli_server_dispatch(server, client TSRMLS_CC);
} else {
@@ -1970,7 +1972,7 @@
return SUCCESS;
}
 #ifdef DEBUG
-   php_cli_server_logf(%s: Accepted TSRMLS_CC, client-addr_str);
+   php_cli_server_logf(%s Accepted TSRMLS_CC, client-addr_str);
 #endif
zend_hash_index_update(server-clients, client_sock, client, 
sizeof(client), NULL);
php_cli_server_recv_event_read_request(server, client 
TSRMLS_CC);

Modified: php/php-src/trunk/sapi/cli/php_cli_server.c
===
--- php/php-src/trunk/sapi/cli/php_cli_server.c 2011-07-19 16:17:07 UTC (rev 
313440)
+++ php/php-src/trunk/sapi/cli/php_cli_server.c 2011-07-19 17:47:34 UTC (rev 
313441)
@@ -1479,7 +1479,7 @@
 static void php_cli_server_close_connection(php_cli_server *server, 
php_cli_server_client *client TSRMLS_DC) /* {{{ */
 {
 #ifdef DEBUG
-   php_cli_server_logf(%s: Closing 

[PHP-CVS] svn: /php/php-src/ branches/PHP_5_4/sapi/cli/php_cli_server.c trunk/sapi/cli/php_cli_server.c

2011-07-19 Thread Moriyoshi Koizumi
moriyoshiTue, 19 Jul 2011 18:00:16 +

Revision: http://svn.php.net/viewvc?view=revisionrevision=313442

Log:
- Buffers are local to the blocks where they belong.

Changed paths:
U   php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c
U   php/php-src/trunk/sapi/cli/php_cli_server.c

Modified: php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c
===
--- php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c  2011-07-19 
17:47:34 UTC (rev 313441)
+++ php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c  2011-07-19 
18:00:16 UTC (rev 313442)
@@ -2048,6 +2048,7 @@
extern const opt_struct OPTIONS[];
const char *document_root = NULL;
const char *router = NULL;
+   char document_root_buf[MAXPATHLEN];

while ((c = php_getopt(argc, argv, OPTIONS, php_optarg, php_optind, 
0, 2))!=-1) {
switch (c) {
@@ -2062,7 +2063,6 @@

if (document_root) {
struct stat sb;
-   char resolved_path[MAXPATHLEN];

if (stat(document_root, sb)) {
fprintf(stderr, Directory %s does not exist.\n, 
document_root);
@@ -2072,19 +2072,18 @@
fprintf(stderr, %s is not a directory.\n, 
document_root);
return 1;
}
-   if (VCWD_REALPATH(document_root, resolved_path)) {
-   document_root = resolved_path;
+   if (VCWD_REALPATH(document_root, document_root_buf)) {
+   document_root = document_root_buf;
}
} else {
-   char path[MAXPATHLEN];
char *ret = NULL;

 #if HAVE_GETCWD
-   ret = VCWD_GETCWD(path, MAXPATHLEN);
+   ret = VCWD_GETCWD(document_root_buf, MAXPATHLEN);
 #elif HAVE_GETWD
-   ret = VCWD_GETWD(path);
+   ret = VCWD_GETWD(document_root_buf);
 #endif
-   document_root = ret ? path : .;
+   document_root = ret ? document_root_buf: .;
}

if (argc  php_optind) {

Modified: php/php-src/trunk/sapi/cli/php_cli_server.c
===
--- php/php-src/trunk/sapi/cli/php_cli_server.c 2011-07-19 17:47:34 UTC (rev 
313441)
+++ php/php-src/trunk/sapi/cli/php_cli_server.c 2011-07-19 18:00:16 UTC (rev 
313442)
@@ -2048,6 +2048,7 @@
extern const opt_struct OPTIONS[];
const char *document_root = NULL;
const char *router = NULL;
+   char document_root_buf[MAXPATHLEN];

while ((c = php_getopt(argc, argv, OPTIONS, php_optarg, php_optind, 
0, 2))!=-1) {
switch (c) {
@@ -2062,7 +2063,6 @@

if (document_root) {
struct stat sb;
-   char resolved_path[MAXPATHLEN];

if (stat(document_root, sb)) {
fprintf(stderr, Directory %s does not exist.\n, 
document_root);
@@ -2072,19 +2072,18 @@
fprintf(stderr, %s is not a directory.\n, 
document_root);
return 1;
}
-   if (VCWD_REALPATH(document_root, resolved_path)) {
-   document_root = resolved_path;
+   if (VCWD_REALPATH(document_root, document_root_buf)) {
+   document_root = document_root_buf;
}
} else {
-   char path[MAXPATHLEN];
char *ret = NULL;

 #if HAVE_GETCWD
-   ret = VCWD_GETCWD(path, MAXPATHLEN);
+   ret = VCWD_GETCWD(document_root_buf, MAXPATHLEN);
 #elif HAVE_GETWD
-   ret = VCWD_GETWD(path);
+   ret = VCWD_GETWD(document_root_buf);
 #endif
-   document_root = ret ? path : .;
+   document_root = ret ? document_root_buf: .;
}

if (argc  php_optind) {

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[PHP-CVS] svn: /php/php-src/ branches/PHP_5_4/sapi/cli/php_cli_server.c trunk/sapi/cli/php_cli_server.c

2011-07-19 Thread Moriyoshi Koizumi
moriyoshiTue, 19 Jul 2011 18:17:25 +

Revision: http://svn.php.net/viewvc?view=revisionrevision=313444

Log:
- Fixed bug #55107 (Null bytes in URL cause insecure behavior (code execution / 
code disclosure)).

Bug: https://bugs.php.net/55107 (Verified) Null bytes in URL cause insecure 
behavior (code execution / code disclosure)
  
Changed paths:
U   php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c
U   php/php-src/trunk/sapi/cli/php_cli_server.c

Modified: php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c
===
--- php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c  2011-07-19 
18:08:09 UTC (rev 313443)
+++ php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c  2011-07-19 
18:17:25 UTC (rev 313444)
@@ -242,6 +242,7 @@
 };

 static php_cli_server_http_reponse_status_code_pair template_map[] = {
+   { 400, h1 class=\h\%s/h1pYour browser sent a request that this 
server could not understand./p },
{ 404, h1 class=\h\%s/h1pThe requested resource %s was not 
found on this server./p },
{ 500, h1 class=\h\%s/h1pThe server is temporality 
unavaiable./p }
 };
@@ -1600,6 +1601,11 @@
destroy_request_info(SG(request_info));
return FAILURE;
}
+   if (strlen(client-request.path_translated) != 
client-request.path_translated_len) {
+   /* can't handle paths that contain nul bytes */
+   destroy_request_info(SG(request_info));
+   return php_cli_server_send_error_page(server, client, 400 
TSRMLS_CC);
+   }
{
zend_file_handle zfd;
zfd.type = ZEND_HANDLE_FILENAME;
@@ -1625,6 +1631,11 @@
int fd;
int status = 200;

+   if (client-request.path_translated  
strlen(client-request.path_translated) != client-request.path_translated_len) 
{
+   /* can't handle paths that contain nul bytes */
+   return php_cli_server_send_error_page(server, client, 400 
TSRMLS_CC);
+   }
+
fd = client-request.path_translated ? 
open(client-request.path_translated, O_RDONLY): -1;
if (fd  0) {
char *errstr = get_last_error();

Modified: php/php-src/trunk/sapi/cli/php_cli_server.c
===
--- php/php-src/trunk/sapi/cli/php_cli_server.c 2011-07-19 18:08:09 UTC (rev 
313443)
+++ php/php-src/trunk/sapi/cli/php_cli_server.c 2011-07-19 18:17:25 UTC (rev 
313444)
@@ -242,6 +242,7 @@
 };

 static php_cli_server_http_reponse_status_code_pair template_map[] = {
+   { 400, h1 class=\h\%s/h1pYour browser sent a request that this 
server could not understand./p },
{ 404, h1 class=\h\%s/h1pThe requested resource %s was not 
found on this server./p },
{ 500, h1 class=\h\%s/h1pThe server is temporality 
unavaiable./p }
 };
@@ -1600,6 +1601,11 @@
destroy_request_info(SG(request_info));
return FAILURE;
}
+   if (strlen(client-request.path_translated) != 
client-request.path_translated_len) {
+   /* can't handle paths that contain nul bytes */
+   destroy_request_info(SG(request_info));
+   return php_cli_server_send_error_page(server, client, 400 
TSRMLS_CC);
+   }
{
zend_file_handle zfd;
zfd.type = ZEND_HANDLE_FILENAME;
@@ -1625,6 +1631,11 @@
int fd;
int status = 200;

+   if (client-request.path_translated  
strlen(client-request.path_translated) != client-request.path_translated_len) 
{
+   /* can't handle paths that contain nul bytes */
+   return php_cli_server_send_error_page(server, client, 400 
TSRMLS_CC);
+   }
+
fd = client-request.path_translated ? 
open(client-request.path_translated, O_RDONLY): -1;
if (fd  0) {
char *errstr = get_last_error();

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[PHP-CVS] svn: /php/php-src/ branches/PHP_5_4/sapi/cli/php_cli_server.c trunk/sapi/cli/php_cli_server.c

2011-07-19 Thread Moriyoshi Koizumi
moriyoshiWed, 20 Jul 2011 04:34:01 +

Revision: http://svn.php.net/viewvc?view=revisionrevision=313464

Log:
- Fixed bug #55073 (PHP-CLI-webserver does not listen on ipv6 interfaces), 
letting getaddrinfo(3) validate IPv6 addresses.

Bug: https://bugs.php.net/55073 (Assigned) PHP-CLI-webserver does not listen on 
ipv6 interfaces
  
Changed paths:
U   php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c
U   php/php-src/trunk/sapi/cli/php_cli_server.c

Modified: php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c
===
--- php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c  2011-07-20 
03:11:53 UTC (rev 313463)
+++ php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c  2011-07-20 
04:34:01 UTC (rev 313464)
@@ -1806,19 +1806,35 @@
int port = 3000;
php_socket_t server_sock = SOCK_ERR;

-   host = pestrdup(addr, 1);
-   if (!host || *host == ':' ) {
-   if (host) {
-   pefree(host, 1);
+   if (addr[0] == '[') {
+   char *p;
+   host = pestrdup(addr + 1, 1);
+   if (!host) {
+   return FAILURE;
}
-   fprintf(stderr, Invalid built-in web-server addr:port 
argument\n);
-   return FAILURE;
-   }
-
-   {
-   char *p = strchr(host, ':');
+   p = strchr(host, ']');
if (p) {
*p++ = '\0';
+   if (*p == ':') {
+   port = strtol(p + 1, p, 10);
+   } else if (*p != '\0') {
+   p = NULL;
+   }
+   }
+   if (!p) {
+   fprintf(stderr, Invalid IPv6 address: %s\n, host);
+   retval = FAILURE;
+   goto out;
+   }
+   } else {
+   char *p;
+   host = pestrdup(addr, 1);
+   if (!host) {
+   return FAILURE;
+   }
+   p = strrchr(host, ':');
+   if (p) {
+   *p++ = '\0';
port = strtol(p, p, 10);
}
}
@@ -2106,7 +2122,7 @@
}
sapi_module.phpinfo_as_text = 0;

-   printf(PHP Development Server is listening on %s:%d in %s ... Press 
Ctrl-C to quit.\n, server.host, server.port, document_root);
+   printf(PHP Development Server is listening on %s in %s ... Press 
Ctrl-C to quit.\n, server_bind_address, document_root);

 #if defined(HAVE_SIGNAL_H)  defined(SIGINT)
signal(SIGINT, php_cli_server_sigint_handler);

Modified: php/php-src/trunk/sapi/cli/php_cli_server.c
===
--- php/php-src/trunk/sapi/cli/php_cli_server.c 2011-07-20 03:11:53 UTC (rev 
313463)
+++ php/php-src/trunk/sapi/cli/php_cli_server.c 2011-07-20 04:34:01 UTC (rev 
313464)
@@ -1806,19 +1806,35 @@
int port = 3000;
php_socket_t server_sock = SOCK_ERR;

-   host = pestrdup(addr, 1);
-   if (!host || *host == ':' ) {
-   if (host) {
-   pefree(host, 1);
+   if (addr[0] == '[') {
+   char *p;
+   host = pestrdup(addr + 1, 1);
+   if (!host) {
+   return FAILURE;
}
-   fprintf(stderr, Invalid built-in web-server addr:port 
argument\n);
-   return FAILURE;
-   }
-
-   {
-   char *p = strchr(host, ':');
+   p = strchr(host, ']');
if (p) {
*p++ = '\0';
+   if (*p == ':') {
+   port = strtol(p + 1, p, 10);
+   } else if (*p != '\0') {
+   p = NULL;
+   }
+   }
+   if (!p) {
+   fprintf(stderr, Invalid IPv6 address: %s\n, host);
+   retval = FAILURE;
+   goto out;
+   }
+   } else {
+   char *p;
+   host = pestrdup(addr, 1);
+   if (!host) {
+   return FAILURE;
+   }
+   p = strrchr(host, ':');
+   if (p) {
+   *p++ = '\0';
port = strtol(p, p, 10);
}
}
@@ -2106,7 +2122,7 @@
}
sapi_module.phpinfo_as_text = 0;

-   printf(PHP Development Server is listening on %s:%d in %s ... Press 
Ctrl-C to quit.\n, server.host, server.port, document_root);
+   printf(PHP Development Server is listening on %s in %s ... Press 
Ctrl-C to quit.\n, server_bind_address, document_root);

 #if defined(HAVE_SIGNAL_H)  defined(SIGINT)
signal(SIGINT, 

[PHP-CVS] svn: /php/php-src/ branches/PHP_5_4/sapi/cli/php_cli_server.c trunk/sapi/cli/php_cli_server.c

2011-07-05 Thread Felipe Pena
felipe   Wed, 06 Jul 2011 01:54:54 +

Revision: http://svn.php.net/viewvc?view=revisionrevision=312974

Log:
- Fixed bug #55076 (requires() fails in a subdirectory with the in-built 
webserver)

Bug: https://bugs.php.net/55076 (Re-Opened) requires() fails in a subdirectory 
with the in-built webserver
  
Changed paths:
U   php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c
U   php/php-src/trunk/sapi/cli/php_cli_server.c

Modified: php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c
===
--- php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c  2011-07-06 
00:53:43 UTC (rev 312973)
+++ php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c  2011-07-06 
01:54:54 UTC (rev 312974)
@@ -2060,6 +2060,8 @@

if (document_root) {
struct stat sb;
+   char resolved_path[MAXPATHLEN];
+
if (stat(document_root, sb)) {
fprintf(stderr, Directory %s does not exist.\n, 
document_root);
return 1;
@@ -2068,6 +2070,9 @@
fprintf(stderr, %s is not a directory.\n, 
document_root);
return 1;
}
+   if (VCWD_REALPATH(document_root, resolved_path)) {
+   document_root = resolved_path;
+   }
} else {
char path[MAXPATHLEN];
char *ret = NULL;

Modified: php/php-src/trunk/sapi/cli/php_cli_server.c
===
--- php/php-src/trunk/sapi/cli/php_cli_server.c 2011-07-06 00:53:43 UTC (rev 
312973)
+++ php/php-src/trunk/sapi/cli/php_cli_server.c 2011-07-06 01:54:54 UTC (rev 
312974)
@@ -2060,6 +2060,8 @@

if (document_root) {
struct stat sb;
+   char resolved_path[MAXPATHLEN];
+
if (stat(document_root, sb)) {
fprintf(stderr, Directory %s does not exist.\n, 
document_root);
return 1;
@@ -2068,6 +2070,9 @@
fprintf(stderr, %s is not a directory.\n, 
document_root);
return 1;
}
+   if (VCWD_REALPATH(document_root, resolved_path)) {
+   document_root = resolved_path;
+   }
} else {
char path[MAXPATHLEN];
char *ret = NULL;

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[PHP-CVS] svn: /php/php-src/ branches/PHP_5_4/sapi/cli/php_cli_server.c trunk/sapi/cli/php_cli_server.c

2011-07-03 Thread Felipe Pena
felipe   Sun, 03 Jul 2011 14:45:41 +

Revision: http://svn.php.net/viewvc?view=revisionrevision=312855

Log:
- Fixed bug #55118 (Imcomplete start message)

Bug: https://bugs.php.net/55118 (Open) Imcomplete start message
  
Changed paths:
U   php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c
U   php/php-src/trunk/sapi/cli/php_cli_server.c

Modified: php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c
===
--- php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c  2011-07-03 
09:14:19 UTC (rev 312854)
+++ php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c  2011-07-03 
14:45:41 UTC (rev 312855)
@@ -2069,7 +2069,15 @@
return 1;
}
} else {
-   document_root = .;
+   char path[MAXPATHLEN];
+   char *ret = NULL;
+
+#if HAVE_GETCWD
+   ret = VCWD_GETCWD(path, MAXPATHLEN);
+#elif HAVE_GETWD
+   ret = VCWD_GETWD(path);
+#endif
+   document_root = ret ? path : .;
}

if (argc  php_optind) {

Modified: php/php-src/trunk/sapi/cli/php_cli_server.c
===
--- php/php-src/trunk/sapi/cli/php_cli_server.c 2011-07-03 09:14:19 UTC (rev 
312854)
+++ php/php-src/trunk/sapi/cli/php_cli_server.c 2011-07-03 14:45:41 UTC (rev 
312855)
@@ -2069,7 +2069,15 @@
return 1;
}
} else {
-   document_root = .;
+   char path[MAXPATHLEN];
+   char *ret = NULL;
+
+#if HAVE_GETCWD
+   ret = VCWD_GETCWD(path, MAXPATHLEN);
+#elif HAVE_GETWD
+   ret = VCWD_GETWD(path);
+#endif
+   document_root = ret ? path : .;
}

if (argc  php_optind) {

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[PHP-CVS] svn: /php/php-src/ branches/PHP_5_4/sapi/cli/php_cli_server.c trunk/sapi/cli/php_cli_server.c

2011-06-30 Thread Philip Olson
philip   Thu, 30 Jun 2011 23:50:56 +

Revision: http://svn.php.net/viewvc?view=revisionrevision=312743

Log:
Updated name to 'PHP Development Server', and CTRL-C to Ctrl-C, as per PHP bug 
#55071

Bug: https://bugs.php.net/55071 (Open) Change in-built web server description
  
Changed paths:
U   php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c
U   php/php-src/trunk/sapi/cli/php_cli_server.c

Modified: php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c
===
--- php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c  2011-06-30 
23:03:02 UTC (rev 312742)
+++ php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c  2011-06-30 
23:50:56 UTC (rev 312743)
@@ -2081,7 +2081,7 @@
}
sapi_module.phpinfo_as_text = 0;

-   printf(Server is listening on %s:%d in %s ... Press CTRL-C to 
quit.\n, server.host, server.port, document_root);
+   printf(PHP Development Server is listening on %s:%d in %s ... Press 
Ctrl-C to quit.\n, server.host, server.port, document_root);

 #if defined(HAVE_SIGNAL_H)  defined(SIGINT)
signal(SIGINT, php_cli_server_sigint_handler);

Modified: php/php-src/trunk/sapi/cli/php_cli_server.c
===
--- php/php-src/trunk/sapi/cli/php_cli_server.c 2011-06-30 23:03:02 UTC (rev 
312742)
+++ php/php-src/trunk/sapi/cli/php_cli_server.c 2011-06-30 23:50:56 UTC (rev 
312743)
@@ -2081,7 +2081,7 @@
}
sapi_module.phpinfo_as_text = 0;

-   printf(Server is listening on %s:%d in %s ... Press CTRL-C to 
quit.\n, server.host, server.port, document_root);
+   printf(PHP Development Server is listening on %s:%d in %s ... Press 
Ctrl-C to quit.\n, server.host, server.port, document_root);

 #if defined(HAVE_SIGNAL_H)  defined(SIGINT)
signal(SIGINT, php_cli_server_sigint_handler);

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[PHP-CVS] svn: /php/php-src/ branches/PHP_5_4/sapi/cli/php_cli_server.c trunk/sapi/cli/php_cli_server.c

2011-06-29 Thread David Soria Parra
dsp  Wed, 29 Jun 2011 23:29:01 +

Revision: http://svn.php.net/viewvc?view=revisionrevision=312643

Log:
fix #55072 in-built web server needs to check -t option is a directory

Bug: http://bugs.php.net/55072 (unknown) 
  
Changed paths:
U   php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c
U   php/php-src/trunk/sapi/cli/php_cli_server.c

Modified: php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c
===
--- php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c  2011-06-29 
22:01:55 UTC (rev 312642)
+++ php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c  2011-06-29 
23:29:01 UTC (rev 312643)
@@ -88,6 +88,10 @@
 # define SOCK_EADDRINUSE WSAEADDRINUSE
 #endif

+#ifndef S_ISDIR
+#define S_ISDIR(mode)  (((mode)S_IFMT) == S_IFDIR)
+#endif
+
 #include ext/standard/file.h /* for php_set_sock_blocking() :-( */
 #include ext/standard/php_smart_str.h
 #include ext/standard/html.h
@@ -2060,6 +2064,10 @@
fprintf(stderr, Directory or script %s does not 
exist.\n, document_root);
return 1;
}
+   if (!S_ISDIR(sb.st_mode)) {
+   fprintf(stderr, %s is not a directory.\n, 
document_root);
+   return 1;
+   }
} else {
document_root = .;
}

Modified: php/php-src/trunk/sapi/cli/php_cli_server.c
===
--- php/php-src/trunk/sapi/cli/php_cli_server.c 2011-06-29 22:01:55 UTC (rev 
312642)
+++ php/php-src/trunk/sapi/cli/php_cli_server.c 2011-06-29 23:29:01 UTC (rev 
312643)
@@ -88,6 +88,10 @@
 # define SOCK_EADDRINUSE WSAEADDRINUSE
 #endif

+#ifndef S_ISDIR
+#define S_ISDIR(mode)  (((mode)S_IFMT) == S_IFDIR)
+#endif
+
 #include ext/standard/file.h /* for php_set_sock_blocking() :-( */
 #include ext/standard/php_smart_str.h
 #include ext/standard/html.h
@@ -2060,6 +2064,10 @@
fprintf(stderr, Directory or script %s does not 
exist.\n, document_root);
return 1;
}
+   if (!S_ISDIR(sb.st_mode)) {
+   fprintf(stderr, %s is not a directory.\n, 
document_root);
+   return 1;
+   }
} else {
document_root = .;
}

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[PHP-CVS] svn: /php/php-src/ branches/PHP_5_4/sapi/cli/php_cli_server.c trunk/sapi/cli/php_cli_server.c

2011-06-29 Thread David Soria Parra
dsp  Wed, 29 Jun 2011 23:44:02 +

Revision: http://svn.php.net/viewvc?view=revisionrevision=312646

Log:
correct error message for a missing document root in the cli webserver

the document root is always a directory.

Changed paths:
U   php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c
U   php/php-src/trunk/sapi/cli/php_cli_server.c

Modified: php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c
===
--- php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c  2011-06-29 
23:40:12 UTC (rev 312645)
+++ php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c  2011-06-29 
23:44:02 UTC (rev 312646)
@@ -2061,7 +2061,7 @@
if (document_root) {
struct stat sb;
if (stat(document_root, sb)) {
-   fprintf(stderr, Directory or script %s does not 
exist.\n, document_root);
+   fprintf(stderr, Directory %s does not exist.\n, 
document_root);
return 1;
}
if (!S_ISDIR(sb.st_mode)) {

Modified: php/php-src/trunk/sapi/cli/php_cli_server.c
===
--- php/php-src/trunk/sapi/cli/php_cli_server.c 2011-06-29 23:40:12 UTC (rev 
312645)
+++ php/php-src/trunk/sapi/cli/php_cli_server.c 2011-06-29 23:44:02 UTC (rev 
312646)
@@ -2061,7 +2061,7 @@
if (document_root) {
struct stat sb;
if (stat(document_root, sb)) {
-   fprintf(stderr, Directory or script %s does not 
exist.\n, document_root);
+   fprintf(stderr, Directory %s does not exist.\n, 
document_root);
return 1;
}
if (!S_ISDIR(sb.st_mode)) {

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[PHP-CVS] svn: /php/php-src/ branches/PHP_5_4/sapi/cli/php_cli_server.c trunk/sapi/cli/php_cli_server.c

2011-06-27 Thread Felipe Pena
felipe   Mon, 27 Jun 2011 23:18:26 +

Revision: http://svn.php.net/viewvc?view=revisionrevision=312541

Log:
- Fixed crash on invalid addr:port (Chris Jones, Felipe)

Changed paths:
U   php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c
U   php/php-src/trunk/sapi/cli/php_cli_server.c

Modified: php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c
===
--- php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c  2011-06-27 
22:58:59 UTC (rev 312540)
+++ php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c  2011-06-27 
23:18:26 UTC (rev 312541)
@@ -360,6 +360,9 @@
 static int sapi_cli_server_ub_write(const char *str, uint str_length 
TSRMLS_DC) /* {{{ */
 {
php_cli_server_client *client = SG(server_context);
+   if (!client) {
+   return 0;
+   }
if (client-capturing) {
php_cli_server_chunk *chunk = 
php_cli_server_chunk_heap_new_self_contained(str_length);
if (!chunk) {
@@ -400,7 +403,7 @@
sapi_header_struct *h;
zend_llist_position pos;

-   if (client-capturing || SG(request_info).no_headers) {
+   if (client == NULL || client-capturing || SG(request_info).no_headers) 
{
return SAPI_HEADER_SENT_SUCCESSFULLY;
}

@@ -1506,7 +1509,9 @@
php_cli_server_client_begin_capture(client);
zend_try {
php_info_print_style(TSRMLS_C);
-   
php_cli_server_buffer_append(client-content_sender.buffer, 
client-capture_buffer.first);
+   if (client-capture_buffer.first) {
+   
php_cli_server_buffer_append(client-content_sender.buffer, 
client-capture_buffer.first);
+   }
client-capture_buffer.first = 
client-capture_buffer.last = NULL;
} zend_catch {
err = 1;
@@ -1785,7 +1790,11 @@
php_socket_t server_sock = SOCK_ERR;

host = pestrdup(addr, 1);
-   if (!host) {
+   if (!host || *host == ':' ) {
+   if (host) {
+   pefree(host, 1);
+   }
+   fprintf(stderr, Invalid built-in web-server addr:port 
argument\n);
return FAILURE;
}


Modified: php/php-src/trunk/sapi/cli/php_cli_server.c
===
--- php/php-src/trunk/sapi/cli/php_cli_server.c 2011-06-27 22:58:59 UTC (rev 
312540)
+++ php/php-src/trunk/sapi/cli/php_cli_server.c 2011-06-27 23:18:26 UTC (rev 
312541)
@@ -360,6 +360,9 @@
 static int sapi_cli_server_ub_write(const char *str, uint str_length 
TSRMLS_DC) /* {{{ */
 {
php_cli_server_client *client = SG(server_context);
+   if (!client) {
+   return 0;
+   }
if (client-capturing) {
php_cli_server_chunk *chunk = 
php_cli_server_chunk_heap_new_self_contained(str_length);
if (!chunk) {
@@ -400,7 +403,7 @@
sapi_header_struct *h;
zend_llist_position pos;

-   if (client-capturing || SG(request_info).no_headers) {
+   if (client == NULL || client-capturing || SG(request_info).no_headers) 
{
return SAPI_HEADER_SENT_SUCCESSFULLY;
}

@@ -1506,7 +1509,9 @@
php_cli_server_client_begin_capture(client);
zend_try {
php_info_print_style(TSRMLS_C);
-   
php_cli_server_buffer_append(client-content_sender.buffer, 
client-capture_buffer.first);
+   if (client-capture_buffer.first) {
+   
php_cli_server_buffer_append(client-content_sender.buffer, 
client-capture_buffer.first);
+   }
client-capture_buffer.first = 
client-capture_buffer.last = NULL;
} zend_catch {
err = 1;
@@ -1785,7 +1790,11 @@
php_socket_t server_sock = SOCK_ERR;

host = pestrdup(addr, 1);
-   if (!host) {
+   if (!host || *host == ':' ) {
+   if (host) {
+   pefree(host, 1);
+   }
+   fprintf(stderr, Invalid built-in web-server addr:port 
argument\n);
return FAILURE;
}


-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[PHP-CVS] svn: /php/php-src/ branches/PHP_5_4/sapi/cli/php_cli_server.c trunk/sapi/cli/php_cli_server.c

2011-06-21 Thread Pierre Joye
pajoye   Tue, 21 Jun 2011 11:43:19 +

Revision: http://svn.php.net/viewvc?view=revisionrevision=312355

Log:
- fix build

Changed paths:
U   php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c
U   php/php-src/trunk/sapi/cli/php_cli_server.c

Modified: php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c
===
--- php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c  2011-06-21 
09:24:04 UTC (rev 312354)
+++ php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c  2011-06-21 
11:43:19 UTC (rev 312355)
@@ -18,8 +18,6 @@

 /* $Id: php_cli.c 306938 2011-01-01 02:17:06Z felipe $ */

-#include php_config.h
-
 #include stdio.h
 #include fcntl.h
 #include assert.h
@@ -30,6 +28,8 @@
 #include win32/time.h
 #include win32/signal.h
 #include win32/php_registry.h
+#else
+# include php_config.h
 #endif

 #ifdef __riscos__

Modified: php/php-src/trunk/sapi/cli/php_cli_server.c
===
--- php/php-src/trunk/sapi/cli/php_cli_server.c 2011-06-21 09:24:04 UTC (rev 
312354)
+++ php/php-src/trunk/sapi/cli/php_cli_server.c 2011-06-21 11:43:19 UTC (rev 
312355)
@@ -18,8 +18,6 @@

 /* $Id: php_cli.c 306938 2011-01-01 02:17:06Z felipe $ */

-#include php_config.h
-
 #include stdio.h
 #include fcntl.h
 #include assert.h
@@ -30,6 +28,8 @@
 #include win32/time.h
 #include win32/signal.h
 #include win32/php_registry.h
+#else
+# include php_config.h
 #endif

 #ifdef __riscos__

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php