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

Valgrind Report for ext/soap/tests/bug73037.phpt ('Bug #73037 SoapServer reports Bad Request when gzipped, var 0')

Script

1: <?php
2:
3:
include dirname(__FILE__) . "/../../../sapi/cli/tests/php_cli_server.inc";
4:
5: function 
get_data($max)
6: {
7:     
$piece "<CD>
8:         <TITLE>Empire Burlesque</TITLE>
9:         <ARTIST>Bob Dylan</ARTIST>
10:         <COUNTRY>USA</COUNTRY>
11:         <COMPANY>Columbia</COMPANY>
12:         <PRICE>10.90</PRICE>
13:         <YEAR>1985</YEAR>
14:     </CD>"
;
15:
16:     
$begin '<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Body><CATALOG>';
17:     
$end '</CATALOG></soapenv:Body></soapenv:Envelope>';
18:
19:     
$min strlen($begin) + strlen($piece) + strlen($end);
20:     
$max $max $min $min $max;
21:
22:     
$data $begin;
23:     
$data .= $piece;
24:     while (
strlen($data) + strlen($end) < $max) {
25:         
/* Randomize a bit, taking gzip in account. */
26:         
$tmp str_replace(
27:             array(
28:                 
"Empire Burlesque",
29:                 
"Bob Dylan",
30:             ),
31:             array(
32:                 
md5(uniqid()),
33:                 
sha1(uniqid()),
34:             ),
35:             
$piece
36:         
);
37:
38:         if (
strlen($begin) + strlen($tmp) + strlen($end) > $max) {
39:             break;
40:         }
41:
42:         
$data .= $tmp;
43:     }
44:     
$data .= $end;
45:
46:     return 
$data;
47: }
48:
49:
$router "bug73037_server.php";
50:
$args substr(PHP_OS03) == 'WIN' "-d extension_dir=" ini_get("extension_dir") . " -d extension=php_soap.dll" "";
51:
$code = <<<'PHP'
52:
$s = new SoapServer(NULL, array('uri' => 'http://here'));
53: $s->setObject(new stdclass());
54: $s->handle();
55:
PHP;
56:
57:
php_cli_server_start($code$router$args);
58:
59: foreach (array(
1024-11024*8-31024*9+11024*16-11024*32-51024*64+31024*128-7) as $k => $i) {
60:     echo 
"Iteration $k\n\n";
61:
62:     
/* with and without compression */
63:     
foreach (array(falsetrue) as $b) {
64:         
$data get_data($i);
65:         if (
$b) {
66:             
$data gzencode($data);
67:         }
68:         
$len strlen($data);
69:
70:         
//echo "len=$len\n";
71:
72:         
$hdrs = <<<HDRS
73:
POST /bug73037_server.php HTTP/1.1
74: Content-Type: application/soap+xml; charset=UTF-8
75: Accept: application/soap+xml, application/dime, multipart/related, text/*
76: SOAPAction: "urn:adressen#adressen#SetAda"
77: Expect: 100-continue
78: Content-Length: 
${len}
79:
HDRS;
80:         if (
$b) {
81:             
$hdrs .="\nContent-Encoding: gzip";        
82:         }
83:         
//echo "Headers sent:\n$hdrs\n\n";
84:         
$fp fsockopen(PHP_CLI_SERVER_HOSTNAMEPHP_CLI_SERVER_PORT$errno$errstr5);
85:         if (!
$fp) {
86:           die(
"connect failed");
87:         }
88:
89:         if(
fwrite($fp"$hdrs\n\n$data")) {
90:             
$out "";
91:             while (!
feof($fp)) {
92:                 
$out .= fread($fp1024);
93:             }
94:
95:             
$pos strpos($out"<env:Text>");
96:             if (
false === $pos) {
97:                 echo 
$out;
98:                 goto 
cleanup;
99:             }
100:             
$pos0 $pos strlen("<env:Text>");
101:             
$pos strpos($out"</env:Text>");
102:             if (
false === $pos) {
103:                 echo 
$out;
104:                 goto 
cleanup;
105:             }
106:             
$len $pos $pos0;
107:             echo 
substr($out$pos0$len);
108:         }
109:
110:
cleanup:
111:         
fclose($fp);
112:
113:         echo 
"\n\n";
114:         }
115: }
116:
117:
?>
118:
==DONE==
119:

Report

==23942== Jump to the invalid address stated on the next line
==23942==    at 0x4FE: ???
==23942==    by 0x1EE955F: ??? (in /var/php_gcov/PHP_HEAD/sapi/cli/php)
==23942==    by 0x1FFEFFEEFF: ???
==23942==    by 0xC5B499F: ??? (in /usr/lib64/libnetsnmp.so.20.0.0)
==23942==    by 0x1FFEFFEEFF: ???
==23942==    by 0x50: ???
==23942==    by 0x4045A87: ???
==23942==    by 0x23809187: ???
==23942==    by 0x4009FE1: do_lookup_x (in /lib64/ld-2.12.so)
==23942==    by 0x400A269: _dl_lookup_symbol_x (in /lib64/ld-2.12.so)
==23942==    by 0x400BAB3: _dl_relocate_object (in /lib64/ld-2.12.so)
==23942==    by 0x4003A08: dl_main (in /lib64/ld-2.12.so)
==23942==  Address 0x4fe is not stack'd, malloc'd or (recently) free'd
==23942== 
==23942== 
==23942== Process terminating with default action of signal 11 (SIGSEGV)
==23942==  Bad permissions for mapped region at address 0x4FE
==23942==    at 0x4FE: ???
==23942==    by 0x1EE955F: ??? (in /var/php_gcov/PHP_HEAD/sapi/cli/php)
==23942==    by 0x1FFEFFEEFF: ???
==23942==    by 0xC5B499F: ??? (in /usr/lib64/libnetsnmp.so.20.0.0)
==23942==    by 0x1FFEFFEEFF: ???
==23942==    by 0x50: ???
==23942==    by 0x4045A87: ???
==23942==    by 0x23809187: ???
==23942==    by 0x4009FE1: do_lookup_x (in /lib64/ld-2.12.so)
==23942==    by 0x400A269: _dl_lookup_symbol_x (in /lib64/ld-2.12.so)
==23942==    by 0x400BAB3: _dl_relocate_object (in /lib64/ld-2.12.so)
==23942==    by 0x4003A08: dl_main (in /lib64/ld-2.12.so)

 

Generated at Sun, 12 Nov 2017 21:17:35 +0000 (6 days ago)

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