#29005 [Opn]: fopen() can't open NT named pipes on local computer

From: Date: Mon, 05 Jul 2004 07:49:11 +0000
Subject: #29005 [Opn]: fopen() can't open NT named pipes on local computer
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-61678@lists.php.net to get a copy of this message
 ID:               29005
 Updated by:       derick@php.net
 Reported By:      cleong at nflc dot org
 Status:           Open
-Bug Type:         Filesystem function related
+Bug Type:         Feature/Change Request
 Operating System: Windows 2000
 PHP Version:      4.3.6
 New Comment:

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


Previous Comments:
------------------------------------------------------------------------

[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 http://bugs.php.net/?id=29005&edit=1


Thread (6 messages)

« previous php.bugs (#61678) next »