Skip to content

Commit

Permalink
Fixed Bug #65564 stack-buffer-overflow in DateTimeZone stuff caught b…
Browse files Browse the repository at this point in the history
…y AddressSanitizer
  • Loading branch information
remicollet committed Aug 30, 2013
1 parent 7da6498 commit d69513a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ PHP NEWS
- Datetime:
. Fixed bug #65554 (createFromFormat broken when weekday name is followed
by some delimiters). (Valentin Logvinskiy, Stas).
. Fixed bug #65564 (stack-buffer-overflow in DateTimeZone stuff caught
by AddressSanitizer). (Remi).

- Openssl:
. Fixed bug #64802 (openssl_x509_parse fails to parse subject properly in
Expand Down
10 changes: 5 additions & 5 deletions ext/date/php_date.c
Original file line number Diff line number Diff line change
Expand Up @@ -2113,13 +2113,13 @@ static HashTable *date_object_get_properties(zval *object TSRMLS_DC)
/* first we add the date and time in ISO format */
MAKE_STD_ZVAL(zv);
ZVAL_STRING(zv, date_format("Y-m-d H:i:s", 12, dateobj->time, 1), 0);
zend_hash_update(props, "date", 5, &zv, sizeof(zval), NULL);
zend_hash_update(props, "date", 5, &zv, sizeof(zv), NULL);

/* then we add the timezone name (or similar) */
if (dateobj->time->is_localtime) {
MAKE_STD_ZVAL(zv);
ZVAL_LONG(zv, dateobj->time->zone_type);
zend_hash_update(props, "timezone_type", 14, &zv, sizeof(zval), NULL);
zend_hash_update(props, "timezone_type", 14, &zv, sizeof(zv), NULL);

MAKE_STD_ZVAL(zv);
switch (dateobj->time->zone_type) {
Expand All @@ -2142,7 +2142,7 @@ static HashTable *date_object_get_properties(zval *object TSRMLS_DC)
ZVAL_STRING(zv, dateobj->time->tz_abbr, 1);
break;
}
zend_hash_update(props, "timezone", 9, &zv, sizeof(zval), NULL);
zend_hash_update(props, "timezone", 9, &zv, sizeof(zv), NULL);
}

return props;
Expand Down Expand Up @@ -2265,7 +2265,7 @@ static HashTable *date_object_get_properties_interval(zval *object TSRMLS_DC)
#define PHP_DATE_INTERVAL_ADD_PROPERTY(n,f) \
MAKE_STD_ZVAL(zv); \
ZVAL_LONG(zv, (long)intervalobj->diff->f); \
zend_hash_update(props, n, strlen(n) + 1, &zv, sizeof(zval), NULL);
zend_hash_update(props, n, strlen(n) + 1, &zv, sizeof(zv), NULL);

PHP_DATE_INTERVAL_ADD_PROPERTY("y", y);
PHP_DATE_INTERVAL_ADD_PROPERTY("m", m);
Expand All @@ -2282,7 +2282,7 @@ static HashTable *date_object_get_properties_interval(zval *object TSRMLS_DC)
} else {
MAKE_STD_ZVAL(zv);
ZVAL_FALSE(zv);
zend_hash_update(props, "days", 5, &zv, sizeof(zval), NULL);
zend_hash_update(props, "days", 5, &zv, sizeof(zv), NULL);
}
PHP_DATE_INTERVAL_ADD_PROPERTY("special_type", special.type);
PHP_DATE_INTERVAL_ADD_PROPERTY("special_amount", special.amount);
Expand Down

0 comments on commit d69513a

Please sign in to comment.