aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/phpbb/filesystem.php
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@gmx.de>2014-05-13 20:04:53 +0200
committerJoas Schilling <nickvergessen@gmx.de>2014-05-29 23:44:10 +0200
commit638d43d6fea5b5c3c1690b23d7cbe7b9bcef48c9 (patch)
treee71f5a2a63b2fe22123214881eea670b05282839 /phpBB/phpbb/filesystem.php
parent41e52d9c9d3add473f46c6cc12d3fc208516d581 (diff)
downloadforums-638d43d6fea5b5c3c1690b23d7cbe7b9bcef48c9.tar
forums-638d43d6fea5b5c3c1690b23d7cbe7b9bcef48c9.tar.gz
forums-638d43d6fea5b5c3c1690b23d7cbe7b9bcef48c9.tar.bz2
forums-638d43d6fea5b5c3c1690b23d7cbe7b9bcef48c9.tar.xz
forums-638d43d6fea5b5c3c1690b23d7cbe7b9bcef48c9.zip
[ticket/12099] Fix clean_path() ".." stripping when previous directory was "."
PHPBB3-12099
Diffstat (limited to 'phpBB/phpbb/filesystem.php')
-rw-r--r--phpBB/phpbb/filesystem.php2
1 files changed, 1 insertions, 1 deletions
diff --git a/phpBB/phpbb/filesystem.php b/phpBB/phpbb/filesystem.php
index 683a12ab76..77517082e5 100644
--- a/phpBB/phpbb/filesystem.php
+++ b/phpBB/phpbb/filesystem.php
@@ -35,7 +35,7 @@ class filesystem
continue;
}
- if ($part === '..' && !empty($filtered) && $filtered[sizeof($filtered) - 1] !== '..')
+ if ($part === '..' && !empty($filtered) && $filtered[sizeof($filtered) - 1] !== '.' && $filtered[sizeof($filtered) - 1] !== '..')
{
array_pop($filtered);
}
>52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
package resize_fat::io; # $Id$

use diagnostics;
use strict;

use resize_fat::fat;
use c;

1;


sub read($$$) {
    my ($fs, $pos, $size) = @_;
    print "reading $size bytes at $pos\n";
    my $buf = "\0" x $size;
    sysseek $fs->{fd}, $pos, 0 or die "seeking to byte #$pos failed on device $fs->{fs_name}";
    sysread $fs->{fd}, $buf, $size or die "reading at byte #$pos failed on device $fs->{fs_name}";
    $buf;
}
sub write($$$$) {
    my ($fs, $pos, $size, $buf) = @_;
    sysseek $fs->{fd}, $pos, 0 or die "seeking to byte #$pos failed on device $fs->{fs_name}";
    syswrite $fs->{fd}, $buf or die "writing at byte #$pos failed on device $fs->{fs_name}";
}

sub read_cluster($$) {
    my ($fs, $cluster) = @_;
    my $buf;
    my $pos = $fs->{cluster_offset} / 512 + $cluster * ($fs->{cluster_size} / 512);

    c::lseek_sector(fileno $fs->{fd}, $pos, 0) or die "seeking to sector #$pos failed on device $fs->{fs_name}";
    sysread $fs->{fd}, $buf, $fs->{cluster_size} or die "reading at sector #$pos failed on device $fs->{fs_name}";
    $buf;
}
sub write_cluster($$$) {
    my ($fs, $cluster, $buf) = @_;
    my $pos = $fs->{cluster_offset} / 512 + $cluster * ($fs->{cluster_size} / 512);

    c::lseek_sector(fileno $fs->{fd}, $pos, 0) or die "seeking to sector #$pos failed on device $fs->{fs_name}";
    syswrite $fs->{fd}, $buf or die "writing at sector #$pos failed on device $fs->{fs_name}";
}

sub read_file($$) {
    my ($fs, $cluster) = @_;
    my $buf = '';

    for (; !resize_fat::fat::is_eof($cluster); $cluster = resize_fat::fat::next ($fs, $cluster)) {
	$cluster == 0 and die "Bad FAT: unterminated chain\n";
	$buf .= read_cluster($fs, $cluster);
    }
    $buf;
}

sub check_mounted($) {
    my ($f) = @_;

    local *F;
    open F, "/proc/mounts" or die "error opening /proc/mounts\n";
    foreach (<F>) {
	/^$f\s/ and die "device is mounted";
    }
}

sub open {
    my ($fs) = @_;

    check_mounted($fs->{device});

    sysopen $fs->{fd}, $fs->{fs_name}, 2 or
      sysopen $fs->{fd}, $fs->{fs_name}, 0 or die "error opening device $fs->{fs_name} for writing\n";
}