Skip to content

Commit 97f8c78

Browse files
committed
Merge branch 'PHP-5.5' of https://git.php.net/repository/php-src into PHP-5.5
2 parents 66d3095 + 2137250 commit 97f8c78

File tree

5 files changed

+39
-23
lines changed

5 files changed

+39
-23
lines changed

ext/date/php_date.c

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2779,12 +2779,9 @@ static int php_date_initialize_from_hash(php_date_obj **dateobj, HashTable *myht
27792779
timelib_tzinfo *tzi;
27802780
php_timezone_obj *tzobj;
27812781

2782-
if (zend_hash_find(myht, "date", 5, (void**) &z_date) == SUCCESS) {
2783-
convert_to_string(*z_date);
2784-
if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS) {
2785-
convert_to_long(*z_timezone_type);
2786-
if (zend_hash_find(myht, "timezone", 9, (void**) &z_timezone) == SUCCESS) {
2787-
convert_to_string(*z_timezone);
2782+
if (zend_hash_find(myht, "date", 5, (void**) &z_date) == SUCCESS && Z_TYPE_PP(z_date) == IS_STRING) {
2783+
if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS && Z_TYPE_PP(z_timezone_type) == IS_LONG) {
2784+
if (zend_hash_find(myht, "timezone", 9, (void**) &z_timezone) == SUCCESS && Z_TYPE_PP(z_timezone) == IS_STRING) {
27882785

27892786
switch (Z_LVAL_PP(z_timezone_type)) {
27902787
case TIMELIB_ZONETYPE_OFFSET:
@@ -2799,7 +2796,6 @@ static int php_date_initialize_from_hash(php_date_obj **dateobj, HashTable *myht
27992796

28002797
case TIMELIB_ZONETYPE_ID: {
28012798
int ret;
2802-
convert_to_string(*z_timezone);
28032799

28042800
tzi = php_date_parse_tzfile(Z_STRVAL_PP(z_timezone), DATE_TIMEZONEDB TSRMLS_CC);
28052801

@@ -3716,9 +3712,8 @@ static int php_date_timezone_initialize_from_hash(zval **return_value, php_timez
37163712
zval **z_timezone = NULL;
37173713
zval **z_timezone_type = NULL;
37183714

3719-
if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS) {
3715+
if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS && Z_TYPE_PP(z_timezone_type) == IS_LONG) {
37203716
if (zend_hash_find(myht, "timezone", 9, (void**) &z_timezone) == SUCCESS) {
3721-
convert_to_long(*z_timezone_type);
37223717
if (SUCCESS == timezone_initialize(*tzobj, Z_STRVAL_PP(z_timezone) TSRMLS_CC)) {
37233718
return SUCCESS;
37243719
}
@@ -3743,7 +3738,9 @@ PHP_METHOD(DateTimeZone, __set_state)
37433738

37443739
php_date_instantiate(date_ce_timezone, return_value TSRMLS_CC);
37453740
tzobj = (php_timezone_obj *) zend_object_store_get_object(return_value TSRMLS_CC);
3746-
php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC);
3741+
if(php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC) != SUCCESS) {
3742+
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Timezone initialization failed");
3743+
}
37473744
}
37483745
/* }}} */
37493746

@@ -3759,7 +3756,9 @@ PHP_METHOD(DateTimeZone, __wakeup)
37593756

37603757
myht = Z_OBJPROP_P(object);
37613758

3762-
php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC);
3759+
if(php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC) != SUCCESS) {
3760+
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Timezone initialization failed");
3761+
}
37633762
}
37643763
/* }}} */
37653764

ext/date/tests/bug68942.phpt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
--TEST--
2+
Bug #68942 (Use after free vulnerability in unserialize() with DateTimeZone).
3+
--FILE--
4+
<?php
5+
$data = unserialize('a:2:{i:0;O:12:"DateTimeZone":2:{s:13:"timezone_type";a:2:{i:0;i:1;i:1;i:2;}s:8:"timezone";s:1:"A";}i:1;R:4;}');
6+
var_dump($data);
7+
?>
8+
--EXPECTF--
9+
Fatal error: DateTimeZone::__wakeup(): Timezone initialization failed in %s/bug68942.php on line %d

ext/date/tests/bug68942_2.phpt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
--TEST--
2+
Bug #68942 (Use after free vulnerability in unserialize() with DateTime).
3+
--FILE--
4+
<?php
5+
$data = unserialize('a:2:{i:0;O:8:"DateTime":3:{s:4:"date";s:26:"2000-01-01 00:00:00.000000";s:13:"timezone_type";a:2:{i:0;i:1;i:1;i:2;}s:8:"timezone";s:1:"A";}i:1;R:5;}');
6+
var_dump($data);
7+
?>
8+
--EXPECTF--
9+
Fatal error: Invalid serialization data for DateTime object in %s/bug68942_2.php on line %d

ext/enchant/enchant.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -550,13 +550,12 @@ PHP_FUNCTION(enchant_broker_request_dict)
550550

551551
d = enchant_broker_request_dict(pbroker->pbroker, (const char *)tag);
552552
if (d) {
553+
pos = pbroker->dictcnt++;
553554
if (pbroker->dictcnt) {
554555
pbroker->dict = (enchant_dict **)erealloc(pbroker->dict, sizeof(enchant_dict *) * pbroker->dictcnt);
555-
pos = pbroker->dictcnt++;
556556
} else {
557557
pbroker->dict = (enchant_dict **)emalloc(sizeof(enchant_dict *));
558558
pos = 0;
559-
pbroker->dictcnt++;
560559
}
561560

562561
dict = pbroker->dict[pos] = (enchant_dict *)emalloc(sizeof(enchant_dict));
@@ -607,14 +606,14 @@ PHP_FUNCTION(enchant_broker_request_pwl_dict)
607606

608607
d = enchant_broker_request_pwl_dict(pbroker->pbroker, (const char *)pwl);
609608
if (d) {
609+
pos = pbroker->dictcnt++;
610610
if (pbroker->dictcnt) {
611-
pos = pbroker->dictcnt++;
612611
pbroker->dict = (enchant_dict **)erealloc(pbroker->dict, sizeof(enchant_dict *) * pbroker->dictcnt);
613612
} else {
614613
pbroker->dict = (enchant_dict **)emalloc(sizeof(enchant_dict *));
615614
pos = 0;
616-
pbroker->dictcnt++;
617615
}
616+
618617
dict = pbroker->dict[pos] = (enchant_dict *)emalloc(sizeof(enchant_dict));
619618
dict->id = pos;
620619
dict->pbroker = pbroker;

ext/standard/config.m4

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ main() {
170170
ac_cv_crypt_blowfish=no
171171
])])
172172

173-
AC_CACHE_CHECK(for SHA512 crypt, ac_cv_crypt_SHA512,[
173+
AC_CACHE_CHECK(for SHA512 crypt, ac_cv_crypt_sha512,[
174174
AC_TRY_RUN([
175175
#if HAVE_UNISTD_H
176176
#include <unistd.h>
@@ -192,14 +192,14 @@ main() {
192192
exit(0);
193193
#endif
194194
}],[
195-
ac_cv_crypt_SHA512=yes
195+
ac_cv_crypt_sha512=yes
196196
],[
197-
ac_cv_crypt_SHA512=no
197+
ac_cv_crypt_sha512=no
198198
],[
199-
ac_cv_crypt_SHA512=no
199+
ac_cv_crypt_sha512=no
200200
])])
201201

202-
AC_CACHE_CHECK(for SHA256 crypt, ac_cv_crypt_SHA256,[
202+
AC_CACHE_CHECK(for SHA256 crypt, ac_cv_crypt_sha256,[
203203
AC_TRY_RUN([
204204
#if HAVE_UNISTD_H
205205
#include <unistd.h>
@@ -222,11 +222,11 @@ main() {
222222
exit(0);
223223
#endif
224224
}],[
225-
ac_cv_crypt_SHA256=yes
225+
ac_cv_crypt_sha256=yes
226226
],[
227-
ac_cv_crypt_SHA256=no
227+
ac_cv_crypt_sha256=no
228228
],[
229-
ac_cv_crypt_SHA256=no
229+
ac_cv_crypt_sha256=no
230230
])])
231231

232232

0 commit comments

Comments
 (0)