Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ext/snmp/snmp.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ function snmp_get_valueretrieval(): int {}

function snmp_read_mib(string $filename): bool {}

/** @not-serializable */
class SNMP
{
/** @cvalue SNMP_VERSION_1 */
Expand Down
4 changes: 2 additions & 2 deletions ext/snmp/snmp_arginfo.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 6 additions & 22 deletions ext/snmp/tests/bug72479.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,12 @@ require_once(__DIR__.'/skipif.inc');
<?php
$arr = [1, [1, 2, 3, 4, 5], 3, 4, 5];
$poc = 'a:3:{i:1;N;i:2;O:4:"snmp":1:{s:11:"quick_print";'.serialize($arr).'}i:1;R:7;}';
$out = unserialize($poc);
gc_collect_cycles();
$fakezval = ptr2str(1122334455);
$fakezval .= ptr2str(0);
$fakezval .= "\x00\x00\x00\x00";
$fakezval .= "\x01";
$fakezval .= "\x00";
$fakezval .= "\x00\x00";
for ($i = 0; $i < 5; $i++) {
$v[$i] = $fakezval.$i;
}
var_dump($out[1]);

function ptr2str($ptr)
{
$out = '';
for ($i = 0; $i < 8; $i++) {
$out .= chr($ptr & 0xff);
$ptr >>= 8;
}
return $out;
try {
$out = unserialize($poc);
var_dump($out);
} catch (Exception $e) {
echo $e->getMessage() . "\n";
}
?>
--EXPECT--
int(1)
Unserialization of 'SNMP' is not allowed
17 changes: 17 additions & 0 deletions ext/snmp/tests/gh21682.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
--TEST--
GH-21682 (SNMP should not be serializable)
--EXTENSIONS--
snmp
--FILE--
<?php
$s = new SNMP(SNMP::VERSION_1, "localhost", "public");
try {
serialize($s);
echo "ERROR: should have thrown\n";
} catch (\Exception $e) {
echo $e->getMessage() . "\n";
}
$s->close();
?>
--EXPECT--
Serialization of 'SNMP' is not allowed
26 changes: 26 additions & 0 deletions ext/tidy/tests/gh21682.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
--TEST--
GH-21682 (tidy and tidyNode should not be serializable)
--EXTENSIONS--
tidy
--FILE--
<?php
$t = new tidy();
try {
serialize($t);
echo "ERROR: should have thrown\n";
} catch (\Exception $e) {
echo $e->getMessage() . "\n";
}

$t->parseString("<html><body>test</body></html>");
$node = $t->body();
try {
serialize($node);
echo "ERROR: should have thrown\n";
} catch (\Exception $e) {
echo $e->getMessage() . "\n";
}
?>
--EXPECT--
Serialization of 'tidy' is not allowed
Serialization of 'tidyNode' is not allowed
2 changes: 2 additions & 0 deletions ext/tidy/tidy.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -861,6 +861,7 @@ function tidy_get_head(tidy $tidy): ?tidyNode {}

function tidy_get_body(tidy $tidy): ?tidyNode {}

/** @not-serializable */
class tidy
{
public ?string $errorBuffer = null;
Expand Down Expand Up @@ -973,6 +974,7 @@ public function html(): ?tidyNode {}
public function body(): ?tidyNode {}
}

/** @not-serializable */
final class tidyNode
{
public readonly string $value;
Expand Down
6 changes: 3 additions & 3 deletions ext/tidy/tidy_arginfo.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions ext/xmlreader/php_xmlreader.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

/** @generate-class-entries */

/** @not-serializable */
class XMLReader
{
/* Constants for NodeType - cannot define common types to share with dom as there are differences in these types */
Expand Down
4 changes: 2 additions & 2 deletions ext/xmlreader/php_xmlreader_arginfo.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions ext/xmlreader/tests/gh21682.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
--TEST--
GH-21682 (XMLReader should not be serializable)
--EXTENSIONS--
xmlreader
--FILE--
<?php
$r = new XMLReader();
try {
serialize($r);
echo "ERROR: should have thrown\n";
} catch (\Exception $e) {
echo $e->getMessage() . "\n";
}
?>
--EXPECT--
Serialization of 'XMLReader' is not allowed
1 change: 1 addition & 0 deletions ext/xmlwriter/php_xmlwriter.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ function xmlwriter_output_memory(XMLWriter $writer, bool $flush = true): string

function xmlwriter_flush(XMLWriter $writer, bool $empty = true): string|int {}

/** @not-serializable */
class XMLWriter
{
/**
Expand Down
4 changes: 2 additions & 2 deletions ext/xmlwriter/php_xmlwriter_arginfo.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions ext/xmlwriter/tests/gh21682.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
--TEST--
GH-21682 (XMLWriter should not be serializable)
--EXTENSIONS--
xmlwriter
--FILE--
<?php
$w = new XMLWriter();
try {
serialize($w);
echo "ERROR: should have thrown\n";
} catch (\Exception $e) {
echo $e->getMessage() . "\n";
}
?>
--EXPECT--
Serialization of 'XMLWriter' is not allowed
Loading