Skip to content

Commit 1ed3241

Browse files
nicolas-grekasthePanz
authored andcommitted
Don't trust properties at destruct time
(cherry picked from commit 5878b18)
1 parent b84ee52 commit 1ed3241

File tree

4 files changed

+31
-0
lines changed

4 files changed

+31
-0
lines changed

lib/classes/Swift/ByteStream/TemporaryFileByteStream.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,14 @@ public function __destruct()
3939
@unlink($this->getPath());
4040
}
4141
}
42+
43+
public function __sleep()
44+
{
45+
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
46+
}
47+
48+
public function __wakeup()
49+
{
50+
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
51+
}
4252
}

lib/classes/Swift/KeyCache/DiskKeyCache.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,4 +318,9 @@ public function __destruct()
318318
$this->clearAll($nsKey);
319319
}
320320
}
321+
322+
public function __wakeup()
323+
{
324+
$this->keys = [];
325+
}
321326
}

lib/classes/Swift/Mime/SimpleMimeEntity.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -843,4 +843,10 @@ public function __clone()
843843
}
844844
$this->setChildren($children);
845845
}
846+
847+
public function __wakeup()
848+
{
849+
$this->cacheKey = bin2hex(random_bytes(16)); // set 32 hex values
850+
$this->cache = new Swift_KeyCache_ArrayKeyCache(new Swift_KeyCache_SimpleKeyCacheInputStream());
851+
}
846852
}

lib/classes/Swift/Transport/AbstractSmtpTransport.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,4 +496,14 @@ public function __destruct()
496496
} catch (Exception $e) {
497497
}
498498
}
499+
500+
public function __sleep()
501+
{
502+
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
503+
}
504+
505+
public function __wakeup()
506+
{
507+
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
508+
}
499509
}

0 commit comments

Comments
 (0)