php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #38488 Access to "php://stdin" and faily crashes PHP on win32
Submitted: 2006-08-18 02:31 UTC Modified: 2006-10-21 21:33 UTC
From: dmitry@php.net Assigned:
Status: Closed Package: Streams related
PHP Version: 5CVS-2006-08-18 (CVS) OS: win32
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: dmitry@php.net
New email:
PHP Version: OS:

 

 [2006-08-18 02:31 UTC] dmitry@php.net
Description:
------------
Access to standard streams using "php://stdin" and family names produces crash. The reason probably is in a buggy _get_osfhandle() function that doesn't return proper HANDLES for standard system streams. We need find out a workaround for this problem.

the bug is probably related to bug #7960

Reproduce code:
---------------
<?php
$f = fopen("php://stdout", "w+");
fwrite($f, "Hello\n");
?>

Expected result:
----------------
Hello

Actual result:
--------------
Crash with the following stack trace

NTDLL! 7c90eb74()
NTDLL! 7c90eb94()
_php_stream_fopen_from_fd(int 0, const char * 0x00416fb0 `string', const char * 0x00000000, int 0, char * 0x1070a25c `string', unsigned int 246, char * 0x00000000, unsigned int 0, void * * * 0x02714fe0) line 200 + 24 bytes
php_stream_url_wrap_php(_php_stream_wrapper * 0x108a5d28 _php_stream_php_wrapper, char * 0x00416fa6, char * 0x00416fb0 `string', int 8, char * * 0x00000000, _php_stream_context * 0x00000000, int 1, char * 0x106dd51c `string', unsigned int 1774, char * 0x004165c8 `string', unsigned int 498, void * * * 0x02714fe0) line 246 + 41 bytes
_php_stream_open_wrapper_ex(char * 0x00416fa0 `string', char * 0x00416fb0 `string', int 0, char * * 0x00000000, _php_stream_context * 0x00000000, int 0, char * 0x004165c8 `string', unsigned int 498, char * 0x00000000, unsigned int 0, void * * * 0x02714fe0) line 1774 + 111 bytes
cli_register_file_handles(void * * * 0x02714fe0) line 498 + 52 bytes
main(int 2, char * * 0x026f8fc0) line 1030 + 12 bytes


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-08-18 04:11 UTC] fmk@php.net
I'm unable to get my system to crash (CGI and CLI). What SAPI are you using?
 [2006-08-22 03:29 UTC] dmitry@php.net
PHP crashes only with "MS Debugging Tools for Windows", however bug don't go away without them.

The problem that _get_osfhandle(0) returns some invalid HANDLE (for me it is 3), and then GetNamedPipeIndo() may crash.

I'll probably look into problem by myself.
 [2006-08-22 06:20 UTC] dmitry@php.net
Fixed in CVS HEAD, PHP_5_2 and PHP_5_1.

The problem was not in _get_osfhandle(), but in GetNamedPipeInfo() that expects PIPE's HANDLE.
 [2006-10-21 21:33 UTC] wez@php.net
What you were seeing under the debugger was an internal exception which is expected if the handle is not a pipe.
GetFileType returns FILE_TYPE_PIPE for pipes and sockets, so now it's not as precise in its classification as it once was.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 15:01:30 2024 UTC