summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Bühler <stbuehler@web.de>2009-06-07 19:07:31 +0000
committerStefan Bühler <stbuehler@web.de>2009-06-07 19:07:31 +0000
commit7be235de1412cef35b4c3c2b662efd82f4bfce67 (patch)
tree0c1906b5249a777fd84c34385d5a246f4b5a8886
parentbf316421a61fffdcb7a03cb191ed258c76588131 (diff)
downloadlighttpd-git-7be235de1412cef35b4c3c2b662efd82f4bfce67.tar.gz
Workaround broken operating systems: check for trailing '/' in filenames (fixes #1989)
git-svn-id: svn+ssh://svn.lighttpd.net/lighttpd/branches/lighttpd-1.4.x@2510 152afb58-edef-0310-8abb-c4023f1b3aa9
-rw-r--r--NEWS1
-rw-r--r--src/stat_cache.c6
-rwxr-xr-xtests/mod-fastcgi.t12
3 files changed, 17 insertions, 2 deletions
diff --git a/NEWS b/NEWS
index fb8eeda5..68b43ce0 100644
--- a/NEWS
+++ b/NEWS
@@ -45,6 +45,7 @@ NEWS
* Modify fastcgi error message
* Backup errno for later usage (reported by Guido Reina via mailinglist)
* Improve FastCGI performance (fixes #1999)
+ * Workaround broken operating systems: check for trailing '/' in filenames (fixes #1989)
- 1.4.22 - 2009-03-07
* Fix wrong lua type for CACHE_MISS/CACHE_HIT in mod_cml (fixes #533)
diff --git a/src/stat_cache.c b/src/stat_cache.c
index 15410760..26571437 100644
--- a/src/stat_cache.c
+++ b/src/stat_cache.c
@@ -489,6 +489,12 @@ handler_t stat_cache_get_entry(server *srv, connection *con, buffer *name, stat_
if (S_ISREG(st.st_mode)) {
+ /* fix broken stat/open for symlinks to reg files with appended slash on freebsd,osx */
+ if (name->ptr[name->used-2] == '/') {
+ errno = ENOTDIR;
+ return HANDLER_ERROR;
+ }
+
/* try to open the file to check if we can read it */
if (-1 == (fd = open(name->ptr, O_RDONLY))) {
return HANDLER_ERROR;
diff --git a/tests/mod-fastcgi.t b/tests/mod-fastcgi.t
index e5057bd9..b5f74d64 100755
--- a/tests/mod-fastcgi.t
+++ b/tests/mod-fastcgi.t
@@ -7,7 +7,7 @@ BEGIN {
}
use strict;
-use Test::More tests => 52;
+use Test::More tests => 53;
use LightyTest;
my $tf = LightyTest->new();
@@ -25,7 +25,7 @@ SKIP: {
}
SKIP: {
- skip "no PHP running on port 1026", 29 unless $tf->listening_on(1026);
+ skip "no PHP running on port 1026", 30 unless $tf->listening_on(1026);
ok($tf->start_proc == 0, "Starting lighttpd") or goto cleanup;
@@ -62,6 +62,14 @@ EOF
ok($tf->handle_http($t) == 0, 'Status + Location via FastCGI');
$t->{REQUEST} = ( <<EOF
+GET /redirect.php/ HTTP/1.0
+Host: www.example.org
+EOF
+ );
+ $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 302, 'Location' => 'http://www.example.org:2048/' } ];
+ ok($tf->handle_http($t) == 0, 'Trailing slash as path-info (#1989: workaround broken operating systems)');
+
+ $t->{REQUEST} = ( <<EOF
GET /get-server-env.php?env=PHP_SELF HTTP/1.0
Host: www.example.org
EOF