Skip to content
Permalink
Browse files Browse the repository at this point in the history
Merge pull request from GHSA-h632-p764-pjqm
Co-authored-by: Mark Lewis <mark@netalico.com>
  • Loading branch information
colinmollenhour and mark-netalico committed Jan 26, 2023
1 parent 45330ff commit d16fc6c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
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
Expand Up @@ -484,10 +484,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)) {

Check failure on line 497 in lib/Varien/Io/File.php

GitHub Actions / PHPStan / Analyze

Call to method Varien_Io_File::_isValidSource() with incorrect case: _IsValidSource
return false;
}

Expand Down

0 comments on commit d16fc6c

Please sign in to comment.