Skip to content

Commit 6bd286a

Browse files
author
Daniel Neto
committed
fix: Validate filename in _file_put_contents and update uploadPoster to use internal path for thumbnails
1 parent a3ed3b6 commit 6bd286a

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

objects/functionsFile.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -810,6 +810,10 @@ function getTmpFile()
810810

811811
function _file_put_contents($filename, $data, $flags = 0, $context = null)
812812
{
813+
if (!is_string($filename) || trim($filename) === '') {
814+
_error_log("_file_put_contents: empty filename");
815+
return false;
816+
}
813817
make_path($filename);
814818
if (!is_string($data)) {
815819
$data = _json_encode($data);

plugin/Live/uploadPoster.json.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@
4444
// SECURITY: Use internal path for file operations but don't expose to API
4545
$internalPathThumbs = $global['systemRootPath'] . Live::_getPosterThumbsImage(User::getId(), $live_servers_id, $posterType);
4646

47-
_error_log("removePoster.php ({$obj->pathThumbs}) unlink line=" . __LINE__);
48-
@unlink($obj->pathThumbs);
47+
_error_log("removePoster.php ({$internalPathThumbs}) unlink line=" . __LINE__);
48+
@unlink($internalPathThumbs);
4949
$obj->error = false;
5050
}
5151
}
@@ -63,10 +63,9 @@
6363
}
6464

6565
if (!empty($jsonTargetImagePath)) {
66-
$obj->jsonFile = str_replace('.jpg', '.json', $jsonTargetImagePath);
67-
$obj->jsonFileBytes = _file_put_contents($obj->jsonFile, $o);
66+
$jsonFilePath = str_replace('.jpg', '.json', $jsonTargetImagePath);
67+
$obj->jsonFileBytes = _file_put_contents($jsonFilePath, $o);
6868
} else {
69-
$obj->jsonFile = '';
7069
$obj->jsonFileBytes = false;
7170
}
7271
}

0 commit comments

Comments
 (0)