Skip to content

Commit fd1959c

Browse files
committed
unserialize: Deprecate the 'S' tag
Support for this was added in 8f5310a for forward-compatibility with PHP 6. There should not be any data that is legitimately using this format and removing it simplifies the unserializer as a security-sensitive piece of code.
1 parent 58c281a commit fd1959c

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
--TEST--
2+
Test unserialize() with the 'S' format emits a deprecation.
3+
--FILE--
4+
<?php
5+
6+
var_dump(unserialize('S:1:"e";'));
7+
var_dump(unserialize('S:1:"\65";'));
8+
9+
?>
10+
--EXPECTF--
11+
Deprecated: unserialize(): Unserializing the 'S' format is deprecated in %s on line %d
12+
string(1) "e"
13+
14+
Deprecated: unserialize(): Unserializing the 'S' format is deprecated in %s on line %d
15+
string(1) "e"

ext/standard/var_unserializer.re

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,6 +1085,9 @@ use_double:
10851085
*p = YYCURSOR;
10861086
10871087
ZVAL_STR(rval, str);
1088+
1089+
php_error_docref(NULL, E_DEPRECATED, "Unserializing the 'S' format is deprecated");
1090+
10881091
return 1;
10891092
}
10901093

0 commit comments

Comments
 (0)