Skip to content

Commit

Permalink
Fixed issue: Security problems with uploaded files in administration
Browse files Browse the repository at this point in the history
  • Loading branch information
c-schmitz committed Mar 7, 2013
1 parent a606982 commit ff144cc
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion application/controllers/admin/dataentry.php
Expand Up @@ -296,7 +296,7 @@ private function _readFile($filePath)
private function _moveUploadedFile($aData)
{
$clang = $this->getController()->lang;
$the_full_file_path = Yii::app()->getConfig('tempdir') . "/" . $_FILES['the_file']['name'];
$the_full_file_path = Yii::app()->getConfig('tempdir') . "/" . randomChars(20);

$move_uploaded_file_result = @move_uploaded_file($_FILES['the_file']['tmp_name'], $the_full_file_path);

Expand Down
2 changes: 1 addition & 1 deletion application/controllers/admin/labels.php
Expand Up @@ -125,7 +125,7 @@ public function import()
{
Yii::app()->loadHelper('admin/import');

$sFullFilepath = Yii::app()->getConfig('tempdir') . DIRECTORY_SEPARATOR . $_FILES['the_file']['name'];
$sFullFilepath = Yii::app()->getConfig('tempdir') . DIRECTORY_SEPARATOR . randomChars(20);
$aPathInfo = pathinfo($sFullFilepath);
$sExtension = !empty($aPathInfo['extension']) ? $aPathInfo['extension'] : '';

Expand Down
2 changes: 1 addition & 1 deletion application/controllers/admin/question.php
Expand Up @@ -47,7 +47,7 @@ public function import()

if ($action == 'importquestion')
{
$sFullFilepath = Yii::app()->getConfig('tempdir') . DIRECTORY_SEPARATOR . $_FILES['the_file']['name'];
$sFullFilepath = Yii::app()->getConfig('tempdir') . DIRECTORY_SEPARATOR . randomChars(20);
$aPathInfo = pathinfo($sFullFilepath);
$sExtension = $aPathInfo['extension'];

Expand Down
2 changes: 1 addition & 1 deletion application/controllers/admin/questiongroup.php
Expand Up @@ -46,7 +46,7 @@ function import()
$importgroup = "\n";
$importgroup .= "\n";

$sFullFilepath = Yii::app()->getConfig('tempdir') . DIRECTORY_SEPARATOR . $_FILES['the_file']['name'];
$sFullFilepath = Yii::app()->getConfig('tempdir') . DIRECTORY_SEPARATOR . randomChars(20);
$aPathInfo = pathinfo($sFullFilepath);
$sExtension = $aPathInfo['extension'];

Expand Down
2 changes: 1 addition & 1 deletion application/controllers/admin/surveyadmin.php
Expand Up @@ -885,7 +885,7 @@ public function copy()
if ($action == 'importsurvey')
{

$the_full_file_path = Yii::app()->getConfig('tempdir') . DIRECTORY_SEPARATOR . randomChars(20).'_'.$_FILES['the_file']['name'];
$the_full_file_path = Yii::app()->getConfig('tempdir') . DIRECTORY_SEPARATOR . randomChars(20);
if (!@move_uploaded_file($_FILES['the_file']['tmp_name'], $the_full_file_path))
{
$aData['sErrorMessage'] = sprintf($clang->gT("An error occurred uploading your file. This may be caused by incorrect permissions in your %s folder."), Yii::app()->getConfig('tempdir'));
Expand Down
3 changes: 1 addition & 2 deletions application/controllers/admin/tokens.php
Expand Up @@ -1830,9 +1830,8 @@ function import($iSurveyId)
$firstline = array();

$sPath = Yii::app()->getConfig('tempdir');
$sFileName = $_FILES['the_file']['name'];
$sFileTmpName = $_FILES['the_file']['tmp_name'];
$sFilePath = $sPath . '/' . $sFileName;
$sFilePath = $sPath . '/' . randomChars(20);

if (!@move_uploaded_file($sFileTmpName, $sFilePath))
{
Expand Down

0 comments on commit ff144cc

Please sign in to comment.