Compare commits

...
9 Commits
14 changed files with 134 additions and 54 deletions

No files matched your search

+11 -1
View File
@@ -1,6 +1,6 @@
PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ??? 2014, PHP 5.5.20
17 Dec 2014, PHP 5.5.20
- Core:
. Fixed bug #68091 (Some Zend headers lack appropriate extern "C" blocks).
@@ -8,6 +8,13 @@ PHP NEWS
. Fixed bug #68185 ("Inconsistent insteadof definition."- incorrectly
triggered). (Julien)
. Fixed bug #68370 ("unset($this)" can make the program crash). (Laruence)
. Fixed bug #68545 (NULL pointer dereference in unserialize.c). (Anatol)
. 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).
@@ -26,6 +33,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)
- PDO_pgsql:
. Fixed bug #66584 (Segmentation fault on statement deallocation) (Matteo)
. Fixed bug #67462 (PDO_PGSQL::beginTransaction() wrongly throws exception
+1 -1
View File
@@ -120,7 +120,7 @@ int zend_sprintf(char *buffer, const char *format, ...);
PHP_MAJOR_VERSION=5
PHP_MINOR_VERSION=5
PHP_RELEASE_VERSION=20
PHP_EXTRA_VERSION="-dev"
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
@@ -619,8 +619,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);
@@ -641,8 +644,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 on Thu Dec 11 19:26:19 2014 */
#line 1 "ext/standard/var_unserializer.re"
/*
+----------------------------------------------------------------------+
@@ -61,7 +61,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
@@ -227,7 +233,7 @@ static char *unserialize_str(const unsigned char **p, size_t *len, size_t maxlen
#define YYMARKER marker
#line 235 "ext/standard/var_unserializer.re"
#line 241 "ext/standard/var_unserializer.re"
@@ -337,6 +343,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);
}
@@ -474,7 +483,7 @@ PHPAPI int php_var_unserialize(UNSERIALIZE_PARAMETER)
#line 478 "ext/standard/var_unserializer.c"
#line 487 "ext/standard/var_unserializer.c"
{
YYCTYPE yych;
static const unsigned char yybm[] = {
@@ -534,9 +543,9 @@ yy2:
yych = *(YYMARKER = ++YYCURSOR);
if (yych == ':') goto yy95;
yy3:
#line 829 "ext/standard/var_unserializer.re"
#line 838 "ext/standard/var_unserializer.re"
{ return 0; }
#line 540 "ext/standard/var_unserializer.c"
#line 549 "ext/standard/var_unserializer.c"
yy4:
yych = *(YYMARKER = ++YYCURSOR);
if (yych == ':') goto yy89;
@@ -579,13 +588,13 @@ yy13:
goto yy3;
yy14:
++YYCURSOR;
#line 823 "ext/standard/var_unserializer.re"
#line 832 "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 589 "ext/standard/var_unserializer.c"
#line 598 "ext/standard/var_unserializer.c"
yy16:
yych = *++YYCURSOR;
goto yy3;
@@ -611,11 +620,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 677 "ext/standard/var_unserializer.re"
#line 686 "ext/standard/var_unserializer.re"
{
size_t len, len2, len3, maxlen;
long elements;
@@ -761,7 +771,7 @@ yy20:
return object_common2(UNSERIALIZE_PASSTHRU, elements);
}
#line 765 "ext/standard/var_unserializer.c"
#line 775 "ext/standard/var_unserializer.c"
yy25:
yych = *++YYCURSOR;
if (yych <= ',') {
@@ -786,7 +796,7 @@ yy27:
yych = *++YYCURSOR;
if (yych != '"') goto yy18;
++YYCURSOR;
#line 669 "ext/standard/var_unserializer.re"
#line 678 "ext/standard/var_unserializer.re"
{
INIT_PZVAL(*rval);
@@ -794,7 +804,7 @@ yy27:
return object_common2(UNSERIALIZE_PASSTHRU,
object_common1(UNSERIALIZE_PASSTHRU, ZEND_STANDARD_CLASS_DEF_PTR));
}
#line 798 "ext/standard/var_unserializer.c"
#line 808 "ext/standard/var_unserializer.c"
yy32:
yych = *++YYCURSOR;
if (yych == '+') goto yy33;
@@ -815,7 +825,7 @@ yy34:
yych = *++YYCURSOR;
if (yych != '{') goto yy18;
++YYCURSOR;
#line 649 "ext/standard/var_unserializer.re"
#line 658 "ext/standard/var_unserializer.re"
{
long elements = parse_iv(start + 2);
/* use iv() not uiv() in order to check data range */
@@ -835,7 +845,7 @@ yy34:
return finish_nested_data(UNSERIALIZE_PASSTHRU);
}
#line 839 "ext/standard/var_unserializer.c"
#line 849 "ext/standard/var_unserializer.c"
yy39:
yych = *++YYCURSOR;
if (yych == '+') goto yy40;
@@ -856,7 +866,7 @@ yy41:
yych = *++YYCURSOR;
if (yych != '"') goto yy18;
++YYCURSOR;
#line 620 "ext/standard/var_unserializer.re"
#line 629 "ext/standard/var_unserializer.re"
{
size_t len, maxlen;
char *str;
@@ -885,7 +895,7 @@ yy41:
ZVAL_STRINGL(*rval, str, len, 0);
return 1;
}
#line 889 "ext/standard/var_unserializer.c"
#line 899 "ext/standard/var_unserializer.c"
yy46:
yych = *++YYCURSOR;
if (yych == '+') goto yy47;
@@ -906,7 +916,7 @@ yy48:
yych = *++YYCURSOR;
if (yych != '"') goto yy18;
++YYCURSOR;
#line 592 "ext/standard/var_unserializer.re"
#line 601 "ext/standard/var_unserializer.re"
{
size_t len, maxlen;
char *str;
@@ -934,7 +944,7 @@ yy48:
ZVAL_STRINGL(*rval, str, len, 1);
return 1;
}
#line 938 "ext/standard/var_unserializer.c"
#line 948 "ext/standard/var_unserializer.c"
yy53:
yych = *++YYCURSOR;
if (yych <= '/') {
@@ -1022,7 +1032,7 @@ yy61:
}
yy63:
++YYCURSOR;
#line 582 "ext/standard/var_unserializer.re"
#line 591 "ext/standard/var_unserializer.re"
{
#if SIZEOF_LONG == 4
use_double:
@@ -1032,7 +1042,7 @@ use_double:
ZVAL_DOUBLE(*rval, zend_strtod((const char *)start + 2, NULL));
return 1;
}
#line 1036 "ext/standard/var_unserializer.c"
#line 1046 "ext/standard/var_unserializer.c"
yy65:
yych = *++YYCURSOR;
if (yych <= ',') {
@@ -1091,7 +1101,7 @@ yy73:
yych = *++YYCURSOR;
if (yych != ';') goto yy18;
++YYCURSOR;
#line 567 "ext/standard/var_unserializer.re"
#line 576 "ext/standard/var_unserializer.re"
{
*p = YYCURSOR;
INIT_PZVAL(*rval);
@@ -1106,7 +1116,7 @@ yy73:
return 1;
}
#line 1110 "ext/standard/var_unserializer.c"
#line 1120 "ext/standard/var_unserializer.c"
yy76:
yych = *++YYCURSOR;
if (yych == 'N') goto yy73;
@@ -1133,7 +1143,7 @@ yy79:
if (yych <= '9') goto yy79;
if (yych != ';') goto yy18;
++YYCURSOR;
#line 540 "ext/standard/var_unserializer.re"
#line 549 "ext/standard/var_unserializer.re"
{
#if SIZEOF_LONG == 4
int digits = YYCURSOR - start - 3;
@@ -1160,7 +1170,7 @@ yy79:
ZVAL_LONG(*rval, parse_iv(start + 2));
return 1;
}
#line 1164 "ext/standard/var_unserializer.c"
#line 1174 "ext/standard/var_unserializer.c"
yy83:
yych = *++YYCURSOR;
if (yych <= '/') goto yy18;
@@ -1168,24 +1178,24 @@ yy83:
yych = *++YYCURSOR;
if (yych != ';') goto yy18;
++YYCURSOR;
#line 533 "ext/standard/var_unserializer.re"
#line 542 "ext/standard/var_unserializer.re"
{
*p = YYCURSOR;
INIT_PZVAL(*rval);
ZVAL_BOOL(*rval, parse_iv(start + 2));
return 1;
}
#line 1179 "ext/standard/var_unserializer.c"
#line 1189 "ext/standard/var_unserializer.c"
yy87:
++YYCURSOR;
#line 526 "ext/standard/var_unserializer.re"
#line 535 "ext/standard/var_unserializer.re"
{
*p = YYCURSOR;
INIT_PZVAL(*rval);
ZVAL_NULL(*rval);
return 1;
}
#line 1189 "ext/standard/var_unserializer.c"
#line 1199 "ext/standard/var_unserializer.c"
yy89:
yych = *++YYCURSOR;
if (yych <= ',') {
@@ -1208,7 +1218,7 @@ yy91:
if (yych <= '9') goto yy91;
if (yych != ';') goto yy18;
++YYCURSOR;
#line 503 "ext/standard/var_unserializer.re"
#line 512 "ext/standard/var_unserializer.re"
{
long id;
@@ -1231,7 +1241,7 @@ yy91:
return 1;
}
#line 1235 "ext/standard/var_unserializer.c"
#line 1245 "ext/standard/var_unserializer.c"
yy95:
yych = *++YYCURSOR;
if (yych <= ',') {
@@ -1254,7 +1264,7 @@ yy97:
if (yych <= '9') goto yy97;
if (yych != ';') goto yy18;
++YYCURSOR;
#line 482 "ext/standard/var_unserializer.re"
#line 491 "ext/standard/var_unserializer.re"
{
long id;
@@ -1275,9 +1285,9 @@ yy97:
return 1;
}
#line 1279 "ext/standard/var_unserializer.c"
#line 1289 "ext/standard/var_unserializer.c"
}
#line 831 "ext/standard/var_unserializer.re"
#line 840 "ext/standard/var_unserializer.re"
return 0;
+10 -1
View File
@@ -59,7 +59,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
@@ -341,6 +347,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);
}
+2 -2
View File
@@ -3,6 +3,6 @@
#define PHP_MAJOR_VERSION 5
#define PHP_MINOR_VERSION 5
#define PHP_RELEASE_VERSION 20
#define PHP_EXTRA_VERSION "-dev"
#define PHP_VERSION "5.5.20-dev"
#define PHP_EXTRA_VERSION ""
#define PHP_VERSION "5.5.20"
#define PHP_VERSION_ID 50520