PHP  
 PHP_7_0
downloads | QA | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
 

Valgrind Report for sapi/cli/tests/php_cli_server_014.phpt ('Bug #60477: Segfault after two multipart/form-data POST requestes')

Script

1: <?php
2:
include "php_cli_server.inc";
3:
php_cli_server_start('echo done, "\n";'null);
4:
5: list(
$host$port) = explode(':'PHP_CLI_SERVER_ADDRESS);
6:
$port intval($port)?:80;
7:
$output '';
8:
9:
// note: select() on Windows (& some other platforms) has historical issues with
10: //       timeouts less than 1000 millis(0.5). it may be better to increase these
11: //       timeouts to 1000 millis(1.0) (fsockopen eventually calls select()).
12: //       see articles like: http://support.microsoft.com/kb/257821
13:
$fp fsockopen($host$port$errno$errstr0.5);
14: if (!
$fp) {
15:   die(
"connect failed");
16: }
17:
18: if(
fwrite($fp, <<<HEADER
19:
POST /index.php HTTP/1.1
20: Host: 
{$host}
21: Content-Type: multipart/form-data; boundary=---------123456789
22: Content-Length: 70
23:
24: ---------123456789
25: Content-Type: application/x-www-form-urlencoded
26: a=b
27:
HEADER
28: )) {
29:     while (!
feof($fp)) {
30:         
$output .= fgets($fp);
31:     }
32: }
33:
34:
fclose($fp);
35:
36:
$fp fsockopen($host$port$errno$errstr0.5);
37: if(
fwrite($fp, <<<HEADER
38:
POST /main/no-exists.php HTTP/1.1
39: Host: 
{$host}
40: Content-Type: multipart/form-data; boundary=---------123456789
41: Content-Length: 70
42:
43: ---------123456789
44: Content-Type: application/x-www-form-urlencoded
45: a=b
46:
HEADER
47: )) {
48:     while (!
feof($fp)) {
49:         
$output .= fgets($fp);
50:     }
51: }
52:
53: echo 
preg_replace("/<style>(.*?)<\/style>/s""<style>AAA</style>"$output), "\n";
54:
fclose($fp);
55:
56:
?>
57:

Report

==6295== Jump to the invalid address stated on the next line
==6295==    at 0x4FE: ???
==6295==  Address 0x4fe is not stack'd, malloc'd or (recently) free'd
==6295== 
==6295== 
==6295== Process terminating with default action of signal 11 (SIGSEGV)
==6295==  Bad permissions for mapped region at address 0x4FE
==6295==    at 0x4FE: ???

 

Generated at Wed, 08 Nov 2017 19:36:35 +0000 (16 days ago)

Copyright © 2005-2017 The PHP Group
All rights reserved.