Skip to content

Commit 205754c

Browse files
author
Viktor Tymchynskyi
committed
MAGETWO-32382: Review and fix all deserialization in Magento
- Rename __distruct() into distruct() in vulnerable classes - Add register_shutdown_function(array($this, 'distruct')) into __construct()
1 parent b4128b2 commit 205754c

File tree

2 files changed

+16
-2
lines changed
  • app/code/Magento/ImportExport/Model

2 files changed

+16
-2
lines changed

app/code/Magento/ImportExport/Model/Export/Adapter/Csv.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,21 @@ class Csv extends \Magento\ImportExport\Model\Export\Adapter\AbstractAdapter
3333
*/
3434
protected $_fileHandler;
3535

36+
/**
37+
* {@inheritdoc }
38+
*/
39+
public function __construct(\Magento\Framework\Filesystem $filesystem, $destination = null)
40+
{
41+
register_shutdown_function([$this, 'destruct']);
42+
parent::__construct($filesystem, $destination);
43+
}
44+
3645
/**
3746
* Object destructor.
47+
*
48+
* @return void
3849
*/
39-
public function __destruct()
50+
public function destruct()
4051
{
4152
if (is_object($this->_fileHandler)) {
4253
$this->_fileHandler->close();

app/code/Magento/ImportExport/Model/Import/Source/Csv.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public function __construct(
4444
$delimiter = ',',
4545
$enclosure = '"'
4646
) {
47+
register_shutdown_function([$this, 'destruct']);
4748
try {
4849
$this->_file = $directory->openFile($directory->getRelativePath($file), 'r');
4950
} catch (\Magento\Framework\Exception\FileSystemException $e) {
@@ -58,8 +59,10 @@ public function __construct(
5859

5960
/**
6061
* Close file handle
62+
*
63+
* @return void
6164
*/
62-
public function __destruct()
65+
public function destruct()
6366
{
6467
if (is_object($this->_file)) {
6568
$this->_file->close();

0 commit comments

Comments
 (0)