bug52820.phpt 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. --TEST--
  2. Bug #52820 (writes to fopencookie FILE* not committed when seeking the stream)
  3. --EXTENSIONS--
  4. curl
  5. zend_test
  6. --SKIPIF--
  7. <?php
  8. /* unfortunately no standard function does a cast to FILE*, so we need
  9. * curl to test this */
  10. $handle=curl_init('file:///i_dont_exist/');
  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('file:///i_dont_exist/');
  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. echo "temp stream (close after):\n";
  29. fclose(do_stuff("php://temp"));
  30. echo "\nmemory stream (close after):\n";
  31. fclose(do_stuff("php://memory"));
  32. echo "\ntemp stream (leak):\n";
  33. zend_leak_variable(do_stuff("php://temp"));
  34. echo "\nmemory stream (leak):\n";
  35. zend_leak_variable(do_stuff("php://memory"));
  36. echo "\nDone.\n";
  37. ?>
  38. --EXPECTF--
  39. temp stream (close after):
  40. About to rewind!
  41. * Couldn't open file /i_dont_exist/
  42. * Closing connection%A%d
  43. memory stream (close after):
  44. About to rewind!
  45. * Couldn't open file /i_dont_exist/
  46. * Closing connection%A%d
  47. temp stream (leak):
  48. About to rewind!
  49. * Couldn't open file /i_dont_exist/
  50. * Closing connection%A%d
  51. memory stream (leak):
  52. About to rewind!
  53. * Couldn't open file /i_dont_exist/
  54. * Closing connection%A%d
  55. Done.