Workaround broken operating systems: check for trailing '/' in filenames (fixes #1989)

git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-1.4.x@2510 152afb58-edef-0310-8abb-c4023f1b3aa9
This commit is contained in:
Stefan Bühler 2009-06-07 19:07:31 +00:00
parent b063f0186a
commit 57066345e4
3 changed files with 17 additions and 2 deletions

1
NEWS
View File

@ -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)

View File

@ -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;

View File

@ -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;
@ -61,6 +61,14 @@ EOF
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 302, 'Location' => 'http://www.example.org:2048/' } ];
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