File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed
app/code/core/Mage/Catalog/Model/Product/Attribute/Backend Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -276,6 +276,12 @@ public function addImage(
276
276
$ move = false ,
277
277
$ exclude = true
278
278
) {
279
+ if (strpos ($ file , chr (0 )) !== false
280
+ || preg_match ('#(^|[ \\\\/])\.\.($|[ \\\\/])# ' , $ file )
281
+ ) {
282
+ throw new Exception ('Detected malicious path or filename input. ' );
283
+ }
284
+
279
285
$ file = realpath ($ file );
280
286
281
287
if (!$ file || !file_exists ($ file )) {
Original file line number Diff line number Diff line change @@ -459,10 +459,17 @@ public function read($filename, $dest = null)
459
459
* @param int $mode
460
460
*
461
461
* @return int|boolean
462
+ * @throws Exception
462
463
*/
463
464
public function write ($ filename , $ src , $ mode = null )
464
465
{
465
- if (!$ this ->_isValidSource ($ src ) || !$ this ->_isFilenameWriteable ($ filename )) {
466
+ if (strpos ($ filename , chr (0 )) !== false
467
+ || preg_match ('#(^|[ \\\\/])\.\.($|[ \\\\/])# ' , $ filename )
468
+ ) {
469
+ throw new Exception ('Detected malicious path or filename input. ' );
470
+ }
471
+
472
+ if (!$ this ->_IsValidSource ($ src ) || !$ this ->_isFilenameWriteable ($ filename )) {
466
473
return false ;
467
474
}
468
475
You can’t perform that action at this time.
0 commit comments