Skip to content

Commit

Permalink
Merge pull request from GHSA-h632-p764-pjqm
Browse files Browse the repository at this point in the history
Co-authored-by: Mark Lewis <mark@netalico.com>
  • Loading branch information
2 people authored and fballiano committed Jan 26, 2023
1 parent d31571c commit 68a1310
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,12 @@ public function addImage(
$move = false,
$exclude = true
) {
if (strpos($file, chr(0)) !== false
|| preg_match('#(^|[\\\\/])\.\.($|[\\\\/])#', $file)
) {
throw new Exception('Detected malicious path or filename input.');
}
$file = realpath($file);
if (!$file || !file_exists($file)) {
Expand Down
9 changes: 8 additions & 1 deletion lib/Varien/Io/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -459,10 +459,17 @@ public function read($filename, $dest = null)
* @param int $mode
*
* @return int|boolean
* @throws Exception
*/
public function write($filename, $src, $mode = null)
{
if (!$this->_isValidSource($src) || !$this->_isFilenameWriteable($filename)) {
if (strpos($filename, chr(0)) !== false
|| preg_match('#(^|[\\\\/])\.\.($|[\\\\/])#', $filename)
) {
throw new Exception('Detected malicious path or filename input.');
}
if (!$this->_IsValidSource($src) || !$this->_isFilenameWriteable($filename)) {
return false;
}
Expand Down

0 comments on commit 68a1310

Please sign in to comment.