Skip to content

Commit 235b80a

Browse files
committed
Disallow more patterns
1 parent 1cc439c commit 235b80a

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

system/application/libraries/File_Upload.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ public function __construct() {}
99
// Upload a file (e.g., "Loocal Media Files")
1010
public function uploadMedia($slug,$chmodMode,$versions=null) {
1111
if (empty($_FILES)) throw new Exception('Could not find uploaded file');
12+
$prepends = array('', 'media');
1213
$path =@ $_POST['slug_prepend'];
14+
if (!in_array($path, $prepends)) throw new Exception('Invalid prepend');
1315
$targetPath = confirm_slash(FCPATH).$slug.$path;
1416
if (!file_exists($targetPath)) mkdir($targetPath, $chmodMode, true);
1517
$tempFile = $_FILES['source_file']['tmp_name'];
@@ -20,6 +22,7 @@ public function uploadMedia($slug,$chmodMode,$versions=null) {
2022
$version = $versions->get($version_id);
2123
$name = $version->url;
2224
if (substr($name, 0, 6)=='media/') $name = substr($name, 6); // Don't use ltrim() because of an apparent OS X bug (we have verifiable problems when a filename began with "em")
25+
if (!$this->is_allowed($name)) throw new Exception('Invalid replacement name');
2326
}
2427
$targetFile = rtrim($targetPath,'/') . '/' . $name;
2528
$this->upload($tempFile,$targetFile,$chmodMode);

0 commit comments

Comments
 (0)