Edit report at https://bugs.php.net/bug.php?id=29005&edit=1

 ID:                 29005
 Updated by:         the...@php.net
 Reported by:        cleong at nflc dot org
 Summary:            fopen() can't open NT named pipes on local computer
-Status:             Open
+Status:             Closed
 Type:               Feature/Change Request
-Package:            Feature/Change Request
+Package:            *General Issues
 Operating System:   Windows 2000
 PHP Version:        4.3.6
-Assigned To:        
+Assigned To:        thekid
 Block user comment: N
 Private report:     N

 New Comment:

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)


Previous Comments:
------------------------------------------------------------------------
[2010-01-13 14:08:48] bob at peret dot net

I got around this by replacing the "." with my local address

"\\\\.\\pipe\\pipename"

"\\\\127.0.0.1\\pipe\\pipename"

------------------------------------------------------------------------
[2004-07-06 16:47:11] cleong at nflc dot org

But it's just a matter of not corrupting the filepath. This is a bug in a way, 
as, for the same reason, the function cannot handle "\\.\C:\filename.ext", 
which is a valid Win32 path.

------------------------------------------------------------------------
[2004-07-06 16:32:20] poll...@php.net

Indeed, Wez and I both have our eyes on named pipe support.  With luck it'll 
show up in 5.1, in any case it should be a simple backport to make it available 
to 5.0 via a PECL extension.

------------------------------------------------------------------------
[2004-07-05 09:49:10] der...@php.net

Let's make this a feature request as it's currently not meant to work.

------------------------------------------------------------------------
[2004-07-04 00:06:58] 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


------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=29005&edit=1

Reply via email to