Hi
Since quite some time (weeks), I have this very strange and annoying
include bug in 5.3-dev and now I think is the time to report it :)
The reproducable script is here:
http://trash.chregu.tv/include-bug.php.txt
In short, when I have
foo/alpha (empty)
bar/alpha/bar.php
and set the include path to foo/:bar/
and then do
include("alpha/bar.php");
it throws an not-found error.
But if I remove foo/alpha, it works correctly.
In the meantime (while I wrote this), I found a similar bug report:
http://bugs.php.net/bug.php?id=45044
and added my script.
Can please someone look into that, it's not an area where I feel
comfortable :)
Thanks
chregu
--
New Office Zurich Opening: http://liip.to/party
Liip AG // Feldstrasse 133 // CH-8004 Zurich
Tel +41 43 500 39 81 // Mobile +41 76 561 88 60
www.liip.ch // blog.liip.ch // GnuPG 0x5CE1DECB
Hi!
and set the include path to foo/:bar/
and then do
include("alpha/bar.php");
it throws an not-found error.
Tried that, worked just fine for me - includes bar/alpha/bar.php. I
notice your script on the link does something different, but works for
me too with 5.3 CVS.
Stanislav Malyshev, Zend Software Architect
stas@zend.com http://www.zend.com/
(408)253-8829 MSN: stas@zend.com
Hi!
and set the include path to foo/:bar/
and then do
include("alpha/bar.php");
it throws an not-found error.Tried that, worked just fine for me - includes bar/alpha/bar.php. I
notice your script on the link does something different, but works for
me too with 5.3 CVS.
Did you try it on a *BSD Variant? And do you have an empty foo/alpha/
directory? That's what my script does and with which it fails on OS X.
It seems to work on Linux.
According to http://bugs.php.net/bug.php?id=45044 I'm not the only one
with that problem and it really introduces a lot of issues.
chregu
--
Liip AG // Feldstrasse 133 // CH-8004 Zurich
Tel +41 43 500 39 81 // Mobile +41 76 561 88 60
www.liip.ch // blog.liip.ch // GnuPG 0x5CE1DECB
On Thu, Aug 7, 2008 at 03:18, Christian Stocker
christian.stocker@liip.ch wrote:
According to http://bugs.php.net/bug.php?id=45044 I'm not the only one with
that problem and it really introduces a lot of issues.
You are not the onlyone.
I'm pretty sure I mailed about this to internals@ few weeks ago too,
and bugged few people on IRC, when it caused doc.php.net to go down.
-Hannes
Christian Stocker wrote:
Hi
Since quite some time (weeks), I have this very strange and annoying
include bug in 5.3-dev and now I think is the time to report it :)The reproducable script is here:
http://trash.chregu.tv/include-bug.php.txt
In short, when I have
foo/alpha (empty)
bar/alpha/bar.phpand set the include path to foo/:bar/
and then do
include("alpha/bar.php");
it throws an not-found error.But if I remove foo/alpha, it works correctly.
In the meantime (while I wrote this), I found a similar bug report:
http://bugs.php.net/bug.php?id=45044
and added my script.
Can please someone look into that, it's not an area where I feel
comfortable :)
I have tried to reproduce this on both OSX and FreeBSD and so far I
haven't had any luck.
This is what I have:
11:18am trainburn-lm:~/Web> l foo/alpha/
total 0
drwxr-xr-x 2 rasmus users 68 Aug 7 11:10 ./
drwxr-xr-x 3 rasmus users 102 Aug 7 11:10 ../
11:18am trainburn-lm:~/Web> l bar/alpha/
total 8
drwxr-xr-x 3 rasmus users 102 Aug 7 11:10 ./
drwxr-xr-x 3 rasmus users 102 Aug 7 11:10 ../
-rw-r--r-- 1 rasmus users 12 Aug 7 11:10 bar.php
11:18am trainburn-lm:~/Web> cat foo.php
<?php
ini_set('include_path','foo/:bar/');
include "alpha/bar.php";
?>
I am getting the contents of bar.php quite nicely both from the command
line and through Apache. This should be really easy to debug with gdb,
but it requires a reproducable case.
-Rasmus
Christian Stocker wrote:
Hi
Since quite some time (weeks), I have this very strange and annoying
include bug in 5.3-dev and now I think is the time to report it :)The reproducable script is here:
http://trash.chregu.tv/include-bug.php.txt
In short, when I have
foo/alpha (empty)
bar/alpha/bar.phpand set the include path to foo/:bar/
and then do
include("alpha/bar.php");
it throws an not-found error.But if I remove foo/alpha, it works correctly.
In the meantime (while I wrote this), I found a similar bug report:
http://bugs.php.net/bug.php?id=45044
and added my script.
Can please someone look into that, it's not an area where I feel
comfortable :)I have tried to reproduce this on both OSX and FreeBSD and so far I haven't
had any luck.This is what I have:
11:18am trainburn-lm:~/Web> l foo/alpha/
total 0
drwxr-xr-x 2 rasmus users 68 Aug 7 11:10 ./
drwxr-xr-x 3 rasmus users 102 Aug 7 11:10 ../
11:18am trainburn-lm:~/Web> l bar/alpha/
total 8
drwxr-xr-x 3 rasmus users 102 Aug 7 11:10 ./
drwxr-xr-x 3 rasmus users 102 Aug 7 11:10 ../
-rw-r--r-- 1 rasmus users 12 Aug 7 11:10 bar.php
11:18am trainburn-lm:~/Web> cat foo.php
<?php
ini_set('include_path','foo/:bar/');
include "alpha/bar.php";
?>I am getting the contents of bar.php quite nicely both from the command line
and through Apache. This should be really easy to debug with gdb, but it
requires a reproducable case.
-bash-2.05b$ php include-bug.php.txt
Doesn't work
PHP Warning: include(/usr/home/bjori/php5.3-200808071630/one/alpha/bar.php):
failed to open stream: No such file or directory in
/usr/home/bjori/php5.3-200808071630/include-bug.php.txt on line 40
Warning: include(/usr/home/bjori/php5.3-200808071630/one/alpha/bar.php):
failed to open stream: No such file or directory in
/usr/home/bjori/php5.3-200808071630/include-bug.php.txt on line 40
PHP Warning: include(): Failed opening 'alpha/bar.php' for inclusion
(include_path='./one/:./two/') in
/usr/home/bjori/php5.3-200808071630/include-bug.php.txt on line 40
Warning: include(): Failed opening 'alpha/bar.php' for inclusion
(include_path='./one/:./two/') in
/usr/home/bjori/php5.3-200808071630/include-bug.php.txt on line 40
Now it works:
works
-bash-2.05b$ find one/ two/
one/
two/
two/alpha
two/alpha/bar.php
-bash-2.05b$ uname -a
FreeBSD pb11.pair.com 4.11-STABLE FreeBSD 4.11-STABLE #1: Tue May 3
13:17:19 EDT 2005 root@pb11.pair.com:/usr/obj/usr/src/sys/NEWPB11
i386
-Hannes
Em Qui, 2008-08-07 às 20:55 +0200, Hannes Magnusson escreveu:
Christian Stocker wrote:
Hi
Since quite some time (weeks), I have this very strange and annoying
include bug in 5.3-dev and now I think is the time to report it :)The reproducable script is here:
When trying debug it days ago, I noticed add that:
+++ TSRM/tsrm_virtual_cwd.c 4 Jul 2008 03:05:16 -0000
@@ -557,9 +557,11 @@ CWD_API int virtual_file_ex(cwd_state *s
if (use_realpath != CWD_EXPAND) {
#if !defined(TSRM_WIN32) && !defined(NETWARE)
char resolved_path[MAXPATHLEN];
-
printf(">>> %s\n", path); if (!realpath(path, resolved_path)) { /* Note: Not
threadsafe on older *BSD's */
-
printf(">> 1\n"); if (use_realpath == CWD_REALPATH) {
-
printf(">> 2\n");
LINUX:
/home/felipe/php5/sapi/cli/php
/home/felipe/php5/sapi/cli/php
/home/felipe/php5/sapi/cli/php-cli.ini
1
/usr/local/lib/php-cli.ini
1
/home/felipe/php5/sapi/cli/php.ini
1
/usr/local/lib/php.ini
/usr/local/lib/php.ini
/home/felipe/test/test.php
/home/felipe/./foo.php
1
2
/usr/local/lib/php/foo.php
1
2
/home/felipe/test/foo.php
foo
BSD:
/usr/home/felipe/php5/sapi/cli/php
/usr/home/felipe/test/test.php
/usr/home/felipe/./foo.php
Warning: include(/usr/home/felipe/foo.php): failed to open stream: No
such file or directory in /usr/home/felipe/test/test.php on line 1
Warning: include(): Failed opening 'foo.php' for inclusion
(include_path='.:/usr/local/lib/php') in /usr/home/felipe/test/test.php
on line 1
--
Regards,
Felipe Pena.
Felipe Pena wrote:
Em Qui, 2008-08-07 às 20:55 +0200, Hannes Magnusson escreveu:
Christian Stocker wrote:
Hi
Since quite some time (weeks), I have this very strange and annoying
include bug in 5.3-dev and now I think is the time to report it :)The reproducable script is here:
When trying debug it days ago, I noticed add that:
+++ TSRM/tsrm_virtual_cwd.c 4 Jul 2008 03:05:16 -0000
@@ -557,9 +557,11 @@ CWD_API int virtual_file_ex(cwd_state *s
if (use_realpath != CWD_EXPAND) {
#if !defined(TSRM_WIN32)&& !defined(NETWARE)
char resolved_path[MAXPATHLEN];
printf(">>> %s\n", path); if (!realpath(path, resolved_path)) { /* Note: Not
threadsafe on older *BSD's */
printf(">> 1\n"); if (use_realpath == CWD_REALPATH) {
printf(">> 2\n");
LINUX:
/home/felipe/php5/sapi/cli/php
/home/felipe/php5/sapi/cli/php
/home/felipe/php5/sapi/cli/php-cli.ini
1
/usr/local/lib/php-cli.ini
1
/home/felipe/php5/sapi/cli/php.ini
1
/usr/local/lib/php.ini
/usr/local/lib/php.ini
/home/felipe/test/test.php
/home/felipe/./foo.php
1
2
/usr/local/lib/php/foo.php
1
2
/home/felipe/test/foo.php
foo
BSD:
/usr/home/felipe/php5/sapi/cli/php
/usr/home/felipe/test/test.php
/usr/home/felipe/./foo.phpWarning: include(/usr/home/felipe/foo.php): failed to open stream: No
such file or directory in /usr/home/felipe/test/test.php on line 1Warning: include(): Failed opening 'foo.php' for inclusion
(include_path='.:/usr/local/lib/php') in /usr/home/felipe/test/test.php
on line 1
That's not the same thing though. Your case seems to show that it isn't
using the include_path at all. On BSD after checking ./foo.php why
doesn't it continue on to /usr/local/lib/php/foo.php? It certain does
for me here.
-Rasmus
On Thursday 07 August 2008 21:52:37 Rasmus Lerdorf wrote:
Felipe Pena wrote:
Em Qui, 2008-08-07 às 20:55 +0200, Hannes Magnusson escreveu:
Christian Stocker wrote:
Hi
Since quite some time (weeks), I have this very strange and annoying
include bug in 5.3-dev and now I think is the time to report it :)The reproducable script is here:
When trying debug it days ago, I noticed add that:
+++ TSRM/tsrm_virtual_cwd.c 4 Jul 2008 03:05:16 -0000
@@ -557,9 +557,11 @@ CWD_API int virtual_file_ex(cwd_state *s
if (use_realpath != CWD_EXPAND) {
#if !defined(TSRM_WIN32)&& !defined(NETWARE)
char resolved_path[MAXPATHLEN];
printf(">>> %s\n", path); if (!realpath(path, resolved_path)) { /* Note: Not
threadsafe on older *BSD's */
printf(">> 1\n"); if (use_realpath == CWD_REALPATH) {
printf(">> 2\n");
LINUX:
/home/felipe/php5/sapi/cli/php
/home/felipe/php5/sapi/cli/php
/home/felipe/php5/sapi/cli/php-cli.ini1
/usr/local/lib/php-cli.ini
1
/home/felipe/php5/sapi/cli/php.ini
1
/usr/local/lib/php.ini
/usr/local/lib/php.ini
/home/felipe/test/test.php
/home/felipe/./foo.php1
2/usr/local/lib/php/foo.php
1
2/home/felipe/test/foo.php
foo
BSD:
/usr/home/felipe/php5/sapi/cli/php
/usr/home/felipe/test/test.php
/usr/home/felipe/./foo.phpWarning: include(/usr/home/felipe/foo.php): failed to open stream: No
such file or directory in /usr/home/felipe/test/test.php on line 1Warning: include(): Failed opening 'foo.php' for inclusion
(include_path='.:/usr/local/lib/php') in /usr/home/felipe/test/test.php
on line 1That's not the same thing though. Your case seems to show that it isn't
using the include_path at all. On BSD after checking ./foo.php why
doesn't it continue on to /usr/local/lib/php/foo.php? It certain does
for me here.-Rasmus
Hi,
I had searched the cause of this bug some days ago and posted what I have
found on http://bugs.php.net/bug.php?id=45044 .
virtual_file_ex() assumes that realpath()
returns NULL
when the file does not
exists. But BSD's realpath()
will not return NULL
if all
components but the last exist. So realpath(/foo/bar) will return /foo/bar
even if bar does not exists.
Regards,
Arnaud
virtual_file_ex() assumes that
realpath()
returnsNULL
when the file does not
exists. But BSD'srealpath()
will not returnNULL
if all
components but the last exist. So realpath(/foo/bar) will return /foo/bar
even if bar does not exists.
And that behavior is intended, but is sadly overwritten in ZTS :(
-Hannes
Hi,
The attached patch is going to fix the problem.
It implements its own realpath()
function, so we won't depend on system
anymore. It also improve realpath cache usage by caching intermediate
results.
I tested it on Linux and Windows only and it seems to work without
problems. It breaks one test related to clearstatcache()
function, but
this break is expected.
Could you please test it.
Does it really fix the bug on FreeBSD?
Thanks. Dmitry.
Hannes Magnusson wrote:
virtual_file_ex() assumes that
realpath()
returnsNULL
when the file does not
exists. But BSD'srealpath()
will not returnNULL
if all
components but the last exist. So realpath(/foo/bar) will return /foo/bar
even if bar does not exists.And that behavior is intended, but is sadly overwritten in ZTS :(
-Hannes
Hi Dmitry,
Hi,
The attached patch is going to fix the problem.
It implements its ownrealpath()
function, so we won't depend on system
anymore. It also improve realpath cache usage by caching intermediate
results.I tested it on Linux and Windows only and it seems to work without
problems. It breaks one test related toclearstatcache()
function, but
this break is expected.Could you please test it.
I can test it asap on various windows, probably on Monday.
After a quick review, it seems that FindClose is missing in the two
buffer overflow check.
state->cwd_length += ptr_length;
+#ifdef TSRM_WIN32
if ((hFind = FindFirstFile(to, &data)) != INVALID_HANDLE_VALUE) {
+fprintf(stderr, "1 %s (%d)\n", to, len);
j = strlen(data.cFileName);
i = len;
while (!IS_SLASH(to[i-1])) {
i--;
}
if (i + j >= MAXPATHLEN-1) {
/*buffer overflow */
FindClose(hFind);
return NULL;
}
if (CWDG(realpath_cache_size_limit)) {
memcpy(tmp, to, i);
memcpy(tmp + i, data.cFileName, j + 1);
realpath_cache_add(to, len, tmp, i + j, t TSRMLS_CC);
}
ret -= (j + 1);
if (ret < buf) {
/* buffer overflow */
FindClose(hFind);
return NULL;
}
*ret = DEFAULT_SLASH;
memcpy(ret+1, data.cFileName, j);
FindClose(hFind);
len = i - 1;
to[len] = 0;
+fprintf(stderr, "2 %s - %s\n", to, ret);
continue;
} else {
if (use_realpath == CWD_REALPATH) {
return NULL;
} else {
goto next_dir; }
ptr = tsrm_strtok_r(NULL, TOKENIZER_STRING, &tok); }
Thanks for your work!
Pierre
Hi Pierre,
Thank you for feedback.
I already noticed the missing FindClose() and several other issues.
I'll send updated patch on weekend, but the sooner I get info if bug is
fixed on FreeBSD the better.
Thanks. Dmitry.
Pierre Joye wrote:
Hi Dmitry,
Hi,
The attached patch is going to fix the problem.
It implements its ownrealpath()
function, so we won't depend on system
anymore. It also improve realpath cache usage by caching intermediate
results.I tested it on Linux and Windows only and it seems to work without
problems. It breaks one test related toclearstatcache()
function, but
this break is expected.Could you please test it.
I can test it asap on various windows, probably on Monday.
After a quick review, it seems that FindClose is missing in the two
buffer overflow check.
state->cwd_length += ptr_length;
+#ifdef TSRM_WIN32
if ((hFind = FindFirstFile(to, &data)) != INVALID_HANDLE_VALUE) {
+fprintf(stderr, "1 %s (%d)\n", to, len);
j = strlen(data.cFileName);
i = len;
while (!IS_SLASH(to[i-1])) {
i--;
}
if (i + j >= MAXPATHLEN-1) {
/*buffer overflow */
FindClose(hFind);
return NULL;
}
if (CWDG(realpath_cache_size_limit)) {
memcpy(tmp, to, i);
memcpy(tmp + i, data.cFileName, j + 1);
realpath_cache_add(to, len, tmp, i + j, t TSRMLS_CC);
}
ret -= (j + 1);
if (ret < buf) {
/* buffer overflow */
FindClose(hFind);
return NULL;
}
*ret = DEFAULT_SLASH;
memcpy(ret+1, data.cFileName, j);
FindClose(hFind);
len = i - 1;
to[len] = 0;
+fprintf(stderr, "2 %s - %s\n", to, ret);
continue;
} else {
if (use_realpath == CWD_REALPATH) {
return NULL;
} else {
goto next_dir; }
ptr = tsrm_strtok_r(NULL, TOKENIZER_STRING, &tok); }
Thanks for your work!
Hi,
On Friday 08 August 2008 17:52:26 Dmitry Stogov wrote:
Hi,
The attached patch is going to fix the problem.
It implements its ownrealpath()
function, so we won't depend on system
anymore. It also improve realpath cache usage by caching intermediate
results.I tested it on Linux and Windows only and it seems to work without
problems. It breaks one test related toclearstatcache()
function, but
this break is expected.Could you please test it.
Does it really fix the bug on FreeBSD?
Yes, it fixes the bug on FreeBSD :)
Thanks. Dmitry.
Hannes Magnusson wrote:
virtual_file_ex() assumes that
realpath()
returnsNULL
when the file
does not exists. But BSD'srealpath()
will not returnNULL
if all
components but the last exist. So realpath(/foo/bar) will return
/foo/bar even if bar does not exists.And that behavior is intended, but is sadly overwritten in ZTS :(
-Hannes
Regards,
Arnaud
Great! :)
It's mean I'm on the right way.
The patch still needs additional work and testing, but I hope it'll be
ready before alpha 2.
Thanks. Dmitry.
Arnaud Le Blanc wrote:
Hi,
On Friday 08 August 2008 17:52:26 Dmitry Stogov wrote:
Hi,
The attached patch is going to fix the problem.
It implements its ownrealpath()
function, so we won't depend on system
anymore. It also improve realpath cache usage by caching intermediate
results.I tested it on Linux and Windows only and it seems to work without
problems. It breaks one test related toclearstatcache()
function, but
this break is expected.Could you please test it.
Does it really fix the bug on FreeBSD?Yes, it fixes the bug on FreeBSD :)
Thanks. Dmitry.
Hannes Magnusson wrote:
virtual_file_ex() assumes that
realpath()
returnsNULL
when the file
does not exists. But BSD'srealpath()
will not returnNULL
if all
components but the last exist. So realpath(/foo/bar) will return
/foo/bar even if bar does not exists.
And that behavior is intended, but is sadly overwritten in ZTS :(-Hannes
Regards,
Arnaud
Just semantics but I'd name the function 'tsrm_realpath[_r]' to be absolutely
clear what it does.
--Jani
Dmitry Stogov kirjoitti:
Hi,
The attached patch is going to fix the problem.
It implements its ownrealpath()
function, so we won't depend on system
anymore. It also improve realpath cache usage by caching intermediate
results.I tested it on Linux and Windows only and it seems to work without
problems. It breaks one test related toclearstatcache()
function, but
this break is expected.Could you please test it.
Does it really fix the bug on FreeBSD?Thanks. Dmitry.
Hannes Magnusson wrote:
virtual_file_ex() assumes that
realpath()
returnsNULL
when the file does not
exists. But BSD'srealpath()
will not returnNULL
if all
components but the last exist. So realpath(/foo/bar) will return /foo/bar
even if bar does not exists.
And that behavior is intended, but is sadly overwritten in ZTS :(-Hannes
Dmitry Stogov wrote:
Hi,
The attached patch is going to fix the problem.
It implements its ownrealpath()
function, so we won't depend on system
anymore. It also improve realpath cache usage by caching intermediate
results.
Very nice. The intermediate caching is going to drastically reduce the
amount of memory we need for the cache. I have seen a number of cases
where sites had to increase the realpath cache size by quite a bit.
-Rasmus
Rasmus Lerdorf wrote:
Dmitry Stogov wrote:
Hi,
The attached patch is going to fix the problem.
It implements its ownrealpath()
function, so we won't depend on system
anymore. It also improve realpath cache usage by caching intermediate
results.Very nice. The intermediate caching is going to drastically reduce the
amount of memory we need for the cache. I have seen a number of cases
where sites had to increase the realpath cache size by quite a bit.
Oh, and on top of that we also get a big performance improvement for
include_path misses since we no longer have to re-stat every component
of the docroot on every miss.
-Rasmus
The improved patch fixes all the issues I found during testing.
However I wasn't able to test it on NETWARE and on Solaris with relative
paths.
Please test it as much as possible.
I'm going to commit it on Tuesday in case of no objections.
Thanks. Dmitry.
Rasmus Lerdorf wrote:
Rasmus Lerdorf wrote:
Dmitry Stogov wrote:
Hi,
The attached patch is going to fix the problem.
It implements its ownrealpath()
function, so we won't depend on system
anymore. It also improve realpath cache usage by caching intermediate
results.Very nice. The intermediate caching is going to drastically reduce the
amount of memory we need for the cache. I have seen a number of cases
where sites had to increase the realpath cache size by quite a bit.Oh, and on top of that we also get a big performance improvement for
include_path misses since we no longer have to re-stat every component
of the docroot on every miss.-Rasmus
hi Dmitry,
The improved patch fixes all the issues I found during testing.
However I wasn't able to test it on NETWARE and on Solaris with relative
paths.Please test it as much as possible.
I run the test suite and the results can be seen here:
There is two failing for real path (Server 2008, Vista 64 and XP (32 and 64)):
Test realpath()
function: basic functionality
[C:\Users\pierre\Documents\php-sdk\vc9\x86\php_5_3\ext\standard\tests\file\realpath_basic-win32.phpt]
realpath()
with relative directory
[C:\Users\pierre\Documents\php-sdk\vc9\x86\php_5_3\ext\standard\tests\file\realpath_basic2.phpt]
Some other may fail because of a change in realpath behavior. I will
run them again without the patch and post again the affected tests.
I'm going to commit it on Tuesday in case of no objections.
A FindClose is missing:
+#ifdef TSRM_WIN32
if (save && (hFind = FindFirstFile(path, &data)) == INVALID_HANDLE_VALUE) { if (use_realpath == CWD_REALPATH) {
return 1;
/* file not found */
return -1; }
.....
if (save) {
directory = (data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0;
if (is_dir && !directory) {
/* not a directory */
FindClose(hFind);
return -1;
}
}
tmp = tsrm_do_alloca(len+1, use_heap);
memcpy(tmp, path, len+1);
+#elif defined(NETWARE)
save = 0;
tmp = tsrm_do_alloca(len+1, use_heap);
memcpy(tmp, path, len+1);
#else
Cheers,
Pierre
Hi Pierre,
Thank you for feedback.
You are definitely right about FindClose().
The failure of realpath_basic-win32.phpt is expected, as behavior of
realpath()
became the same as on Linux (slashes after regular file name
are not allowed).
I wasn't able to reproduce realpath_basic2.phpt failure (may be because
I added missing FindClose()).
Thanks. Dmitry.
Pierre Joye wrote:
hi Dmitry,
The improved patch fixes all the issues I found during testing.
However I wasn't able to test it on NETWARE and on Solaris with relative
paths.Please test it as much as possible.
I run the test suite and the results can be seen here:
There is two failing for real path (Server 2008, Vista 64 and XP (32 and 64)):
Test
realpath()
function: basic functionality
[C:\Users\pierre\Documents\php-sdk\vc9\x86\php_5_3\ext\standard\tests\file\realpath_basic-win32.phpt]
realpath()
with relative directory
[C:\Users\pierre\Documents\php-sdk\vc9\x86\php_5_3\ext\standard\tests\file\realpath_basic2.phpt]Some other may fail because of a change in realpath behavior. I will
run them again without the patch and post again the affected tests.I'm going to commit it on Tuesday in case of no objections.
A FindClose is missing:
+#ifdef TSRM_WIN32
if (save && (hFind = FindFirstFile(path, &data)) == INVALID_HANDLE_VALUE) { if (use_realpath == CWD_REALPATH) {
return 1;
/* file not found */
return -1; }
.....
if (save) {
directory = (data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0;
if (is_dir && !directory) {
/* not a directory */
FindClose(hFind);
return -1;
}
}
tmp = tsrm_do_alloca(len+1, use_heap);
memcpy(tmp, path, len+1);
+#elif defined(NETWARE)
save = 0;
tmp = tsrm_do_alloca(len+1, use_heap);
memcpy(tmp, path, len+1);
#else
Cheers,
The failure of realpath_basic-win32.phpt is expected, as behavior of
realpath()
became the same as on Linux (slashes after regular file
name are not allowed).
Lets make extra sure that when you commit these kinds of platform
unifications, that you use the [DOC] tag so that things get documented
(and adding a note to the 5.3 upgrading scratch pad [1] would also be
nice).
regards,
Lukas Kahwe Smith
mls@pooteeweet.org
The improved patch fixes all the issues I found during testing.
However I wasn't able to test it on NETWARE and on Solaris with relative
paths.Please test it as much as possible.
I'm going to commit it on Tuesday in case of no objections.
ext/standard/tests/file/clearstatcache_001.phpt fails with the patch applied.
--
Wbr,
Antony Dovgal
On Saturday 09 August 2008 23:16:30 Antony Dovgal wrote:
The improved patch fixes all the issues I found during testing.
However I wasn't able to test it on NETWARE and on Solaris with relative
paths.Please test it as much as possible.
I'm going to commit it on Tuesday in case of no objections.ext/standard/tests/file/clearstatcache_001.phpt fails with the patch
applied.--
Wbr,
Antony Dovgal
Hi,
The test was wrong, I fixed it.
Regards,
Arnaud
This test failure is expected, but only this one.
Thanks. Dmitry.
Antony Dovgal wrote:
The improved patch fixes all the issues I found during testing.
However I wasn't able to test it on NETWARE and on Solaris with
relative paths.Please test it as much as possible.
I'm going to commit it on Tuesday in case of no objections.ext/standard/tests/file/clearstatcache_001.phpt fails with the patch
applied.
The improved patch fixes all the issues I found during testing.
However I wasn't able to test it on NETWARE and on Solaris with relative
paths.Please test it as much as possible.
I'm going to commit it on Tuesday in case of no objections.
These three tests fail on AIX without the patch and pass with it,
so the patch seems to fix some issues indeed =)
ext/standard/tests/file/readlink_realpath_basic1.phpt
ext/standard/tests/file/readlink_realpath_basic2.phpt
ext/standard/tests/file/realpath_basic3.phpt
--
Wbr,
Antony Dovgal
Hi Dmitry
Hi,
The attached patch is going to fix the problem.
Works also on my OS X 10.4 box now. Thanks a lot for the effort (and if
it brings a performance boost, even better :) )
chregu
It implements its own
realpath()
function, so we won't depend on system
anymore. It also improve realpath cache usage by caching intermediate
results.I tested it on Linux and Windows only and it seems to work without
problems. It breaks one test related toclearstatcache()
function, but
this break is expected.Could you please test it.
Does it really fix the bug on FreeBSD?Thanks. Dmitry.
Hannes Magnusson wrote:
virtual_file_ex() assumes that
realpath()
returnsNULL
when the file does not
exists. But BSD'srealpath()
will not returnNULL
if all
components but the last exist. So realpath(/foo/bar) will return /foo/bar
even if bar does not exists.
And that behavior is intended, but is sadly overwritten in ZTS :(-Hannes
--
New Office Zurich Opening: http://liip.to/party
Liip AG // Feldstrasse 133 // CH-8004 Zurich
Tel +41 43 500 39 81 // Mobile +41 76 561 88 60
www.liip.ch // blog.liip.ch // GnuPG 0x5CE1DECB
Hi,
The attached patch is going to fix the problem.
It implements its ownrealpath()
function, so we won't depend on system
anymore. It also improve realpath cache usage by caching intermediate
results.I tested it on Linux and Windows only and it seems to work without
problems. It breaks one test related toclearstatcache()
function, but
this break is expected.Could you please test it.
Does it really fix the bug on FreeBSD?
Yup. But it introduces a new one.
realpath()
no longer works as documented, now requiring all the
components to exist.
-Hannes
Where is it documented?
The realpath()
implementation conforming to 4.4BSD and POSIX.1-2001
requires file existence. With the patch it'll work in the same standard
way on all systems.
Thanks. Dmitry.
Hannes Magnusson wrote:
Hi,
The attached patch is going to fix the problem.
It implements its ownrealpath()
function, so we won't depend on system
anymore. It also improve realpath cache usage by caching intermediate
results.I tested it on Linux and Windows only and it seems to work without
problems. It breaks one test related toclearstatcache()
function, but
this break is expected.Could you please test it.
Does it really fix the bug on FreeBSD?Yup. But it introduces a new one.
realpath()
no longer works as documented, now requiring all the
components to exist.-Hannes
Where is it documented?
http://php.net/realpath
http://www.ipnom.com/FreeBSD-Man-Pages/realpath.3.html
-Hannes
hi all!
On Sat, Aug 9, 2008 at 12:41 PM, Hannes Magnusson
hannes.magnusson@gmail.com wrote:
Where is it documented?
http://php.net/realpath
http://www.ipnom.com/FreeBSD-Man-Pages/realpath.3.html
"On BSD systems realpath()
doesn't fail if only the last path
component doesn't exist, while other systems will return FALSE."
This behavior has genearated enough pain in the past to be dropped.
The key problem in php application is portability. I'm in favor of
dropping this BSD specific thing in 5.3+.
Cheers,
Pierre
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hello Dmitry,
while you are at fixing realpath()
it might be a good idea to fix the
../ nonsense.
What I mean is:
fopen("this_is_not_a_dir_but_a_file/../../../../../../../../etc/passwd",
"r");
works because of realpath()
and PHP's wrapper.
Same for
fopen("this_is_not_existing/../../../../../../../../etc/passwd", "r");
Both is madness...
Stefan
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.8 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEUEARECAAYFAkidgR0ACgkQSuF5XhWr2nhovACXZpeATBITDai/M1wsCuavuZ3C
OgCgn46uM4XHwENW7si4aJzeNgnuTKg=
=QiYy
-----END PGP SIGNATURE
Stefan Esser wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1Hello Dmitry,
while you are at fixing
realpath()
it might be a good idea to fix the
../ nonsense.What I mean is:
fopen("this_is_not_a_dir_but_a_file/../../../../../../../../etc/passwd",
"r");works because of
realpath()
and PHP's wrapper.Same for
fopen("this_is_not_existing/../../../../../../../../etc/passwd", "r");
Dmitry, I think this is a good suggestion. If any component of the
path, other than the final one is not a directory, or if a component of
the path doesn't exist, the realpath call should fail. We're doing the
stat on each one anyway, so checking the entry type shouldn't be an issue.
-Rasmus
This behavior is already implemented in "improved" patch that I sent on
Saturday.
Thanks. Dmitry.
Rasmus Lerdorf wrote:
Stefan Esser wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1Hello Dmitry,
while you are at fixing
realpath()
it might be a good idea to fix the
../ nonsense.What I mean is:
fopen("this_is_not_a_dir_but_a_file/../../../../../../../../etc/passwd",
"r");works because of
realpath()
and PHP's wrapper.Same for
fopen("this_is_not_existing/../../../../../../../../etc/passwd", "r");
Dmitry, I think this is a good suggestion. If any component of the
path, other than the final one is not a directory, or if a component of
the path doesn't exist, the realpath call should fail. We're doing the
stat on each one anyway, so checking the entry type shouldn't be an issue.-Rasmus
Dmitry Stogov wrote:
This behavior is already implemented in "improved" patch that I sent on
Saturday.Thanks. Dmitry.
[snip]
What I mean is:
fopen("this_is_not_a_dir_but_a_file/../../../../../../../../etc/passwd",
"r");works because of
realpath()
and PHP's wrapper.
[snip]
Does this change affect code like:
include "../file.php";
?
Thanks,
Greg
Dmitry Stogov wrote:
This behavior is already implemented in "improved" patch that I sent on
Saturday.Thanks. Dmitry.
[snip]
What I mean is:
fopen("this_is_not_a_dir_but_a_file/../../../../../../../../etc/passwd",
"r");works because of
realpath()
and PHP's wrapper.[snip]
Does this change affect code like:
include "../file.php";
I was thinking along the same line. I bet some people have been lazy
and used FILE. "/../../foobar.php".
But then again, maybe they deserve to be punished :)
-Hannes
Does this change affect code like:
include "../file.php";
That will work fine.
I was thinking along the same line. I bet some people have been lazy
and used FILE. "/../../foobar.php".
That will not work. And that is moronic code anyway. Why wouldn't they
use DIR there?
-Rasmus
FILE. "/../../foobar.php" probably could work on Windows/BSD only,
but won't work anymore.
The patch is committed.
Thanks. Dmitry.
Rasmus Lerdorf wrote:
Does this change affect code like:
include "../file.php";
That will work fine.
I was thinking along the same line. I bet some people have been lazy
and used FILE. "/../../foobar.php".That will not work. And that is moronic code anyway. Why wouldn't they
use DIR there?-Rasmus
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi Dmitry,
FILE. "/../../foobar.php" probably could work on Windows/BSD only,
but won't work anymore.
this works on Linux and everywhere where GLIBC is used, because GLIBC
realpath()
supports this nonsense.
Stefan
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.8 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEYEARECAAYFAkihRmwACgkQSuF5XhWr2nhv5gCgsRSUMOtc8/PcsugrL3xTNar0
iYIAoIVA4fO5dWwRfxIzHpYfhNFNNuA4
=tAba
-----END PGP SIGNATURE
realpath(FILE . "/..") doesn't work (returns false) on php-5.2
Linux, however include(FILE . "/../some.php") worked with 5.2.
Thanks. Dmitry.
Stefan Esser wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1Hi Dmitry,
FILE. "/../../foobar.php" probably could work on Windows/BSD only,
but won't work anymore.this works on Linux and everywhere where GLIBC is used, because GLIBC
realpath()
supports this nonsense.Stefan
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.8 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.orgiEYEARECAAYFAkihRmwACgkQSuF5XhWr2nhv5gCgsRSUMOtc8/PcsugrL3xTNar0
iYIAoIVA4fO5dWwRfxIzHpYfhNFNNuA4
=tAba
-----END PGP SIGNATURE
I was thinking along the same line. I bet some people have been lazy
and used FILE. "/../../foobar.php".That will not work. And that is moronic code anyway. Why wouldn't they use
DIR there?
Because it didn't exist until 5.3 (or 5.2.7, don't remember) and they
are to lazy to do dirname(FILE)...
It is silly, but still an "edge case" we need to add to the "backwards
compatibility breaks" document :)
-Hannes