Compare commits

...
12 Commits
Author SHA1 Message Date
Stanislav Malyshev c37265eacd Merge branch 'PHP-5.5' into PHP-5.6
* PHP-5.5:
  update news
  add CVE
  add missing test file
  Fix bug #68594 - Use after free vulnerability in unserialize()

Conflicts:
	ext/standard/var_unserializer.c
2014-12-17 02:25:00 +01:00
Ferenc Kovacs fe1ab0e566 fix NEWS 2014-12-17 02:19:35 +01:00
Ferenc Kovacs 4f8fd1fdf6 update the date of the release 2014-12-16 18:26:48 +01:00
Anatol Belski e3b5de600d move the test to the right place 2014-12-10 14:14:22 +01:00
Julien Pauli eaaa352975 5.6.4 2014-12-10 14:12:55 +01:00
Anatol Belski 239bfe29a1 Fixed bug #68545 NULL pointer dereference in unserialize.c
Conflicts:
	ext/standard/var_unserializer.c
2014-12-10 13:58:20 +01:00
Dmitry Stogov ea2fc5a123 Fixed possible read after end of buffer and use after free. 2014-12-10 13:33:13 +01:00
Derick Rethans 3020b613ef Fixed day_of_week function as it could sometimes return negative values internally. 2014-12-10 13:32:58 +01:00
Ferenc Kovacs 5b098036e8 Merge branch 'PHP-5.6' into PHP-5.6.4
* PHP-5.6:
  the darwin specific test fails for me with the same output which is the expected for the original test I couldn't find anybody who managed to see this test passing, but I found a bunch of other reports on qa.php.net/reports and on google which do see this test failing on mac. if this change causes you to have this test failing on Mac, please drop me a mail so we can improve the current test so it passes for everybody.
  5.5.21 now
2014-11-27 00:15:16 +01:00
Ferenc Kovacs 25b119ef62 update NEWS 2014-11-26 23:20:45 +01:00
Ferenc Kovacs bddacad8a9 Merge branch 'PHP-5.6' into PHP-5.6.4
* PHP-5.6:
  #68446 is fixed
2014-11-26 23:19:41 +01:00
Ferenc Kovacs 74796926a2 5.6.4RC1 2014-11-26 19:24:07 +01:00
14 changed files with 137 additions and 59 deletions

No files matched your search

