Annotation of embedaddon/php/ext/standard/tests/file/bug52820.phpt, revision 1.1.1.3

1.1       misho       1: --TEST--
1.1.1.3 ! misho       2: Bug #52820 (writes to fopencookie FILE* not committed when seeking the stream)
1.1       misho       3: --SKIPIF--
                      4: <?php
1.1.1.2   misho       5: if (!function_exists('leak_variable'))
                      6:    die("skip only for debug builds");
1.1       misho       7: /* unfortunately no standard function does a cast to FILE*, so we need
                      8:  * curl to test this */
                      9: if (!extension_loaded("curl")) exit("skip curl extension not loaded");
                     10: $handle=curl_init('http://127.0.0.1:37349/');
                     11: curl_setopt($handle, CURLOPT_VERBOSE, true);
                     12: curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
                     13: if (!curl_setopt($handle, CURLOPT_STDERR, fopen("php://memory", "w+")))
                     14:     die("skip fopencookie not supported on this platform");
                     15: --FILE--
                     16: <?php
                     17: function do_stuff($url) {
                     18:     $handle=curl_init('http://127.0.0.1:37349/');
                     19:     curl_setopt($handle, CURLOPT_VERBOSE, true);
                     20:     curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
                     21:     curl_setopt($handle, CURLOPT_STDERR, $o = fopen($url, "w+"));
                     22:     curl_exec($handle);
                     23:     echo "About to rewind!\n";
                     24:     rewind($o);
                     25:     echo stream_get_contents($o);
                     26:     return $o;
                     27: }
                     28: 
                     29: echo "temp stream (close after):\n";
                     30: fclose(do_stuff("php://temp"));
                     31: 
                     32: echo "\nmemory stream (close after):\n";
                     33: fclose(do_stuff("php://memory"));
                     34: 
1.1.1.2   misho      35: echo "\ntemp stream (leak):\n";
                     36: leak_variable(do_stuff("php://temp"), true);
                     37: 
                     38: echo "\nmemory stream (leak):\n";
                     39: leak_variable(do_stuff("php://memory"), true);
                     40: 
1.1       misho      41: echo "\nDone.\n";
1.1.1.2   misho      42: --EXPECTF--
1.1       misho      43: temp stream (close after):
                     44: About to rewind!
1.1.1.2   misho      45: * About to connect() to 127.0.0.1 port 37349%r.*%r
1.1.1.3 ! misho      46: *   Trying 127.0.0.1...%A* Connection refused
        !            47: * couldn't connect to host%S
1.1       misho      48: * Closing connection #0
                     49: 
                     50: memory stream (close after):
                     51: About to rewind!
1.1.1.2   misho      52: * About to connect() to 127.0.0.1 port 37349%r.*%r
1.1.1.3 ! misho      53: *   Trying 127.0.0.1...%A* Connection refused
        !            54: * couldn't connect to host%S
1.1.1.2   misho      55: * Closing connection #0
                     56: 
                     57: temp stream (leak):
                     58: About to rewind!
                     59: * About to connect() to 127.0.0.1 port 37349%r.*%r
1.1.1.3 ! misho      60: *   Trying 127.0.0.1...%A* Connection refused
        !            61: * couldn't connect to host%S
1.1.1.2   misho      62: * Closing connection #0
                     63: 
                     64: memory stream (leak):
                     65: About to rewind!
                     66: * About to connect() to 127.0.0.1 port 37349%r.*%r
1.1.1.3 ! misho      67: *   Trying 127.0.0.1...%A* Connection refused
        !            68: * couldn't connect to host%S
1.1       misho      69: * Closing connection #0
                     70: 
                     71: Done.

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>