|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2004-07-04 00:06 UTC] cleong at nflc dot org
Description:
------------
fopen() can't handle path names like "\\.\pipe\pipename" because the internal function virtual_file_ex() see the ".\" part, thinks that it means current directory, and promptly removes it.
The manual doesn't mention named pipes but I think this is worth fixing as it will give PHP Win32 a robust interprocess communication mechanism that's fairly easy to implement. The fix is easy enough. Insert the following at line 413 in tsrm_virtual_cwd.c, right after the else if (!IS_DIRECTORY_CURRENT(ptr, ptr_length)) loop:
#ifdef TSRM_WIN32
/* '.' should be retained if the first two chars are '\' as it stands for local machine
done mainly for paths to NT named pipes (\\.\pipe\pipename) */
} else if(state->cwd_length == 2 && state->cwd[0] == '\\' && state->cwd[1] == '\\') {
state->cwd = (char *) realloc(state->cwd, state->cwd_length+ptr_length+1);
memcpy(&state->cwd[state->cwd_length], ptr, ptr_length+1);
state->cwd_length += ptr_length;
#endif
}
Reproduce code:
---------------
Set break point at line 1975 in streams.c
fd = open(realpath, open_flags, 0666);
then run <? readfile('\\\\.\\pipe\\pipename'); ?>. Inspect realpath.
Expected result:
----------------
realpath => \\.\pipe\pipename
Actual result:
--------------
realpath => \\pipe\pipename
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 05:00:02 2025 UTC |
This has been fixed in PHP 5.3 in the meantime: $ F:\Programme\php-5.3.0-Win32\php.exe -r 'var_dump(fopen("\\\\.\\pipe\\mysql", "r+"));' resource(5) of type (stream)