+11 -3
View File
@@ -1,8 +1,6 @@
PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ??? 2015, PHP 5.6.5
11 Dec 2014, PHP 5.6.4
18 Dec 2014, PHP 5.6.4
- Core:
. Fixed bug #68091 (Some Zend headers lack appropriate extern "C" blocks).
@@ -16,8 +14,15 @@ PHP NEWS
. Fixed bug #68370 ("unset($this)" can make the program crash). (Laruence)
. Fixed bug #68422 (Incorrect argument reflection info for array_multisort()).
(Alexander Lisachenko)
. Fixed bug #68545 (NULL pointer dereference in unserialize.c). (Anatol)
. Fixed bug #68446 (Array constant not accepted for array parameter default).
(Bob, Dmitry)
. Fixed bug #68594 (Use after free vulnerability in unserialize()).
(CVE-2014-8142) (Stefan Esser)
- Date:
. Fixed day_of_week function as it could sometimes return negative values
internally. (Derick)
- FPM:
. Fixed bug #68381 (fpm_unix_init_main ignores log_level).
@@ -36,6 +41,9 @@ PHP NEWS
(Florian Margaine, Remi)
. Fixed bug #68478 (access.log don't use prefix). (Remi)
- Mcrypt:
. Fixed possible read after end of buffer and use after free. (Dmitry)
- GMP:
. Fixed bug #68419 (build error with gmp 4.1). (Remi)
+2 -2
View File
@@ -119,8 +119,8 @@ int zend_sprintf(char *buffer, const char *format, ...);
PHP_MAJOR_VERSION=5
PHP_MINOR_VERSION=6
PHP_RELEASE_VERSION=5
PHP_EXTRA_VERSION="-dev"
PHP_RELEASE_VERSION=4
PHP_EXTRA_VERSION=""
PHP_VERSION="$PHP_MAJOR_VERSION.$PHP_MINOR_VERSION.$PHP_RELEASE_VERSION$PHP_EXTRA_VERSION"
PHP_VERSION_ID=`expr [$]PHP_MAJOR_VERSION \* 10000 + [$]PHP_MINOR_VERSION \* 100 + [$]PHP_RELEASE_VERSION`
+15 -3
View File
@@ -23,9 +23,21 @@
static int m_table_common[13] = { -1, 0, 3, 3, 6, 1, 4, 6, 2, 5, 0, 3, 5 }; /* 1 = jan */
static int m_table_leap[13] = { -1, 6, 2, 3, 6, 1, 4, 6, 2, 5, 0, 3, 5 }; /* 1 = jan */
static timelib_sll positive_mod(timelib_sll x, timelib_sll y)
{
timelib_sll tmp;
tmp = x % y;
if (tmp < 0) {
tmp += y;
}
return tmp;
}
static timelib_sll century_value(timelib_sll j)
{
return 6 - (j % 4) * 2;
return 6 - positive_mod(j, 4) * 2;
}
static timelib_sll timelib_day_of_week_ex(timelib_sll y, timelib_sll m, timelib_sll d, int iso)
@@ -36,9 +48,9 @@ static timelib_sll timelib_day_of_week_ex(timelib_sll y, timelib_sll m, timelib_
* Julian calendar. We just return the 'wrong' day of week to be
* consistent. */
c1 = century_value(y / 100);
y1 = (y % 100);
y1 = positive_mod(y, 100);
m1 = timelib_is_leap(y) ? m_table_leap[m] : m_table_common[m];
dow = (c1 + y1 + m1 + (y1 / 4) + d) % 7;
dow = positive_mod((c1 + y1 + m1 + (y1 / 4) + d), 7);
if (iso) {
if (dow == 0) {
dow = 7;
@@ -145,7 +145,7 @@ object(DateTime)#%d (3) {
-- int -12345 --
object(DateTime)#%d (3) {
["date"]=>
string(28) "-12345-02-15 08:34:10.000000"
string(28) "-12345-02-11 08:34:10.000000"
["timezone_type"]=>
int(3)
["timezone"]=>
@@ -165,7 +165,7 @@ object(DateTime)#%d (3) {
-- float -10.5 --
object(DateTime)#%d (3) {
["date"]=>
string(27) "-0010-02-19 08:34:10.000000"
string(27) "-0010-02-14 08:34:10.000000"
["timezone_type"]=>
int(3)
["timezone"]=>
+3 -2
View File
@@ -10,7 +10,8 @@ var_dump($date->format('r'));
$date->setDate(-2147483648, 1, 1);
var_dump($date->format('r'));
var_dump($date->format('c'));
?>
--EXPECT--
string(32) "Sat, 01 Jan -1500 00:00:00 +0000"
string(42) "Unknown, 01 Jan -2147483648 00:00:00 +0000"
string(32) "Fri, 01 Jan -1500 00:00:00 +0000"
string(38) "Mon, 01 Jan -2147483648 00:00:00 +0000"
string(32) "-2147483648-01-01T00:00:00+00:00"
@@ -145,7 +145,7 @@ object(DateTime)#%d (3) {
-- int -12345 --
object(DateTime)#%d (3) {
["date"]=>
string(28) "-12345-02-15 08:34:10.000000"
string(28) "-12345-02-11 08:34:10.000000"
["timezone_type"]=>
int(3)
["timezone"]=>
@@ -165,7 +165,7 @@ object(DateTime)#%d (3) {
-- float -10.5 --
object(DateTime)#%d (3) {
["date"]=>
string(27) "-0010-02-19 08:34:10.000000"
string(27) "-0010-02-14 08:34:10.000000"
["timezone_type"]=>
int(3)
["timezone"]=>
+2 -2
View File
@@ -61,7 +61,7 @@ array\(11\) {
\["mday"\]=>
int\((9|14|23)\)
\["wday"\]=>
int\((6|-4)\)
int\(0\)
\["mon"\]=>
int\((10|12)\)
\["year"\]=>
@@ -69,7 +69,7 @@ array\(11\) {
\["yday"\]=>
int\((282|347|295)\)
\["weekday"\]=>
string\((8|7)\) "(Saturday|Unknown)"
string\(6\) "Sunday"
\["month"\]=>
string\((7|8)\) "(October|December)"
\[0\]=>
+2 -2
View File
@@ -87,7 +87,7 @@ array\(9\) {
\[5\]=>
int\((104|1|-3843)\)
\[6\]=>
int\((5|-5)\)
int\(6\)
\[7\]=>
int\((281|346|294)\)
\[8\]=>
@@ -107,7 +107,7 @@ array\(9\) {
\["tm_year"\]=>
int\((104|1|-3843)\)
\["tm_wday"\]=>
int\((5|-5)\)
int\(6\)
\["tm_yday"\]=>
int\((281|346|294)\)
\["tm_isdst"\]=>
+6 -2
View File
@@ -578,8 +578,11 @@ PHP_FUNCTION(mcrypt_generic_init)
if (iv_len != iv_size) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Iv size incorrect; supplied length: %d, needed: %d", iv_len, iv_size);
if (iv_len > iv_size) {
iv_len = iv_size;
}
}
memcpy(iv_s, iv, iv_size);
memcpy(iv_s, iv, iv_len);
mcrypt_generic_deinit(pm->td);
result = mcrypt_generic_init(pm->td, key_s, key_size, iv_s);
@@ -600,8 +603,9 @@ PHP_FUNCTION(mcrypt_generic_init)
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown error");
break;
}
} else {
pm->init = 1;
}
pm->init = 1;
RETVAL_LONG(result);
efree(iv_s);
@@ -0,0 +1,11 @@
--TEST--
Bug #68545 NULL pointer dereference in unserialize.c:var_push_dtor
--FILE--
<?php
var_dump(unserialize('a:6:{a:6:{s:3:"322";s:3:"bar";s:3:"bar";s:3:"foo";a:6:{a:6:{s:3:"322";s:3:"bar";s:3:"bar";s:3:"foo";s:3:"bar";a:6:{a:6:{s:3:"322";s:3:"bar";s:3:"bar";s:3:"foo";a:6:{a:6:{s:3:"322";s:3:"bar";s:3:"b22";s:3:"bar";s:3:"bar";s:3:"foo";s:3:"bar";a:6:{a:6:{s:3:"322";s:3:"bar";s:3:"bar";s:3:"foo";s:3:"bar";s:3:"bar";'));
?>
===DONE===
--EXPECTF--
Notice: unserialize(): Error at offset %d of %d bytes in %sbug68545.php on line %d
bool(false)
===DONE===
@@ -0,0 +1,23 @@
--TEST--
Bug #68545 Use after free vulnerability in unserialize()
--FILE--
<?php
for ($i=4; $i<100; $i++) {
$m = new StdClass();
$u = array(1);
$m->aaa = array(1,2,&$u,4,5);
$m->bbb = 1;
$m->ccc = &$u;
$m->ddd = str_repeat("A", $i);
$z = serialize($m);
$z = str_replace("bbb", "aaa", $z);
$y = unserialize($z);
$z = serialize($y);
}
?>
===DONE===
--EXPECTF--
===DONE===
+44 -34
View File
@@ -1,4 +1,4 @@
/* Generated by re2c 0.13.5 */
/* Generated by re2c 0.13.7.5 */
#line 1 "ext/standard/var_unserializer.re"
/*
+----------------------------------------------------------------------+
@@ -60,7 +60,13 @@ static inline void var_push(php_unserialize_data_t *var_hashx, zval **rval)
PHPAPI void var_push_dtor(php_unserialize_data_t *var_hashx, zval **rval)
{
var_entries *var_hash = (*var_hashx)->last_dtor;
var_entries *var_hash;
if (!var_hashx || !*var_hashx) {
return;
}
var_hash = (*var_hashx)->last_dtor;
#if VAR_ENTRIES_DBG
fprintf(stderr, "var_push_dtor(%ld): %d\n", var_hash?var_hash->used_slots:-1L, Z_TYPE_PP(rval));
#endif
@@ -226,7 +232,7 @@ static char *unserialize_str(const unsigned char **p, size_t *len, size_t maxlen
#define YYMARKER marker
#line 234 "ext/standard/var_unserializer.re"
#line 240 "ext/standard/var_unserializer.re"
@@ -336,6 +342,9 @@ static inline int process_nested_data(UNSERIALIZE_PARAMETER, HashTable *ht, long
} else {
/* object properties should include no integers */
convert_to_string(key);
if (zend_symtable_find(ht, Z_STRVAL_P(key), Z_STRLEN_P(key) + 1, (void **)&old_data)==SUCCESS) {
var_push_dtor(var_hash, old_data);
}
zend_hash_update(ht, Z_STRVAL_P(key), Z_STRLEN_P(key) + 1, &data,
sizeof data, NULL);
}
@@ -469,7 +478,7 @@ PHPAPI int php_var_unserialize(UNSERIALIZE_PARAMETER)
#line 473 "ext/standard/var_unserializer.c"
#line 482 "ext/standard/var_unserializer.c"
{
YYCTYPE yych;
static const unsigned char yybm[] = {
@@ -529,9 +538,9 @@ yy2:
yych = *(YYMARKER = ++YYCURSOR);
if (yych == ':') goto yy95;
yy3:
#line 824 "ext/standard/var_unserializer.re"
#line 833 "ext/standard/var_unserializer.re"
{ return 0; }
#line 535 "ext/standard/var_unserializer.c"
#line 544 "ext/standard/var_unserializer.c"
yy4:
yych = *(YYMARKER = ++YYCURSOR);
if (yych == ':') goto yy89;
@@ -574,13 +583,13 @@ yy13:
goto yy3;
yy14:
++YYCURSOR;
#line 818 "ext/standard/var_unserializer.re"
#line 827 "ext/standard/var_unserializer.re"
{
/* this is the case where we have less data than planned */
php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Unexpected end of serialized data");
return 0; /* not sure if it should be 0 or 1 here? */
}
#line 584 "ext/standard/var_unserializer.c"
#line 593 "ext/standard/var_unserializer.c"
yy16:
yych = *++YYCURSOR;
goto yy3;
@@ -606,11 +615,12 @@ yy20:
if (yybm[0+yych] & 128) {
goto yy20;
}
if (yych != ':') goto yy18;
if (yych <= '/') goto yy18;
if (yych >= ';') goto yy18;
yych = *++YYCURSOR;
if (yych != '"') goto yy18;
++YYCURSOR;
#line 672 "ext/standard/var_unserializer.re"
#line 681 "ext/standard/var_unserializer.re"
{
size_t len, len2, len3, maxlen;
long elements;
@@ -756,7 +766,7 @@ yy20:
return object_common2(UNSERIALIZE_PASSTHRU, elements);
}
#line 760 "ext/standard/var_unserializer.c"
#line 770 "ext/standard/var_unserializer.c"
yy25:
yych = *++YYCURSOR;
if (yych <= ',') {
@@ -781,7 +791,7 @@ yy27:
yych = *++YYCURSOR;
if (yych != '"') goto yy18;
++YYCURSOR;
#line 664 "ext/standard/var_unserializer.re"
#line 673 "ext/standard/var_unserializer.re"
{
INIT_PZVAL(*rval);
@@ -789,7 +799,7 @@ yy27:
return object_common2(UNSERIALIZE_PASSTHRU,
object_common1(UNSERIALIZE_PASSTHRU, ZEND_STANDARD_CLASS_DEF_PTR));
}
#line 793 "ext/standard/var_unserializer.c"
#line 803 "ext/standard/var_unserializer.c"
yy32:
yych = *++YYCURSOR;
if (yych == '+') goto yy33;
@@ -810,7 +820,7 @@ yy34:
yych = *++YYCURSOR;
if (yych != '{') goto yy18;
++YYCURSOR;
#line 644 "ext/standard/var_unserializer.re"
#line 653 "ext/standard/var_unserializer.re"
{
long elements = parse_iv(start + 2);
/* use iv() not uiv() in order to check data range */
@@ -830,7 +840,7 @@ yy34:
return finish_nested_data(UNSERIALIZE_PASSTHRU);
}
#line 834 "ext/standard/var_unserializer.c"
#line 844 "ext/standard/var_unserializer.c"
yy39:
yych = *++YYCURSOR;
if (yych == '+') goto yy40;
@@ -851,7 +861,7 @@ yy41:
yych = *++YYCURSOR;
if (yych != '"') goto yy18;
++YYCURSOR;
#line 615 "ext/standard/var_unserializer.re"
#line 624 "ext/standard/var_unserializer.re"
{
size_t len, maxlen;
char *str;
@@ -880,7 +890,7 @@ yy41:
ZVAL_STRINGL(*rval, str, len, 0);
return 1;
}
#line 884 "ext/standard/var_unserializer.c"
#line 894 "ext/standard/var_unserializer.c"
yy46:
yych = *++YYCURSOR;
if (yych == '+') goto yy47;
@@ -901,7 +911,7 @@ yy48:
yych = *++YYCURSOR;
if (yych != '"') goto yy18;
++YYCURSOR;
#line 587 "ext/standard/var_unserializer.re"
#line 596 "ext/standard/var_unserializer.re"
{
size_t len, maxlen;
char *str;
@@ -929,7 +939,7 @@ yy48:
ZVAL_STRINGL(*rval, str, len, 1);
return 1;
}
#line 933 "ext/standard/var_unserializer.c"
#line 943 "ext/standard/var_unserializer.c"
yy53:
yych = *++YYCURSOR;
if (yych <= '/') {
@@ -1017,7 +1027,7 @@ yy61:
}
yy63:
++YYCURSOR;
#line 577 "ext/standard/var_unserializer.re"
#line 586 "ext/standard/var_unserializer.re"
{
#if SIZEOF_LONG == 4
use_double:
@@ -1027,7 +1037,7 @@ use_double:
ZVAL_DOUBLE(*rval, zend_strtod((const char *)start + 2, NULL));
return 1;
}
#line 1031 "ext/standard/var_unserializer.c"
#line 1041 "ext/standard/var_unserializer.c"
yy65:
yych = *++YYCURSOR;
if (yych <= ',') {
@@ -1086,7 +1096,7 @@ yy73:
yych = *++YYCURSOR;
if (yych != ';') goto yy18;
++YYCURSOR;
#line 562 "ext/standard/var_unserializer.re"
#line 571 "ext/standard/var_unserializer.re"
{
*p = YYCURSOR;
INIT_PZVAL(*rval);
@@ -1101,7 +1111,7 @@ yy73:
return 1;
}
#line 1105 "ext/standard/var_unserializer.c"
#line 1115 "ext/standard/var_unserializer.c"
yy76:
yych = *++YYCURSOR;
if (yych == 'N') goto yy73;
@@ -1128,7 +1138,7 @@ yy79:
if (yych <= '9') goto yy79;
if (yych != ';') goto yy18;
++YYCURSOR;
#line 535 "ext/standard/var_unserializer.re"
#line 544 "ext/standard/var_unserializer.re"
{
#if SIZEOF_LONG == 4
int digits = YYCURSOR - start - 3;
@@ -1155,7 +1165,7 @@ yy79:
ZVAL_LONG(*rval, parse_iv(start + 2));
return 1;
}
#line 1159 "ext/standard/var_unserializer.c"
#line 1169 "ext/standard/var_unserializer.c"
yy83:
yych = *++YYCURSOR;
if (yych <= '/') goto yy18;
@@ -1163,24 +1173,24 @@ yy83:
yych = *++YYCURSOR;
if (yych != ';') goto yy18;
++YYCURSOR;
#line 528 "ext/standard/var_unserializer.re"
#line 537 "ext/standard/var_unserializer.re"
{
*p = YYCURSOR;
INIT_PZVAL(*rval);
ZVAL_BOOL(*rval, parse_iv(start + 2));
return 1;
}
#line 1174 "ext/standard/var_unserializer.c"
#line 1184 "ext/standard/var_unserializer.c"
yy87:
++YYCURSOR;
#line 521 "ext/standard/var_unserializer.re"
#line 530 "ext/standard/var_unserializer.re"
{
*p = YYCURSOR;
INIT_PZVAL(*rval);
ZVAL_NULL(*rval);
return 1;
}
#line 1184 "ext/standard/var_unserializer.c"
#line 1194 "ext/standard/var_unserializer.c"
yy89:
yych = *++YYCURSOR;
if (yych <= ',') {
@@ -1203,7 +1213,7 @@ yy91:
if (yych <= '9') goto yy91;
if (yych != ';') goto yy18;
++YYCURSOR;
#line 498 "ext/standard/var_unserializer.re"
#line 507 "ext/standard/var_unserializer.re"
{
long id;
@@ -1226,7 +1236,7 @@ yy91:
return 1;
}
#line 1230 "ext/standard/var_unserializer.c"
#line 1240 "ext/standard/var_unserializer.c"
yy95:
yych = *++YYCURSOR;
if (yych <= ',') {
@@ -1249,7 +1259,7 @@ yy97:
if (yych <= '9') goto yy97;
if (yych != ';') goto yy18;
++YYCURSOR;
#line 477 "ext/standard/var_unserializer.re"
#line 486 "ext/standard/var_unserializer.re"
{
long id;
@@ -1270,9 +1280,9 @@ yy97:
return 1;
}
#line 1274 "ext/standard/var_unserializer.c"
#line 1284 "ext/standard/var_unserializer.c"
}
#line 826 "ext/standard/var_unserializer.re"
#line 835 "ext/standard/var_unserializer.re"
return 0;
+10 -1
View File
@@ -58,7 +58,13 @@ static inline void var_push(php_unserialize_data_t *var_hashx, zval **rval)
PHPAPI void var_push_dtor(php_unserialize_data_t *var_hashx, zval **rval)
{
var_entries *var_hash = (*var_hashx)->last_dtor;
var_entries *var_hash;
if (!var_hashx || !*var_hashx) {
return;
}
var_hash = (*var_hashx)->last_dtor;
#if VAR_ENTRIES_DBG
fprintf(stderr, "var_push_dtor(%ld): %d\n", var_hash?var_hash->used_slots:-1L, Z_TYPE_PP(rval));
#endif
@@ -340,6 +346,9 @@ static inline int process_nested_data(UNSERIALIZE_PARAMETER, HashTable *ht, long
} else {
/* object properties should include no integers */
convert_to_string(key);
if (zend_symtable_find(ht, Z_STRVAL_P(key), Z_STRLEN_P(key) + 1, (void **)&old_data)==SUCCESS) {
var_push_dtor(var_hash, old_data);
}
zend_hash_update(ht, Z_STRVAL_P(key), Z_STRLEN_P(key) + 1, &data,
sizeof data, NULL);
}
+4 -4
View File
@@ -2,7 +2,7 @@
/* edit configure.in to change version number */
#define PHP_MAJOR_VERSION 5
#define PHP_MINOR_VERSION 6
#define PHP_RELEASE_VERSION 5
#define PHP_EXTRA_VERSION "-dev"
#define PHP_VERSION "5.6.5-dev"
#define PHP_VERSION_ID 50605
#define PHP_RELEASE_VERSION 4
#define PHP_EXTRA_VERSION ""
#define PHP_VERSION "5.6.4"
#define PHP_VERSION_ID 50604