Skip to content

Commit 9acd6fe

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 9e66bc9 commit 9acd6fe

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
@@ -1090,6 +1090,9 @@ use_double:
10901090
*p = YYCURSOR;
10911091
10921092
ZVAL_STR(rval, str);
1093+
1094+
php_error_docref(NULL, E_DEPRECATED, "Unserializing the 'S' format is deprecated");
1095+
10931096
return 1;
10941097
}
10951098

0 commit comments

Comments
 (0)