Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8bc5679

Browse files
bug #39795 Dont allow unserializing classes with a destructor - 5.1 (jderusse)
This PR was merged into the 5.1 branch. Discussion ---------- Dont allow unserializing classes with a destructor - 5.1 | Q | A | ------------- | --- | Branch? | 5.1 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - Prevent destructors with side-effects from being unserialized Commits ------- 07402f4 Dont allow unserializing classes with a destructor - 5.1
2 parents b2fa405 + 07402f4 commit 8bc5679

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

src/Symfony/Component/HttpClient/Response/AmpResponse.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,16 @@ public function getInfo(string $type = null)
109109
return null !== $type ? $this->info[$type] ?? null : $this->info;
110110
}
111111

112+
public function __sleep()
113+
{
114+
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
115+
}
116+
117+
public function __wakeup()
118+
{
119+
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
120+
}
121+
112122
public function __destruct()
113123
{
114124
try {

src/Symfony/Component/Messenger/Bridge/AmazonSqs/Transport/Connection.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,16 @@ public function __construct(array $configuration, SqsClient $client = null)
6363
$this->client = $client ?? new SqsClient([]);
6464
}
6565

66+
public function __sleep()
67+
{
68+
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
69+
}
70+
71+
public function __wakeup()
72+
{
73+
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
74+
}
75+
6676
public function __destruct()
6777
{
6878
$this->reset();

src/Symfony/Component/String/UnicodeString.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,10 @@ public function startsWith($prefix): bool
359359

360360
public function __wakeup()
361361
{
362+
if (!\is_string($this->string)) {
363+
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
364+
}
365+
362366
normalizer_is_normalized($this->string) ?: $this->string = normalizer_normalize($this->string);
363367
}
364368

0 commit comments

Comments
 (0)