Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:64679 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 21352 invoked from network); 8 Jan 2013 13:24:35 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 8 Jan 2013 13:24:35 -0000 Authentication-Results: pb1.pair.com smtp.mail=nicolai.scheer@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=nicolai.scheer@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.49 as permitted sender) X-PHP-List-Original-Sender: nicolai.scheer@gmail.com X-Host-Fingerprint: 74.125.82.49 mail-wg0-f49.google.com Received: from [74.125.82.49] ([74.125.82.49:61422] helo=mail-wg0-f49.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 0A/17-16636-21E1CE05 for ; Tue, 08 Jan 2013 08:24:35 -0500 Received: by mail-wg0-f49.google.com with SMTP id 15so311484wgd.4 for ; Tue, 08 Jan 2013 05:24:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; bh=cwywqTqJrknqS0ZV1brgDW89ZikM7HQpVGjU3lMNeZs=; b=jJgFGyuSBUnpW6kBqkatQfr4uDVx46Athx+pi8eSj4qRZhqni68Nwq0dS2v2dyNljg hzWQboJId7643+WkORy1UZaOvYHaFORAdamVA+5JCwiv4jXVKWBMjqcUQ+MYbiY4vkwX hds4G7kQFZ8aq6Ub0MkfHnFfP77n+41alQ1oUi2dcVeDJYzh0ItxvPetyn74JTuta+yn VsNyCYNZjSYd8p7Q0JoY7UrE9eVmMg4prRzZpcnvo6pR7IhuaQoNROfRSzK5WV9H8YMv pD9FmMXh0zh0cRcgS7ut9/fKIOkbi5kYgrm5dE05WoHaOd5hR6NCKRu1LCqd6lIVkvUj U6pw== MIME-Version: 1.0 X-Received: by 10.180.82.69 with SMTP id g5mr15065375wiy.21.1357651471300; Tue, 08 Jan 2013 05:24:31 -0800 (PST) Received: by 10.227.170.206 with HTTP; Tue, 8 Jan 2013 05:24:31 -0800 (PST) In-Reply-To: References: Date: Tue, 8 Jan 2013 14:24:31 +0100 Message-ID: To: Pierre Joye Cc: Ferenc Kovacs , PHP internals Content-Type: multipart/alternative; boundary=f46d0442838aacf9e804d2c6ddf0 Subject: Re: [PHP-DEV] File-Paths exceeding MAX_PATH on Windows From: nicolai.scheer@gmail.com (Nicolai Scheer) --f46d0442838aacf9e804d2c6ddf0 Content-Type: text/plain; charset=UTF-8 Hi! On 8 January 2013 06:48, Pierre Joye wrote: > hi, > > On Mon, Jan 7, 2013 at 10:22 PM, Ferenc Kovacs wrote: > > > is this about allowing the user to shot him/herself in the foot, or > adding > > this feature could potentially break some existing functionality (eg. new > > trick to bypass open_basedir, etc.)? > > All of them, as the paths are passed right to the kernel APIs, without > any system checks like in the higher level APIs (posix or win32). > I justed checked that without any modification the userspace functions unlink() mkdir() rmdir() rename() do work with "\\?\" prefixed paths, because there is no call to expand_filepath() i.e. paths are passed directly. So the only function we needed to modify is php_plain_files_stream_opener... What do you think about adding: zval **ctx_opt = NULL; ... // basedir checks ... if (context) { if ( SUCCESS == php_stream_context_get_option(context, "file", "assume_realpath", &ctx_opt) && Z_TYPE_PP(ctx_opt) == IS_BOOL && Z_LVAL_PP(ctx_opt) == 1) { options = options | STREAM_ASSUME_REALPATH; } } Usually STREAM_ASSUME_REALPATH is set by _php_stream_open_wrapper_ex when USE_PATH is set and the path was resolved successfully. Unfortunately, the following zend_resolve_path fails as before, because of the '?' in the path. With the context option above, I could do the following: array( "assume_realpath" => true ) ); $ctx = stream_context_create( $options ); $fh = fopen( $path, "r", false, $ctx ); Which works without the need to touch MAXPATHLEN by just using the already implemented skip of expand_filepath(). Don't get me wrong, I'm not trying to bend php to allow the usage of this ugly workaround. But as this is quite well documented, and supported on windows, I just like to ask if adding the above context option is a feasable way to prevent php with interfering with the prefix. As of now, there don't seem to be any stream context options for file://. Question here is, if it is ok to expose a stream option telling php "do not interfere with my paths, I'm doing this myself". To my mind, since it already works for anything not involving php_plain_files_stream_opener, this could be ok. There are already a lot of stream context options for other wrappers. And most of them do very lowlevel adjustments... Yes, there are better ways of doing this, but these future implementations will take a lot of time and will not be available within the next months. Of course I'm trying to prevent finding myself compiling php for production use incorporating just such a little change... I currently don't see a way how I could introduce the mentioned context option inside an extension without duplicating a lot of code. Any pointers are welcome... What do you think? Greeting Nico --f46d0442838aacf9e804d2c6ddf0--