1
0
mirror of https://github.com/php/php-src.git synced 2026-03-30 04:02:19 +02:00

Merge branch 'PHP-5.6' of git.php.net:php-src into PHP-5.6

This commit is contained in:
George Wang
2014-11-03 11:44:13 -05:00
134 changed files with 10688 additions and 3998 deletions

View File

@@ -42,5 +42,5 @@ before_script:
# Run PHPs run-tests.php
script:
- ./sapi/cli/php run-tests.php -p `pwd`/sapi/cli/php -g "FAIL,XFAIL,BORK,WARN,LEAK,SKIP" --show-diff --set-timeout 120
- ./sapi/cli/php run-tests.php -p `pwd`/sapi/cli/php -g "FAIL,XFAIL,BORK,WARN,LEAK,SKIP" --show-diff --set-timeout 120 -s
- ./sapi/cli/php sapi/phpdbg/tests/run-tests.php -diff2stdout --phpdbg sapi/phpdbg/phpdbg

View File

@@ -444,6 +444,12 @@ PRIMARY MAINTAINER: Frank M. Kromann
MAINTENANCE: Unknown
STATUS: Experimental
-------------------------------------------------------------------------------
EXTENSION: opcache
PRIMARY MAINTAINER: Dmitry Stogov <dmitry@zend.com>, Xinchen Hui <laruence@php.net>
MAINTENANCE: Maintained
STATUS: Working
SINCE: 5.5.0
-------------------------------------------------------------------------------
EXTENSION: openssl
PRIMARY MAINTAINER: Wez Furlong <wez@php.net>, Pierre-Alain Joye <pajoye@php.net>
MAINTENANCE: Maintained

77
NEWS
View File

@@ -1,14 +1,38 @@
PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ??? 2014, PHP 5.6.2
?? ??? 2014, PHP 5.6.4
?? ??? 2014, PHP 5.6.3
- Core:
. Fixed bug #67739 (Windows 8.1/Server 2012 R2 OS build number reported
as 6.2 (instead of 6.3)). (Christian Wenz)
. Fixed bug #68104 (Segfault while pre-evaluating a disabled function).
(Laruence)
. Implemented 64-bit format codes for pack() and unpack(). (Leigh)
. Fixed bug #51800 (proc_open on Windows hangs forever). (Anatol)
. Fixed bug #67633 (A foreach on an array returned from a function not doing
copy-on-write). (Nikita)
. Fixed bug #51800 (proc_open on Windows hangs forever). (Anatol)
. Fixed bug #67739 (Windows 8.1/Server 2012 R2 OS build number reported
as 6.2 (instead of 6.3)). (Christian Wenz)
. Fixed bug #67949 (DOMNodeList elements should be accessible through
array notation) (Florian)
. Fixed bug #68095 (AddressSanitizer reports a heap buffer overflow in
php_getopt()). (Stas)
. Fixed bug #68118 ($a->foo .= 'test'; can leave $a->foo undefined). (Nikita)
. Fixed bug #68129 (parse_url() - incomplete support for empty usernames
and passwords) (Tjerk)
- phpdbg:
. Added XML protocol (-x command line flag). (Bob)
. Added hard interruptions (twice SIGINT). (Bob)
- Fileinfo:
. Fixed bug #66242 (libmagic: don't assume char is signed). (ArdB)
. Fixed bug #68224 (buffer-overflow in libmagic/readcdf.c caught by
AddressSanitizer). (Remi)
. Fixed bug #68283 (fileinfo: out-of-bounds read in elf note headers).
(CVE-2014-3710) (Remi)
- FPM:
. Fixed bug #65641 (PHP-FPM incorrectly defines the SCRIPT_NAME variable
@@ -16,6 +40,14 @@ PHP NEWS
. Implemented FR #55508 (listen and listen.allowed_clients should take IPv6
addresses). (Robin Gloster)
- GD:
. Fixed bug #65171 (imagescale() fails without height param). (Remi)
- GMP:
. Implemented gmp_random_range() and gmp_random_bits(). (Leigh)
. Fixed bug #63595 (GMP memory management conflicts with other libraries
using GMP). (Remi)
- Reflection:
. Fixed bug #68103 (Duplicate entry in Reflection for class alias). (Remi)
@@ -23,6 +55,41 @@ PHP NEWS
. Fixed bug #68074 (Allow to use system cipher list instead of hardcoded
value). (Remi)
- Mysqli:
. Fixed bug #68114 (linker error on some OS X machines with fixed width
decimal support) (Keyur Govande)
- ODBC:
. Fixed bug #68087 (ODBC not correctly reading DATE column when preceded by
a VARCHAR column) (Keyur Govande)
- SPL:
. Fixed bug #68128 (Regression in RecursiveRegexIterator) (Tjerk)
- CURL:
. Add CURL_SSLVERSION_TLSv1_0, CURL_SSLVERSION_TLSv1_1, and
CURL_SSLVERSION_TLSv1_2 constants if supported by libcurl (Rasmus)
- PDO_pgsql:
. Fixed bug #68199 (PDO::pgsqlGetNotify doesn't support NOTIFY payloads)
(Matteo, Alain Laporte)
16 Oct 2014, PHP 5.6.2
- Core:
. Fixed bug #68044 (Integer overflow in unserialize() (32-bits only)).
(CVE-2014-3669) (Stas)
- cURL:
. Fixed bug #68089 (NULL byte injection - cURL lib). (Stas)
- EXIF:
. Fixed bug #68113 (Heap corruption in exif_thumbnail()). (CVE-2014-3670)
(Stas)
- XMLRPC:
. Fixed bug #68027 (Global buffer overflow in mkgmtime() function).
(CVE-2014-3668) (Stas)
02 Oct 2014, PHP 5.6.1
@@ -59,8 +126,6 @@ PHP NEWS
. Fixed bug #67839 (mysqli does not handle 4-byte floats correctly). (Keyur)
- OpenSSL:
. Fixed bug #41631 (socket timeouts not honored in blocking SSL reads).
(Daniel Lowrey)
. Fixed bug #67850 (extension won't build if openssl compiled without SSLv3).
(Daniel Lowrey)

View File

@@ -217,6 +217,7 @@ PHP 5.6 UPGRADE NOTES
- Strings:
substr_compare() now allows $length to be zero.
pack() and unpack() now support 64-bit format specifiers: q, Q, J and P.
- Crypt:
crypt() will now raise an E_NOTICE error if the salt parameter is omitted.
@@ -269,6 +270,7 @@ PHP 5.6 UPGRADE NOTES
Added gmp_root($a, $nth) and gmp_rootrem($a, $nth) for calculating nth roots.
Added gmp_import($data, $word_size = 1, $options = GMP_MSW_FIRST | GMP_NATIVE_ENDIAN) in PHP 5.6.1.
Added gmp_export($gmpnumber, $word_size = 1, $options = GMP_MSW_FIRST | GMP_NATIVE_ENDIAN) in PHP 5.6.1.
Added gmp_random_range() and gmp_random_bits() in PHP 5.6.3.
- Hash
Added hash_equals($known_string, $user_string)

View File

@@ -901,7 +901,7 @@ ZEND_API void _zend_bailout(char *filename, uint lineno) /* {{{ */
/* }}} */
END_EXTERN_C()
void zend_append_version_info(const zend_extension *extension) /* {{{ */
ZEND_API void zend_append_version_info(const zend_extension *extension) /* {{{ */
{
char *new_info;
uint new_info_length;

View File

@@ -2499,7 +2499,7 @@ ZEND_API void zend_post_deactivate_modules(TSRMLS_D) /* {{{ */
/* }}} */
/* return the next free module number */
int zend_next_free_module(void) /* {{{ */
ZEND_API int zend_next_free_module(void) /* {{{ */
{
return zend_hash_num_elements(&module_registry) + 1;
}
@@ -2635,18 +2635,15 @@ ZEND_API ZEND_FUNCTION(display_disabled_function)
}
/* }}} */
static zend_function_entry disabled_function[] = {
ZEND_FE(display_disabled_function, NULL)
ZEND_FE_END
};
ZEND_API int zend_disable_function(char *function_name, uint function_name_length TSRMLS_DC) /* {{{ */
{
if (zend_hash_del(CG(function_table), function_name, function_name_length+1)==FAILURE) {
return FAILURE;
zend_internal_function *func;
if (zend_hash_find(CG(function_table), function_name, function_name_length+1, (void **)&func)==SUCCESS) {
func->arg_info = NULL;
func->handler = ZEND_FN(display_disabled_function);
return SUCCESS;
}
disabled_function[0].fname = function_name;
return zend_register_functions(NULL, disabled_function, CG(function_table), MODULE_PERSISTENT TSRMLS_CC);
return FAILURE;
}
/* }}} */

View File

@@ -233,7 +233,7 @@ typedef struct _zend_fcall_info_cache {
#define ZEND_FCI_INITIALIZED(fci) ((fci).size != 0)
int zend_next_free_module(void);
ZEND_API int zend_next_free_module(void);
BEGIN_EXTERN_C()
ZEND_API int zend_get_parameters(int ht, int param_count, ...);

View File

@@ -111,7 +111,7 @@ END_EXTERN_C()
ZEND_API extern zend_llist zend_extensions;
void zend_extension_dtor(zend_extension *extension);
void zend_append_version_info(const zend_extension *extension);
ZEND_API void zend_append_version_info(const zend_extension *extension);
int zend_startup_extensions_mechanism(void);
int zend_startup_extensions(void);
void zend_shutdown_extensions(TSRMLS_D);

View File

@@ -119,7 +119,7 @@ int zend_sprintf(char *buffer, const char *format, ...);
PHP_MAJOR_VERSION=5
PHP_MINOR_VERSION=6
PHP_RELEASE_VERSION=2
PHP_RELEASE_VERSION=4
PHP_EXTRA_VERSION="-dev"
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`

View File

@@ -169,6 +169,11 @@ static int php_curl_option_str(php_curl *ch, long option, const char *str, const
{
CURLcode error = CURLE_OK;
if (strlen(str) != len) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Curl option contains invalid characters (\\0)");
return FAILURE;
}
#if LIBCURL_VERSION_NUM >= 0x071100
if (make_copy) {
#endif
@@ -1189,6 +1194,12 @@ PHP_MINIT_FUNCTION(curl)
REGISTER_CURL_CONSTANT(CURLSSLOPT_ALLOW_BEAST);
#endif
#if LIBCURL_VERSION_NUM >= 0x072200 /* Available since 7.34.0 */
REGISTER_CURL_CONSTANT(CURL_SSLVERSION_TLSv1_0);
REGISTER_CURL_CONSTANT(CURL_SSLVERSION_TLSv1_1);
REGISTER_CURL_CONSTANT(CURL_SSLVERSION_TLSv1_2);
#endif
#if CURLOPT_FTPASCII != 0
REGISTER_CURL_CONSTANT(CURLOPT_FTPASCII);
#endif

View File

@@ -0,0 +1,18 @@
--TEST--
Bug #68089 (NULL byte injection - cURL lib)
--SKIPIF--
<?php
include 'skipif.inc';
?>
--FILE--
<?php
$url = "file:///etc/passwd\0http://google.com";
$ch = curl_init();
var_dump(curl_setopt($ch, CURLOPT_URL, $url));
?>
Done
--EXPECTF--
Warning: curl_setopt(): Curl option contains invalid characters (\0) in %s/bug68089.php on line 4
bool(false)
Done

View File

@@ -1,4 +1,4 @@
const timelib_tzdb_index_entry timezonedb_idx_builtin[582] = {
const timelib_tzdb_index_entry timezonedb_idx_builtin[583] = {
{ "Africa/Abidjan" , 0x000000 },
{ "Africa/Accra" , 0x000055 },
{ "Africa/Addis_Ababa" , 0x00019D },
@@ -261,329 +261,330 @@ const timelib_tzdb_index_entry timezonedb_idx_builtin[582] = {
{ "Asia/Harbin" , 0x01B474 },
{ "Asia/Hebron" , 0x01B514 },
{ "Asia/Ho_Chi_Minh" , 0x01B870 },
{ "Asia/Hong_Kong" , 0x01B8E8 },
{ "Asia/Hovd" , 0x01BAAA },
{ "Asia/Irkutsk" , 0x01BC22 },
{ "Asia/Istanbul" , 0x01BE0D },
{ "Asia/Jakarta" , 0x01C1FA },
{ "Asia/Jayapura" , 0x01C2A4 },
{ "Asia/Jerusalem" , 0x01C341 },
{ "Asia/Kabul" , 0x01C670 },
{ "Asia/Kamchatka" , 0x01C6C1 },
{ "Asia/Karachi" , 0x01C8BA },
{ "Asia/Kashgar" , 0x01C96F },
{ "Asia/Kathmandu" , 0x01C9C4 },
{ "Asia/Katmandu" , 0x01CA2A },
{ "Asia/Khandyga" , 0x01CA90 },
{ "Asia/Kolkata" , 0x01CCBA },
{ "Asia/Krasnoyarsk" , 0x01CD33 },
{ "Asia/Kuala_Lumpur" , 0x01CF20 },
{ "Asia/Kuching" , 0x01CFDD },
{ "Asia/Kuwait" , 0x01D0CB },
{ "Asia/Macao" , 0x01D120 },
{ "Asia/Macau" , 0x01D25B },
{ "Asia/Magadan" , 0x01D396 },
{ "Asia/Makassar" , 0x01D59A },
{ "Asia/Manila" , 0x01D65F },
{ "Asia/Muscat" , 0x01D6E4 },
{ "Asia/Nicosia" , 0x01D739 },
{ "Asia/Novokuznetsk" , 0x01DA21 },
{ "Asia/Novosibirsk" , 0x01DC41 },
{ "Asia/Omsk" , 0x01DE31 },
{ "Asia/Oral" , 0x01E01D },
{ "Asia/Phnom_Penh" , 0x01E1ED },
{ "Asia/Pontianak" , 0x01E265 },
{ "Asia/Pyongyang" , 0x01E327 },
{ "Asia/Qatar" , 0x01E3B7 },
{ "Asia/Qyzylorda" , 0x01E41D },
{ "Asia/Rangoon" , 0x01E5F3 },
{ "Asia/Riyadh" , 0x01E66B },
{ "Asia/Saigon" , 0x01E6C0 },
{ "Asia/Sakhalin" , 0x01E738 },
{ "Asia/Samarkand" , 0x01E935 },
{ "Asia/Seoul" , 0x01EA6B },
{ "Asia/Shanghai" , 0x01EB32 },
{ "Asia/Singapore" , 0x01EBDE },
{ "Asia/Srednekolymsk" , 0x01EC95 },
{ "Asia/Taipei" , 0x01EE95 },
{ "Asia/Tashkent" , 0x01EFC6 },
{ "Asia/Tbilisi" , 0x01F0F7 },
{ "Asia/Tehran" , 0x01F2B1 },
{ "Asia/Tel_Aviv" , 0x01F51F },
{ "Asia/Thimbu" , 0x01F84E },
{ "Asia/Thimphu" , 0x01F8B4 },
{ "Asia/Tokyo" , 0x01F91A },
{ "Asia/Ujung_Pandang" , 0x01F9A4 },
{ "Asia/Ulaanbaatar" , 0x01FA21 },
{ "Asia/Ulan_Bator" , 0x01FB7C },
{ "Asia/Urumqi" , 0x01FCC9 },
{ "Asia/Ust-Nera" , 0x01FD2B },
{ "Asia/Vientiane" , 0x01FF3D },
{ "Asia/Vladivostok" , 0x01FFB5 },
{ "Asia/Yakutsk" , 0x02019F },
{ "Asia/Yekaterinburg" , 0x020389 },
{ "Asia/Yerevan" , 0x0205AA },
{ "Atlantic/Azores" , 0x0207AA },
{ "Atlantic/Bermuda" , 0x020CAD },
{ "Atlantic/Canary" , 0x020F8E },
{ "Atlantic/Cape_Verde" , 0x021264 },
{ "Atlantic/Faeroe" , 0x0212DD },
{ "Atlantic/Faroe" , 0x021581 },
{ "Atlantic/Jan_Mayen" , 0x021825 },
{ "Atlantic/Madeira" , 0x021B57 },
{ "Atlantic/Reykjavik" , 0x022060 },
{ "Atlantic/South_Georgia" , 0x022219 },
{ "Atlantic/St_Helena" , 0x02242B },
{ "Atlantic/Stanley" , 0x02225D },
{ "Australia/ACT" , 0x022480 },
{ "Australia/Adelaide" , 0x0227A3 },
{ "Australia/Brisbane" , 0x022AD5 },
{ "Australia/Broken_Hill" , 0x022BA2 },
{ "Australia/Canberra" , 0x022EE6 },
{ "Australia/Currie" , 0x023209 },
{ "Australia/Darwin" , 0x023542 },
{ "Australia/Eucla" , 0x0235CE },
{ "Australia/Hobart" , 0x0236AA },
{ "Australia/LHI" , 0x023A0E },
{ "Australia/Lindeman" , 0x023CAF },
{ "Australia/Lord_Howe" , 0x023D96 },
{ "Australia/Melbourne" , 0x024047 },
{ "Australia/North" , 0x024372 },
{ "Australia/NSW" , 0x0243EC },
{ "Australia/Perth" , 0x02470F },
{ "Australia/Queensland" , 0x0247ED },
{ "Australia/South" , 0x02489F },
{ "Australia/Sydney" , 0x024BC2 },
{ "Australia/Tasmania" , 0x024F05 },
{ "Australia/Victoria" , 0x025250 },
{ "Australia/West" , 0x025573 },
{ "Australia/Yancowinna" , 0x02562F },
{ "Brazil/Acre" , 0x025957 },
{ "Brazil/DeNoronha" , 0x025A5B },
{ "Brazil/East" , 0x025B7B },
{ "Brazil/West" , 0x025E58 },
{ "Canada/Atlantic" , 0x025F50 },
{ "Canada/Central" , 0x026438 },
{ "Canada/East-Saskatchewan" , 0x026D42 },
{ "Canada/Eastern" , 0x026852 },
{ "Canada/Mountain" , 0x026ECB },
{ "Canada/Newfoundland" , 0x027241 },
{ "Canada/Pacific" , 0x02776C },
{ "Canada/Saskatchewan" , 0x027B85 },
{ "Canada/Yukon" , 0x027D0E },
{ "CET" , 0x028011 },
{ "Chile/Continental" , 0x02831A },
{ "Chile/EasterIsland" , 0x0286B5 },
{ "CST6CDT" , 0x0289F7 },
{ "Cuba" , 0x028D48 },
{ "EET" , 0x0290BB },
{ "Egypt" , 0x02936E },
{ "Eire" , 0x029755 },
{ "EST" , 0x029C66 },
{ "EST5EDT" , 0x029CAA },
{ "Etc/GMT" , 0x029FFB },
{ "Etc/GMT+0" , 0x02A0C7 },
{ "Etc/GMT+1" , 0x02A151 },
{ "Etc/GMT+10" , 0x02A1DE },
{ "Etc/GMT+11" , 0x02A26C },
{ "Etc/GMT+12" , 0x02A2FA },
{ "Etc/GMT+2" , 0x02A415 },
{ "Etc/GMT+3" , 0x02A4A1 },
{ "Etc/GMT+4" , 0x02A52D },
{ "Etc/GMT+5" , 0x02A5B9 },
{ "Etc/GMT+6" , 0x02A645 },
{ "Etc/GMT+7" , 0x02A6D1 },
{ "Etc/GMT+8" , 0x02A75D },
{ "Etc/GMT+9" , 0x02A7E9 },
{ "Etc/GMT-0" , 0x02A083 },
{ "Etc/GMT-1" , 0x02A10B },
{ "Etc/GMT-10" , 0x02A197 },
{ "Etc/GMT-11" , 0x02A225 },
{ "Etc/GMT-12" , 0x02A2B3 },
{ "Etc/GMT-13" , 0x02A341 },
{ "Etc/GMT-14" , 0x02A388 },
{ "Etc/GMT-2" , 0x02A3CF },
{ "Etc/GMT-3" , 0x02A45B },
{ "Etc/GMT-4" , 0x02A4E7 },
{ "Etc/GMT-5" , 0x02A573 },
{ "Etc/GMT-6" , 0x02A5FF },
{ "Etc/GMT-7" , 0x02A68B },
{ "Etc/GMT-8" , 0x02A717 },
{ "Etc/GMT-9" , 0x02A7A3 },
{ "Etc/GMT0" , 0x02A03F },
{ "Etc/Greenwich" , 0x02A82F },
{ "Etc/UCT" , 0x02A873 },
{ "Etc/Universal" , 0x02A8B7 },
{ "Etc/UTC" , 0x02A8FB },
{ "Etc/Zulu" , 0x02A93F },
{ "Europe/Amsterdam" , 0x02A983 },
{ "Europe/Andorra" , 0x02ADC1 },
{ "Europe/Athens" , 0x02B03D },
{ "Europe/Belfast" , 0x02B380 },
{ "Europe/Belgrade" , 0x02B8B7 },
{ "Europe/Berlin" , 0x02BB80 },
{ "Europe/Bratislava" , 0x02BEE4 },
{ "Europe/Brussels" , 0x02C216 },
{ "Europe/Bucharest" , 0x02C64D },
{ "Europe/Budapest" , 0x02C977 },
{ "Europe/Busingen" , 0x02CCE0 },
{ "Europe/Chisinau" , 0x02CF97 },
{ "Europe/Copenhagen" , 0x02D325 },
{ "Europe/Dublin" , 0x02D62F },
{ "Europe/Gibraltar" , 0x02DB40 },
{ "Europe/Guernsey" , 0x02DF97 },
{ "Europe/Helsinki" , 0x02E4CE },
{ "Europe/Isle_of_Man" , 0x02E784 },
{ "Europe/Istanbul" , 0x02ECBB },
{ "Europe/Jersey" , 0x02F0A8 },
{ "Europe/Kaliningrad" , 0x02F5DF },
{ "Europe/Kiev" , 0x02F84A },
{ "Europe/Lisbon" , 0x02FB66 },
{ "Europe/Ljubljana" , 0x03006A },
{ "Europe/London" , 0x030333 },
{ "Europe/Luxembourg" , 0x03086A },
{ "Europe/Madrid" , 0x030CC0 },
{ "Europe/Malta" , 0x031086 },
{ "Europe/Mariehamn" , 0x03143F },
{ "Europe/Minsk" , 0x0316F5 },
{ "Europe/Monaco" , 0x031903 },
{ "Europe/Moscow" , 0x031D3E },
{ "Europe/Nicosia" , 0x031F98 },
{ "Europe/Oslo" , 0x032280 },
{ "Europe/Paris" , 0x0325B2 },
{ "Europe/Podgorica" , 0x0329F8 },
{ "Europe/Prague" , 0x032CC1 },
{ "Europe/Riga" , 0x032FF3 },
{ "Europe/Rome" , 0x033338 },
{ "Europe/Samara" , 0x0336FB },
{ "Europe/San_Marino" , 0x033964 },
{ "Europe/Sarajevo" , 0x033D27 },
{ "Europe/Simferopol" , 0x033FF0 },
{ "Europe/Skopje" , 0x034241 },
{ "Europe/Sofia" , 0x03450A },
{ "Europe/Stockholm" , 0x034812 },
{ "Europe/Tallinn" , 0x034AC1 },
{ "Europe/Tirane" , 0x034DFB },
{ "Europe/Tiraspol" , 0x035101 },
{ "Europe/Uzhgorod" , 0x03548F },
{ "Europe/Vaduz" , 0x0357A6 },
{ "Europe/Vatican" , 0x035A55 },
{ "Europe/Vienna" , 0x035E18 },
{ "Europe/Vilnius" , 0x036145 },
{ "Europe/Volgograd" , 0x036484 },
{ "Europe/Warsaw" , 0x0366A5 },
{ "Europe/Zagreb" , 0x036A86 },
{ "Europe/Zaporozhye" , 0x036D4F },
{ "Europe/Zurich" , 0x037090 },
{ "Factory" , 0x03733F },
{ "GB" , 0x0373B0 },
{ "GB-Eire" , 0x0378E7 },
{ "GMT" , 0x037E1E },
{ "GMT+0" , 0x037EEA },
{ "GMT-0" , 0x037EA6 },
{ "GMT0" , 0x037E62 },
{ "Greenwich" , 0x037F2E },
{ "Hongkong" , 0x037F72 },
{ "HST" , 0x038134 },
{ "Iceland" , 0x038178 },
{ "Indian/Antananarivo" , 0x038331 },
{ "Indian/Chagos" , 0x0383A5 },
{ "Indian/Christmas" , 0x038407 },
{ "Indian/Cocos" , 0x03844B },
{ "Indian/Comoro" , 0x03848F },
{ "Indian/Kerguelen" , 0x0384E4 },
{ "Indian/Mahe" , 0x038539 },
{ "Indian/Maldives" , 0x03858E },
{ "Indian/Mauritius" , 0x0385E3 },
{ "Indian/Mayotte" , 0x038659 },
{ "Indian/Reunion" , 0x0386AE },
{ "Iran" , 0x038703 },
{ "Israel" , 0x038971 },
{ "Jamaica" , 0x038CA0 },
{ "Japan" , 0x038D65 },
{ "Kwajalein" , 0x038DEF },
{ "Libya" , 0x038E52 },
{ "MET" , 0x038F5B },
{ "Mexico/BajaNorte" , 0x039264 },
{ "Mexico/BajaSur" , 0x0395CD },
{ "Mexico/General" , 0x039812 },
{ "MST" , 0x039A70 },
{ "MST7MDT" , 0x039AB4 },
{ "Navajo" , 0x039E05 },
{ "NZ" , 0x03A17E },
{ "NZ-CHAT" , 0x03A4FC },
{ "Pacific/Apia" , 0x03A7E0 },
{ "Pacific/Auckland" , 0x03A97C },
{ "Pacific/Chatham" , 0x03AD08 },
{ "Pacific/Chuuk" , 0x03AFFB },
{ "Pacific/Easter" , 0x03B054 },
{ "Pacific/Efate" , 0x03B3A3 },
{ "Pacific/Enderbury" , 0x03B469 },
{ "Pacific/Fakaofo" , 0x03B4D7 },
{ "Pacific/Fiji" , 0x03B528 },
{ "Pacific/Funafuti" , 0x03B6BB },
{ "Pacific/Galapagos" , 0x03B6FF },
{ "Pacific/Gambier" , 0x03B777 },
{ "Pacific/Guadalcanal" , 0x03B7DC },
{ "Pacific/Guam" , 0x03B831 },
{ "Pacific/Honolulu" , 0x03B887 },
{ "Pacific/Johnston" , 0x03B8FE },
{ "Pacific/Kiritimati" , 0x03B97D },
{ "Pacific/Kosrae" , 0x03B9E8 },
{ "Pacific/Kwajalein" , 0x03BA45 },
{ "Pacific/Majuro" , 0x03BAB1 },
{ "Pacific/Marquesas" , 0x03BB10 },
{ "Pacific/Midway" , 0x03BB77 },
{ "Pacific/Nauru" , 0x03BC01 },
{ "Pacific/Niue" , 0x03BC79 },
{ "Pacific/Norfolk" , 0x03BCD7 },
{ "Pacific/Noumea" , 0x03BD2C },
{ "Pacific/Pago_Pago" , 0x03BDBC },
{ "Pacific/Palau" , 0x03BE33 },
{ "Pacific/Pitcairn" , 0x03BE77 },
{ "Pacific/Pohnpei" , 0x03BECC },
{ "Pacific/Ponape" , 0x03BF21 },
{ "Pacific/Port_Moresby" , 0x03BF66 },
{ "Pacific/Rarotonga" , 0x03BFAA },
{ "Pacific/Saipan" , 0x03C086 },
{ "Pacific/Samoa" , 0x03C0E9 },
{ "Pacific/Tahiti" , 0x03C160 },
{ "Pacific/Tarawa" , 0x03C1C5 },
{ "Pacific/Tongatapu" , 0x03C219 },
{ "Pacific/Truk" , 0x03C2A5 },
{ "Pacific/Wake" , 0x03C2EA },
{ "Pacific/Wallis" , 0x03C33A },
{ "Pacific/Yap" , 0x03C37E },
{ "Poland" , 0x03C3C3 },
{ "Portugal" , 0x03C7A4 },
{ "PRC" , 0x03CCA0 },
{ "PST8PDT" , 0x03CD40 },
{ "ROC" , 0x03D091 },
{ "ROK" , 0x03D1C2 },
{ "Singapore" , 0x03D289 },
{ "Turkey" , 0x03D340 },
{ "UCT" , 0x03D72D },
{ "Universal" , 0x03D771 },
{ "US/Alaska" , 0x03D7B5 },
{ "US/Aleutian" , 0x03DB1E },
{ "US/Arizona" , 0x03DE84 },
{ "US/Central" , 0x03DF12 },
{ "US/East-Indiana" , 0x03E91C },
{ "US/Eastern" , 0x03E41D },
{ "US/Hawaii" , 0x03EB86 },
{ "US/Indiana-Starke" , 0x03EBF7 },
{ "US/Michigan" , 0x03EF68 },
{ "US/Mountain" , 0x03F29F },
{ "US/Pacific" , 0x03F618 },
{ "US/Pacific-New" , 0x03FA1D },
{ "US/Samoa" , 0x03FE22 },
{ "UTC" , 0x03FE99 },
{ "W-SU" , 0x040190 },
{ "WET" , 0x03FEDD },
{ "Zulu" , 0x0403D3 },
{ "Asia/Hong_Kong" , 0x01B912 },
{ "Asia/Hovd" , 0x01BAD4 },
{ "Asia/Irkutsk" , 0x01BC4C },
{ "Asia/Istanbul" , 0x01BE37 },
{ "Asia/Jakarta" , 0x01C224 },
{ "Asia/Jayapura" , 0x01C2CE },
{ "Asia/Jerusalem" , 0x01C36B },
{ "Asia/Kabul" , 0x01C69A },
{ "Asia/Kamchatka" , 0x01C6EB },
{ "Asia/Karachi" , 0x01C8E4 },
{ "Asia/Kashgar" , 0x01C999 },
{ "Asia/Kathmandu" , 0x01C9EE },
{ "Asia/Katmandu" , 0x01CA54 },
{ "Asia/Khandyga" , 0x01CABA },
{ "Asia/Kolkata" , 0x01CCE4 },
{ "Asia/Krasnoyarsk" , 0x01CD5D },
{ "Asia/Kuala_Lumpur" , 0x01CF4A },
{ "Asia/Kuching" , 0x01D007 },
{ "Asia/Kuwait" , 0x01D0F5 },
{ "Asia/Macao" , 0x01D14A },
{ "Asia/Macau" , 0x01D285 },
{ "Asia/Magadan" , 0x01D3C0 },
{ "Asia/Makassar" , 0x01D5C4 },
{ "Asia/Manila" , 0x01D689 },
{ "Asia/Muscat" , 0x01D70E },
{ "Asia/Nicosia" , 0x01D763 },
{ "Asia/Novokuznetsk" , 0x01DA4B },
{ "Asia/Novosibirsk" , 0x01DC6B },
{ "Asia/Omsk" , 0x01DE5B },
{ "Asia/Oral" , 0x01E047 },
{ "Asia/Phnom_Penh" , 0x01E217 },
{ "Asia/Pontianak" , 0x01E26C },
{ "Asia/Pyongyang" , 0x01E32E },
{ "Asia/Qatar" , 0x01E3BE },
{ "Asia/Qyzylorda" , 0x01E424 },
{ "Asia/Rangoon" , 0x01E5FA },
{ "Asia/Riyadh" , 0x01E672 },
{ "Asia/Saigon" , 0x01E6C7 },
{ "Asia/Sakhalin" , 0x01E769 },
{ "Asia/Samarkand" , 0x01E966 },
{ "Asia/Seoul" , 0x01EA9C },
{ "Asia/Shanghai" , 0x01EB63 },
{ "Asia/Singapore" , 0x01EC0F },
{ "Asia/Srednekolymsk" , 0x01ECC6 },
{ "Asia/Taipei" , 0x01EEC6 },
{ "Asia/Tashkent" , 0x01EFF7 },
{ "Asia/Tbilisi" , 0x01F128 },
{ "Asia/Tehran" , 0x01F2E2 },
{ "Asia/Tel_Aviv" , 0x01F550 },
{ "Asia/Thimbu" , 0x01F87F },
{ "Asia/Thimphu" , 0x01F8E5 },
{ "Asia/Tokyo" , 0x01F94B },
{ "Asia/Ujung_Pandang" , 0x01F9D5 },
{ "Asia/Ulaanbaatar" , 0x01FA52 },
{ "Asia/Ulan_Bator" , 0x01FBAD },
{ "Asia/Urumqi" , 0x01FCFA },
{ "Asia/Ust-Nera" , 0x01FD5C },
{ "Asia/Vientiane" , 0x01FF6E },
{ "Asia/Vladivostok" , 0x01FFC3 },
{ "Asia/Yakutsk" , 0x0201AD },
{ "Asia/Yekaterinburg" , 0x020397 },
{ "Asia/Yerevan" , 0x0205B8 },
{ "Atlantic/Azores" , 0x0207B8 },
{ "Atlantic/Bermuda" , 0x020CBB },
{ "Atlantic/Canary" , 0x020F9C },
{ "Atlantic/Cape_Verde" , 0x021272 },
{ "Atlantic/Faeroe" , 0x0212EB },
{ "Atlantic/Faroe" , 0x02158F },
{ "Atlantic/Jan_Mayen" , 0x021833 },
{ "Atlantic/Madeira" , 0x021B65 },
{ "Atlantic/Reykjavik" , 0x02206E },
{ "Atlantic/South_Georgia" , 0x022227 },
{ "Atlantic/St_Helena" , 0x022439 },
{ "Atlantic/Stanley" , 0x02226B },
{ "Australia/ACT" , 0x02248E },
{ "Australia/Adelaide" , 0x0227B1 },
{ "Australia/Brisbane" , 0x022AE3 },
{ "Australia/Broken_Hill" , 0x022BB0 },
{ "Australia/Canberra" , 0x022EF4 },
{ "Australia/Currie" , 0x023217 },
{ "Australia/Darwin" , 0x023550 },
{ "Australia/Eucla" , 0x0235DC },
{ "Australia/Hobart" , 0x0236B8 },
{ "Australia/LHI" , 0x023A1C },
{ "Australia/Lindeman" , 0x023CBD },
{ "Australia/Lord_Howe" , 0x023DA4 },
{ "Australia/Melbourne" , 0x024055 },
{ "Australia/North" , 0x024380 },
{ "Australia/NSW" , 0x0243FA },
{ "Australia/Perth" , 0x02471D },
{ "Australia/Queensland" , 0x0247FB },
{ "Australia/South" , 0x0248AD },
{ "Australia/Sydney" , 0x024BD0 },
{ "Australia/Tasmania" , 0x024F13 },
{ "Australia/Victoria" , 0x02525E },
{ "Australia/West" , 0x025581 },
{ "Australia/Yancowinna" , 0x02563D },
{ "Brazil/Acre" , 0x025965 },
{ "Brazil/DeNoronha" , 0x025A69 },
{ "Brazil/East" , 0x025B89 },
{ "Brazil/West" , 0x025E66 },
{ "Canada/Atlantic" , 0x025F5E },
{ "Canada/Central" , 0x026446 },
{ "Canada/East-Saskatchewan" , 0x026D50 },
{ "Canada/Eastern" , 0x026860 },
{ "Canada/Mountain" , 0x026ED9 },
{ "Canada/Newfoundland" , 0x02724F },
{ "Canada/Pacific" , 0x02777A },
{ "Canada/Saskatchewan" , 0x027B93 },
{ "Canada/Yukon" , 0x027D1C },
{ "CET" , 0x02801F },
{ "Chile/Continental" , 0x028328 },
{ "Chile/EasterIsland" , 0x0286C3 },
{ "CST6CDT" , 0x028A05 },
{ "Cuba" , 0x028D56 },
{ "EET" , 0x0290C9 },
{ "Egypt" , 0x02937C },
{ "Eire" , 0x029763 },
{ "EST" , 0x029C74 },
{ "EST5EDT" , 0x029CB8 },
{ "Etc/GMT" , 0x02A009 },
{ "Etc/GMT+0" , 0x02A0D5 },
{ "Etc/GMT+1" , 0x02A15F },
{ "Etc/GMT+10" , 0x02A1EC },
{ "Etc/GMT+11" , 0x02A27A },
{ "Etc/GMT+12" , 0x02A308 },
{ "Etc/GMT+2" , 0x02A423 },
{ "Etc/GMT+3" , 0x02A4AF },
{ "Etc/GMT+4" , 0x02A53B },
{ "Etc/GMT+5" , 0x02A5C7 },
{ "Etc/GMT+6" , 0x02A653 },
{ "Etc/GMT+7" , 0x02A6DF },
{ "Etc/GMT+8" , 0x02A76B },
{ "Etc/GMT+9" , 0x02A7F7 },
{ "Etc/GMT-0" , 0x02A091 },
{ "Etc/GMT-1" , 0x02A119 },
{ "Etc/GMT-10" , 0x02A1A5 },
{ "Etc/GMT-11" , 0x02A233 },
{ "Etc/GMT-12" , 0x02A2C1 },
{ "Etc/GMT-13" , 0x02A34F },
{ "Etc/GMT-14" , 0x02A396 },
{ "Etc/GMT-2" , 0x02A3DD },
{ "Etc/GMT-3" , 0x02A469 },
{ "Etc/GMT-4" , 0x02A4F5 },
{ "Etc/GMT-5" , 0x02A581 },
{ "Etc/GMT-6" , 0x02A60D },
{ "Etc/GMT-7" , 0x02A699 },
{ "Etc/GMT-8" , 0x02A725 },
{ "Etc/GMT-9" , 0x02A7B1 },
{ "Etc/GMT0" , 0x02A04D },
{ "Etc/Greenwich" , 0x02A83D },
{ "Etc/UCT" , 0x02A881 },
{ "Etc/Universal" , 0x02A8C5 },
{ "Etc/UTC" , 0x02A909 },
{ "Etc/Zulu" , 0x02A94D },
{ "Europe/Amsterdam" , 0x02A991 },
{ "Europe/Andorra" , 0x02ADCF },
{ "Europe/Athens" , 0x02B04B },
{ "Europe/Belfast" , 0x02B38E },
{ "Europe/Belgrade" , 0x02B8C5 },
{ "Europe/Berlin" , 0x02BB8E },
{ "Europe/Bratislava" , 0x02BEF2 },
{ "Europe/Brussels" , 0x02C224 },
{ "Europe/Bucharest" , 0x02C65B },
{ "Europe/Budapest" , 0x02C985 },
{ "Europe/Busingen" , 0x02CCEE },
{ "Europe/Chisinau" , 0x02CFA5 },
{ "Europe/Copenhagen" , 0x02D333 },
{ "Europe/Dublin" , 0x02D63D },
{ "Europe/Gibraltar" , 0x02DB4E },
{ "Europe/Guernsey" , 0x02DFA5 },
{ "Europe/Helsinki" , 0x02E4DC },
{ "Europe/Isle_of_Man" , 0x02E792 },
{ "Europe/Istanbul" , 0x02ECC9 },
{ "Europe/Jersey" , 0x02F0B6 },
{ "Europe/Kaliningrad" , 0x02F5ED },
{ "Europe/Kiev" , 0x02F858 },
{ "Europe/Lisbon" , 0x02FB74 },
{ "Europe/Ljubljana" , 0x030078 },
{ "Europe/London" , 0x030341 },
{ "Europe/Luxembourg" , 0x030878 },
{ "Europe/Madrid" , 0x030CCE },
{ "Europe/Malta" , 0x031094 },
{ "Europe/Mariehamn" , 0x03144D },
{ "Europe/Minsk" , 0x031703 },
{ "Europe/Monaco" , 0x031916 },
{ "Europe/Moscow" , 0x031D51 },
{ "Europe/Nicosia" , 0x031FAB },
{ "Europe/Oslo" , 0x032293 },
{ "Europe/Paris" , 0x0325C5 },
{ "Europe/Podgorica" , 0x032A0B },
{ "Europe/Prague" , 0x032CD4 },
{ "Europe/Riga" , 0x033006 },
{ "Europe/Rome" , 0x03334B },
{ "Europe/Samara" , 0x03370E },
{ "Europe/San_Marino" , 0x033977 },
{ "Europe/Sarajevo" , 0x033D3A },
{ "Europe/Simferopol" , 0x034003 },
{ "Europe/Skopje" , 0x034254 },
{ "Europe/Sofia" , 0x03451D },
{ "Europe/Stockholm" , 0x034825 },
{ "Europe/Tallinn" , 0x034AD4 },
{ "Europe/Tirane" , 0x034E0E },
{ "Europe/Tiraspol" , 0x035114 },
{ "Europe/Uzhgorod" , 0x0354A2 },
{ "Europe/Vaduz" , 0x0357B9 },
{ "Europe/Vatican" , 0x035A68 },
{ "Europe/Vienna" , 0x035E2B },
{ "Europe/Vilnius" , 0x036158 },
{ "Europe/Volgograd" , 0x036497 },
{ "Europe/Warsaw" , 0x0366B8 },
{ "Europe/Zagreb" , 0x036A99 },
{ "Europe/Zaporozhye" , 0x036D62 },
{ "Europe/Zurich" , 0x0370A3 },
{ "Factory" , 0x037352 },
{ "GB" , 0x0373C3 },
{ "GB-Eire" , 0x0378FA },
{ "GMT" , 0x037E31 },
{ "GMT+0" , 0x037EFD },
{ "GMT-0" , 0x037EB9 },
{ "GMT0" , 0x037E75 },
{ "Greenwich" , 0x037F41 },
{ "Hongkong" , 0x037F85 },
{ "HST" , 0x038147 },
{ "Iceland" , 0x03818B },
{ "Indian/Antananarivo" , 0x038344 },
{ "Indian/Chagos" , 0x0383B8 },
{ "Indian/Christmas" , 0x03841A },
{ "Indian/Cocos" , 0x03845E },
{ "Indian/Comoro" , 0x0384A2 },
{ "Indian/Kerguelen" , 0x0384F7 },
{ "Indian/Mahe" , 0x03854C },
{ "Indian/Maldives" , 0x0385A1 },
{ "Indian/Mauritius" , 0x0385F6 },
{ "Indian/Mayotte" , 0x03866C },
{ "Indian/Reunion" , 0x0386C1 },
{ "Iran" , 0x038716 },
{ "Israel" , 0x038984 },
{ "Jamaica" , 0x038CB3 },
{ "Japan" , 0x038D78 },
{ "Kwajalein" , 0x038E02 },
{ "Libya" , 0x038E65 },
{ "MET" , 0x038F6E },
{ "Mexico/BajaNorte" , 0x039277 },
{ "Mexico/BajaSur" , 0x0395E0 },
{ "Mexico/General" , 0x039825 },
{ "MST" , 0x039A83 },
{ "MST7MDT" , 0x039AC7 },
{ "Navajo" , 0x039E18 },
{ "NZ" , 0x03A191 },
{ "NZ-CHAT" , 0x03A50F },
{ "Pacific/Apia" , 0x03A7F3 },
{ "Pacific/Auckland" , 0x03A98F },
{ "Pacific/Bougainville" , 0x03AD1B },
{ "Pacific/Chatham" , 0x03AD92 },
{ "Pacific/Chuuk" , 0x03B085 },
{ "Pacific/Easter" , 0x03B0DE },
{ "Pacific/Efate" , 0x03B42D },
{ "Pacific/Enderbury" , 0x03B4F3 },
{ "Pacific/Fakaofo" , 0x03B561 },
{ "Pacific/Fiji" , 0x03B5B2 },
{ "Pacific/Funafuti" , 0x03B745 },
{ "Pacific/Galapagos" , 0x03B789 },
{ "Pacific/Gambier" , 0x03B801 },
{ "Pacific/Guadalcanal" , 0x03B866 },
{ "Pacific/Guam" , 0x03B8BB },
{ "Pacific/Honolulu" , 0x03B911 },
{ "Pacific/Johnston" , 0x03B988 },
{ "Pacific/Kiritimati" , 0x03BA07 },
{ "Pacific/Kosrae" , 0x03BA72 },
{ "Pacific/Kwajalein" , 0x03BACF },
{ "Pacific/Majuro" , 0x03BB3B },
{ "Pacific/Marquesas" , 0x03BB9A },
{ "Pacific/Midway" , 0x03BC01 },
{ "Pacific/Nauru" , 0x03BC8B },
{ "Pacific/Niue" , 0x03BD03 },
{ "Pacific/Norfolk" , 0x03BD61 },
{ "Pacific/Noumea" , 0x03BDB6 },
{ "Pacific/Pago_Pago" , 0x03BE46 },
{ "Pacific/Palau" , 0x03BEBD },
{ "Pacific/Pitcairn" , 0x03BF01 },
{ "Pacific/Pohnpei" , 0x03BF56 },
{ "Pacific/Ponape" , 0x03BFAB },
{ "Pacific/Port_Moresby" , 0x03BFF0 },
{ "Pacific/Rarotonga" , 0x03C042 },
{ "Pacific/Saipan" , 0x03C11E },
{ "Pacific/Samoa" , 0x03C181 },
{ "Pacific/Tahiti" , 0x03C1F8 },
{ "Pacific/Tarawa" , 0x03C25D },
{ "Pacific/Tongatapu" , 0x03C2B1 },
{ "Pacific/Truk" , 0x03C33D },
{ "Pacific/Wake" , 0x03C382 },
{ "Pacific/Wallis" , 0x03C3D2 },
{ "Pacific/Yap" , 0x03C416 },
{ "Poland" , 0x03C45B },
{ "Portugal" , 0x03C83C },
{ "PRC" , 0x03CD38 },
{ "PST8PDT" , 0x03CDD8 },
{ "ROC" , 0x03D129 },
{ "ROK" , 0x03D25A },
{ "Singapore" , 0x03D321 },
{ "Turkey" , 0x03D3D8 },
{ "UCT" , 0x03D7C5 },
{ "Universal" , 0x03D809 },
{ "US/Alaska" , 0x03D84D },
{ "US/Aleutian" , 0x03DBB6 },
{ "US/Arizona" , 0x03DF1C },
{ "US/Central" , 0x03DFAA },
{ "US/East-Indiana" , 0x03E9B4 },
{ "US/Eastern" , 0x03E4B5 },
{ "US/Hawaii" , 0x03EC1E },
{ "US/Indiana-Starke" , 0x03EC8F },
{ "US/Michigan" , 0x03F000 },
{ "US/Mountain" , 0x03F337 },
{ "US/Pacific" , 0x03F6B0 },
{ "US/Pacific-New" , 0x03FAB5 },
{ "US/Samoa" , 0x03FEBA },
{ "UTC" , 0x03FF31 },
{ "W-SU" , 0x040228 },
{ "WET" , 0x03FF75 },
{ "Zulu" , 0x04046B },
};
/* This is a generated file, do not modify */
const unsigned char timelib_timezone_db_data_builtin[263191] = {
const unsigned char timelib_timezone_db_data_builtin[263343] = {
/* Africa/Abidjan */
@@ -8304,13 +8305,16 @@ const unsigned char timelib_timezone_db_data_builtin[263191] = {
/* Asia/Ho_Chi_Minh */
0x50, 0x48, 0x50, 0x31, 0x01, 0x56, 0x4E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x0C, 0x88, 0x6F, 0x42, 0x80,
0x91, 0x5F, 0xEE, 0xD0, 0x93, 0x85, 0xB1, 0x90, 0xB7, 0x41, 0xBC, 0x00, 0x01, 0x02, 0x03, 0x02,
0x00, 0x00, 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x63, 0xEC, 0x00, 0x04, 0x00, 0x00, 0x62, 0x70,
0x00, 0x08, 0x00, 0x00, 0x70, 0x80, 0x00, 0x08, 0x4C, 0x4D, 0x54, 0x00, 0x53, 0x4D, 0x54, 0x00,
0x49, 0x43, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x99, 0xBB, 0x78,
0x01, 0xB5, 0x6B, 0x2A, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x15, 0x88, 0x8C, 0x43, 0x80,
0x91, 0xA3, 0x2B, 0x0A, 0xCD, 0x35, 0xE6, 0x80, 0xD1, 0x59, 0xCE, 0x70, 0xD2, 0x3B, 0x3E, 0xF0,
0xD5, 0x32, 0xBB, 0x10, 0xE4, 0xB6, 0xE4, 0x80, 0xED, 0x2F, 0x98, 0x00, 0x0A, 0x3D, 0xC7, 0x00,
0x01, 0x02, 0x03, 0x04, 0x02, 0x03, 0x02, 0x03, 0x02, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, 0x00,
0x00, 0x63, 0xF6, 0x00, 0x04, 0x00, 0x00, 0x62, 0x70, 0x00, 0x09, 0x00, 0x00, 0x70, 0x80, 0x00,
0x0D, 0x00, 0x00, 0x7E, 0x90, 0x00, 0x11, 0x4C, 0x4D, 0x54, 0x00, 0x50, 0x4C, 0x4D, 0x54, 0x00,
0x49, 0x43, 0x54, 0x00, 0x49, 0x44, 0x54, 0x00, 0x4A, 0x53, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x99, 0xBB, 0x78, 0x01, 0xB5, 0x6B, 0x2A, 0x00, 0x00,
0x00, 0x00,
/* Asia/Hong_Kong */
0x50, 0x48, 0x50, 0x31, 0x01, 0x48, 0x4B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -9046,13 +9050,11 @@ const unsigned char timelib_timezone_db_data_builtin[263191] = {
/* Asia/Phnom_Penh */
0x50, 0x48, 0x50, 0x31, 0x01, 0x4B, 0x48, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x0C, 0x88, 0x6F, 0x44, 0x24,
0x91, 0x5F, 0xEE, 0xD0, 0x93, 0x85, 0xB1, 0x90, 0xB7, 0x41, 0xBC, 0x00, 0x01, 0x02, 0x03, 0x02,
0x00, 0x00, 0x62, 0x5C, 0x00, 0x00, 0x00, 0x00, 0x63, 0xEC, 0x00, 0x04, 0x00, 0x00, 0x62, 0x70,
0x00, 0x08, 0x00, 0x00, 0x70, 0x80, 0x00, 0x08, 0x4C, 0x4D, 0x54, 0x00, 0x53, 0x4D, 0x54, 0x00,
0x49, 0x43, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9A, 0xF3, 0xF8,
0x01, 0xB2, 0xBF, 0x92, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x08, 0xA2, 0x6A, 0x67, 0xC4,
0x01, 0x00, 0x00, 0x5E, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x62, 0x70, 0x00, 0x04, 0x42, 0x4D, 0x54,
0x00, 0x49, 0x43, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9A, 0xF3, 0xF8, 0x01, 0xB2, 0xBF,
0x92, 0x00, 0x00, 0x00, 0x00,
/* Asia/Pontianak */
0x50, 0x48, 0x50, 0x31, 0x01, 0x49, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -9142,13 +9144,16 @@ const unsigned char timelib_timezone_db_data_builtin[263191] = {
/* Asia/Saigon */
0x50, 0x48, 0x50, 0x31, 0x00, 0x3F, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x0C, 0x88, 0x6F, 0x42, 0x80,
0x91, 0x5F, 0xEE, 0xD0, 0x93, 0x85, 0xB1, 0x90, 0xB7, 0x41, 0xBC, 0x00, 0x01, 0x02, 0x03, 0x02,
0x00, 0x00, 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x63, 0xEC, 0x00, 0x04, 0x00, 0x00, 0x62, 0x70,
0x00, 0x08, 0x00, 0x00, 0x70, 0x80, 0x00, 0x08, 0x4C, 0x4D, 0x54, 0x00, 0x53, 0x4D, 0x54, 0x00,
0x49, 0x43, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x89, 0x54, 0x40,
0x01, 0x12, 0xA8, 0x80, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x15, 0x88, 0x8C, 0x43, 0x80,
0x91, 0xA3, 0x2B, 0x0A, 0xCD, 0x35, 0xE6, 0x80, 0xD1, 0x59, 0xCE, 0x70, 0xD2, 0x3B, 0x3E, 0xF0,
0xD5, 0x32, 0xBB, 0x10, 0xE4, 0xB6, 0xE4, 0x80, 0xED, 0x2F, 0x98, 0x00, 0x0A, 0x3D, 0xC7, 0x00,
0x01, 0x02, 0x03, 0x04, 0x02, 0x03, 0x02, 0x03, 0x02, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, 0x00,
0x00, 0x63, 0xF6, 0x00, 0x04, 0x00, 0x00, 0x62, 0x70, 0x00, 0x09, 0x00, 0x00, 0x70, 0x80, 0x00,
0x0D, 0x00, 0x00, 0x7E, 0x90, 0x00, 0x11, 0x4C, 0x4D, 0x54, 0x00, 0x50, 0x4C, 0x4D, 0x54, 0x00,
0x49, 0x43, 0x54, 0x00, 0x49, 0x44, 0x54, 0x00, 0x4A, 0x53, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x89, 0x54, 0x40, 0x01, 0x12, 0xA8, 0x80, 0x00, 0x00,
0x00, 0x00,
/* Asia/Sakhalin */
0x50, 0x48, 0x50, 0x31, 0x01, 0x52, 0x55, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -9584,13 +9589,11 @@ const unsigned char timelib_timezone_db_data_builtin[263191] = {
/* Asia/Vientiane */
0x50, 0x48, 0x50, 0x31, 0x01, 0x4C, 0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x0C, 0x88, 0x6F, 0x46, 0x50,
0x91, 0x5F, 0xEE, 0xD0, 0x93, 0x85, 0xB1, 0x90, 0xB7, 0x41, 0xBC, 0x00, 0x01, 0x02, 0x03, 0x02,
0x00, 0x00, 0x60, 0x30, 0x00, 0x00, 0x00, 0x00, 0x63, 0xEC, 0x00, 0x04, 0x00, 0x00, 0x62, 0x70,
0x00, 0x08, 0x00, 0x00, 0x70, 0x80, 0x00, 0x08, 0x4C, 0x4D, 0x54, 0x00, 0x53, 0x4D, 0x54, 0x00,
0x49, 0x43, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA4, 0xBE, 0x7A,
0x01, 0xAF, 0x36, 0xA0, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x08, 0xA2, 0x6A, 0x67, 0xC4,
0x01, 0x00, 0x00, 0x5E, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x62, 0x70, 0x00, 0x04, 0x42, 0x4D, 0x54,
0x00, 0x49, 0x43, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA4, 0xBE, 0x7A, 0x01, 0xAF, 0x36,
0xA0, 0x00, 0x00, 0x00, 0x00,
/* Asia/Vladivostok */
0x50, 0x48, 0x50, 0x31, 0x01, 0x52, 0x55, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -14391,7 +14394,7 @@ const unsigned char timelib_timezone_db_data_builtin[263191] = {
/* Europe/Minsk */
0x50, 0x48, 0x50, 0x31, 0x01, 0x42, 0x59, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x44, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x22, 0xAA, 0x19, 0xAA, 0x38,
0x00, 0x00, 0x00, 0x45, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x22, 0xAA, 0x19, 0xAA, 0x38,
0xB5, 0xA4, 0x19, 0x60, 0xCA, 0x5E, 0x70, 0xD0, 0xCC, 0xE7, 0x4B, 0x10, 0xCD, 0xA9, 0x17, 0x90,
0xCE, 0xA2, 0x43, 0x10, 0xCF, 0x92, 0x34, 0x10, 0xD0, 0x0A, 0x02, 0x60, 0x15, 0x27, 0xA7, 0xD0,
0x16, 0x18, 0xDC, 0x40, 0x17, 0x08, 0xDB, 0x50, 0x17, 0xFA, 0x0F, 0xC0, 0x18, 0xEA, 0x0E, 0xD0,
@@ -14408,20 +14411,21 @@ const unsigned char timelib_timezone_db_data_builtin[263191] = {
0x40, 0x66, 0x15, 0x80, 0x41, 0x84, 0x2B, 0x00, 0x42, 0x45, 0xF7, 0x80, 0x43, 0x64, 0x0D, 0x00,
0x44, 0x25, 0xD9, 0x80, 0x45, 0x43, 0xEF, 0x00, 0x46, 0x05, 0xBB, 0x80, 0x47, 0x23, 0xD1, 0x00,
0x47, 0xEE, 0xD8, 0x00, 0x49, 0x03, 0xB3, 0x00, 0x49, 0xCE, 0xBA, 0x00, 0x4A, 0xE3, 0x95, 0x00,
0x4B, 0xAE, 0x9C, 0x00, 0x4C, 0xCC, 0xB1, 0x80, 0x4D, 0x8E, 0x7E, 0x00, 0x01, 0x02, 0x05, 0x03,
0x04, 0x03, 0x04, 0x02, 0x06, 0x02, 0x06, 0x02, 0x06, 0x02, 0x06, 0x07, 0x08, 0x07, 0x08, 0x07,
0x08, 0x07, 0x08, 0x07, 0x08, 0x07, 0x02, 0x09, 0x0A, 0x09, 0x0A, 0x09, 0x0A, 0x09, 0x0A, 0x09,
0x4B, 0xAE, 0x9C, 0x00, 0x4C, 0xCC, 0xB1, 0x80, 0x4D, 0x8E, 0x7E, 0x00, 0x54, 0x4C, 0x1D, 0x60,
0x01, 0x02, 0x05, 0x03, 0x04, 0x03, 0x04, 0x02, 0x06, 0x02, 0x06, 0x02, 0x06, 0x02, 0x06, 0x07,
0x08, 0x07, 0x08, 0x07, 0x08, 0x07, 0x08, 0x07, 0x08, 0x07, 0x02, 0x09, 0x0A, 0x09, 0x0A, 0x09,
0x0A, 0x09, 0x0A, 0x09, 0x0A, 0x09, 0x0A, 0x09, 0x0A, 0x09, 0x0A, 0x09, 0x0A, 0x09, 0x0A, 0x09,
0x0A, 0x09, 0x0A, 0x09, 0x0A, 0x09, 0x0A, 0x09, 0x0A, 0x09, 0x0A, 0x09, 0x0A, 0x09, 0x0A, 0x0B,
0x00, 0x00, 0x19, 0xC8, 0x00, 0x00, 0x00, 0x00, 0x1C, 0x20, 0x00, 0x04, 0x00, 0x00, 0x2A, 0x30,
0x00, 0x08, 0x00, 0x00, 0x0E, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x1C, 0x20, 0x01, 0x10, 0x00, 0x00,
0x1C, 0x20, 0x01, 0x10, 0x00, 0x00, 0x38, 0x40, 0x01, 0x15, 0x00, 0x00, 0x2A, 0x30, 0x00, 0x08,
0x00, 0x00, 0x38, 0x40, 0x01, 0x15, 0x00, 0x00, 0x2A, 0x30, 0x01, 0x19, 0x00, 0x00, 0x1C, 0x20,
0x00, 0x04, 0x00, 0x00, 0x2A, 0x30, 0x00, 0x1E, 0x4D, 0x4D, 0x54, 0x00, 0x45, 0x45, 0x54, 0x00,
0x4D, 0x53, 0x4B, 0x00, 0x43, 0x45, 0x54, 0x00, 0x43, 0x45, 0x53, 0x54, 0x00, 0x4D, 0x53, 0x44,
0x00, 0x45, 0x45, 0x53, 0x54, 0x00, 0x46, 0x45, 0x54, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00,
0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0xDB, 0x92, 0xF0, 0x01, 0x3C, 0xB8, 0xBA, 0x00, 0x00, 0x00, 0x00,
0x0A, 0x09, 0x0A, 0x09, 0x0A, 0x09, 0x0A, 0x09, 0x0A, 0x09, 0x0A, 0x09, 0x0A, 0x09, 0x0A, 0x09,
0x0A, 0x09, 0x0A, 0x0B, 0x07, 0x00, 0x00, 0x19, 0xC8, 0x00, 0x00, 0x00, 0x00, 0x1C, 0x20, 0x00,
0x04, 0x00, 0x00, 0x2A, 0x30, 0x00, 0x08, 0x00, 0x00, 0x0E, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x1C,
0x20, 0x01, 0x10, 0x00, 0x00, 0x1C, 0x20, 0x01, 0x10, 0x00, 0x00, 0x38, 0x40, 0x01, 0x15, 0x00,
0x00, 0x2A, 0x30, 0x00, 0x08, 0x00, 0x00, 0x38, 0x40, 0x01, 0x15, 0x00, 0x00, 0x2A, 0x30, 0x01,
0x19, 0x00, 0x00, 0x1C, 0x20, 0x00, 0x04, 0x00, 0x00, 0x2A, 0x30, 0x00, 0x1E, 0x4D, 0x4D, 0x54,
0x00, 0x45, 0x45, 0x54, 0x00, 0x4D, 0x53, 0x4B, 0x00, 0x43, 0x45, 0x54, 0x00, 0x43, 0x45, 0x53,
0x54, 0x00, 0x4D, 0x53, 0x44, 0x00, 0x45, 0x45, 0x53, 0x54, 0x00, 0x46, 0x45, 0x54, 0x00, 0x00,
0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xDB, 0x92, 0xF0, 0x01, 0x3C, 0xB8, 0xBA, 0x00,
0x00, 0x00, 0x00,
/* Europe/Monaco */
0x50, 0x48, 0x50, 0x31, 0x01, 0x4D, 0x43, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -16966,6 +16970,16 @@ const unsigned char timelib_timezone_db_data_builtin[263191] = {
0x00, 0x00, 0x00, 0x51, 0x13, 0x35, 0x02, 0x1D, 0x54, 0xBA, 0x00, 0x00, 0x00, 0x0E, 0x6D, 0x6F,
0x73, 0x74, 0x20, 0x6C, 0x6F, 0x63, 0x61, 0x74, 0x69, 0x6F, 0x6E, 0x73,
/* Pacific/Bougainville */
0x50, 0x48, 0x50, 0x31, 0x01, 0x50, 0x47, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x0C, 0xCC, 0x43, 0x36, 0x60,
0xD2, 0x2B, 0x6C, 0xF0, 0x54, 0x9E, 0xD7, 0x80, 0x01, 0x00, 0x02, 0x00, 0x00, 0x8C, 0xA0, 0x00,
0x00, 0x00, 0x00, 0x7E, 0x90, 0x00, 0x04, 0x00, 0x00, 0x9A, 0xB0, 0x00, 0x08, 0x50, 0x47, 0x54,
0x00, 0x4A, 0x53, 0x54, 0x00, 0x42, 0x53, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x7F, 0xD7, 0xDD, 0x02, 0x00, 0x08, 0xBA, 0x00, 0x00, 0x00, 0x0C, 0x42, 0x6F, 0x75, 0x67, 0x61,
0x69, 0x6E, 0x76, 0x69, 0x6C, 0x6C, 0x65,
/* Pacific/Chatham */
0x50, 0x48, 0x50, 0x31, 0x01, 0x4E, 0x5A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00,
@@ -17118,19 +17132,19 @@ const unsigned char timelib_timezone_db_data_builtin[263191] = {
0x36, 0x3B, 0x17, 0xE0, 0x36, 0xD7, 0xFA, 0x60, 0x38, 0x24, 0x34, 0x60, 0x38, 0xB7, 0xDC, 0x60,
0x4B, 0x11, 0x2C, 0xE0, 0x4B, 0xAE, 0x0F, 0x60, 0x4C, 0xC2, 0xEA, 0x60, 0x4D, 0x72, 0x41, 0xE0,
0x4E, 0xA2, 0xCC, 0x60, 0x4F, 0x1A, 0xC4, 0xE0, 0x50, 0x82, 0xAE, 0x60, 0x50, 0xFA, 0xA6, 0xE0,
0x52, 0x6B, 0xCA, 0xE0, 0x52, 0xDA, 0x7A, 0xD0, 0x54, 0x4B, 0xAC, 0xE0, 0x54, 0xBA, 0x5C, 0xD0,
0x56, 0x2B, 0x8E, 0xE0, 0x56, 0xA3, 0x79, 0x50, 0x58, 0x0B, 0x70, 0xE0, 0x58, 0x83, 0x5B, 0x50,
0x59, 0xEB, 0x52, 0xE0, 0x5A, 0x63, 0x3D, 0x50, 0x5B, 0xCB, 0x34, 0xE0, 0x5C, 0x43, 0x1F, 0x50,
0x5D, 0xB4, 0x51, 0x60, 0x5E, 0x23, 0x01, 0x50, 0x5F, 0x94, 0x33, 0x60, 0x60, 0x0C, 0x1D, 0xD0,
0x61, 0x74, 0x15, 0x60, 0x61, 0xEB, 0xFF, 0xD0, 0x63, 0x53, 0xF7, 0x60, 0x63, 0xCB, 0xE1, 0xD0,
0x65, 0x33, 0xD9, 0x60, 0x65, 0xAB, 0xC3, 0xD0, 0x67, 0x1C, 0xF5, 0xE0, 0x67, 0x8B, 0xA5, 0xD0,
0x68, 0xFC, 0xD7, 0xE0, 0x69, 0x6B, 0x87, 0xD0, 0x6A, 0xDC, 0xB9, 0xE0, 0x6B, 0x54, 0xA4, 0x50,
0x6C, 0xBC, 0x9B, 0xE0, 0x6D, 0x34, 0x86, 0x50, 0x6E, 0x9C, 0x7D, 0xE0, 0x6F, 0x14, 0x68, 0x50,
0x70, 0x7C, 0x5F, 0xE0, 0x70, 0xF4, 0x4A, 0x50, 0x72, 0x65, 0x7C, 0x60, 0x72, 0xD4, 0x2C, 0x50,
0x74, 0x45, 0x5E, 0x60, 0x74, 0xB4, 0x0E, 0x50, 0x76, 0x25, 0x40, 0x60, 0x76, 0x9D, 0x2A, 0xD0,
0x78, 0x05, 0x22, 0x60, 0x78, 0x7D, 0x0C, 0xD0, 0x79, 0xE5, 0x04, 0x60, 0x7A, 0x5C, 0xEE, 0xD0,
0x7B, 0xC4, 0xE6, 0x60, 0x7C, 0x3C, 0xD0, 0xD0, 0x7D, 0xAE, 0x02, 0xE0, 0x7E, 0x1C, 0xB2, 0xD0,
0x7F, 0x8D, 0xE4, 0xE0, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01,
0x52, 0x6B, 0xCA, 0xE0, 0x52, 0xDA, 0x7A, 0xD0, 0x54, 0x54, 0xE7, 0x60, 0x54, 0xBA, 0x6A, 0xE0,
0x56, 0x34, 0xC9, 0x60, 0x56, 0xA3, 0x87, 0x60, 0x58, 0x1D, 0xE5, 0xE0, 0x58, 0x83, 0x69, 0x60,
0x59, 0xFD, 0xC7, 0xE0, 0x5A, 0x63, 0x4B, 0x60, 0x5B, 0xDD, 0xA9, 0xE0, 0x5C, 0x43, 0x2D, 0x60,
0x5D, 0xBD, 0x8B, 0xE0, 0x5E, 0x23, 0x0F, 0x60, 0x5F, 0x9D, 0x6D, 0xE0, 0x60, 0x0C, 0x2B, 0xE0,
0x61, 0x86, 0x8A, 0x60, 0x61, 0xEC, 0x0D, 0xE0, 0x63, 0x66, 0x6C, 0x60, 0x63, 0xCB, 0xEF, 0xE0,
0x65, 0x46, 0x4E, 0x60, 0x65, 0xAB, 0xD1, 0xE0, 0x67, 0x26, 0x30, 0x60, 0x67, 0x8B, 0xB3, 0xE0,
0x69, 0x06, 0x12, 0x60, 0x69, 0x6B, 0x95, 0xE0, 0x6A, 0xE5, 0xF4, 0x60, 0x6B, 0x54, 0xB2, 0x60,
0x6C, 0xCF, 0x10, 0xE0, 0x6D, 0x34, 0x94, 0x60, 0x6E, 0xAE, 0xF2, 0xE0, 0x6F, 0x14, 0x76, 0x60,
0x70, 0x8E, 0xD4, 0xE0, 0x70, 0xF4, 0x58, 0x60, 0x72, 0x6E, 0xB6, 0xE0, 0x72, 0xD4, 0x3A, 0x60,
0x74, 0x4E, 0x98, 0xE0, 0x74, 0xB4, 0x1C, 0x60, 0x76, 0x37, 0xB5, 0x60, 0x76, 0x9D, 0x38, 0xE0,
0x78, 0x17, 0x97, 0x60, 0x78, 0x7D, 0x1A, 0xE0, 0x79, 0xF7, 0x79, 0x60, 0x7A, 0x5C, 0xFC, 0xE0,
0x7B, 0xD7, 0x5B, 0x60, 0x7C, 0x3C, 0xDE, 0xE0, 0x7D, 0xB7, 0x3D, 0x60, 0x7E, 0x1C, 0xC0, 0xE0,
0x7F, 0x97, 0x1F, 0x60, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01,
0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01,
0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01,
0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01,
@@ -17338,7 +17352,8 @@ const unsigned char timelib_timezone_db_data_builtin[263191] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x8C, 0xA0,
0x00, 0x00, 0x50, 0x47, 0x54, 0x00, 0x00, 0x00, 0x00, 0x7A, 0xD5, 0x50, 0x01, 0xF3, 0x37, 0x7A,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x0E, 0x6D, 0x6F, 0x73, 0x74, 0x20, 0x6C, 0x6F, 0x63, 0x61, 0x74, 0x69, 0x6F,
0x6E, 0x73,
/* Pacific/Rarotonga */
0x50, 0x48, 0x50, 0x31, 0x01, 0x43, 0x4B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -18532,4 +18547,4 @@ const unsigned char timelib_timezone_db_data_builtin[263191] = {
0x00, 0x00, 0x55, 0x54, 0x43, 0x00, 0x00, 0x00, 0x00, 0x89, 0x54, 0x40, 0x01, 0x12, 0xA8, 0x80,
0x00, 0x00, 0x00, 0x00, };
const timelib_tzdb timezonedb_builtin = { "2014.8", 582, timezonedb_idx_builtin, timelib_timezone_db_data_builtin };
const timelib_tzdb timezonedb_builtin = { "2014.9", 583, timezonedb_idx_builtin, timelib_timezone_db_data_builtin };

View File

@@ -330,7 +330,7 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_timezone_offset_get, 0, 0, 2)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_timezone_method_offset_get, 0, 0, 1)
ZEND_ARG_INFO(0, datetime)
ZEND_ARG_INFO(0, object)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_timezone_transitions_get, 0, 0, 1)
@@ -3848,7 +3848,7 @@ PHP_FUNCTION(timezone_name_from_abbr)
}
/* }}} */
/* {{{ proto long timezone_offset_get(DateTimeZone object, DateTime object)
/* {{{ proto long timezone_offset_get(DateTimeZone object, DateTimeInterface object)
Returns the timezone offset.
*/
PHP_FUNCTION(timezone_offset_get)
@@ -3858,13 +3858,13 @@ PHP_FUNCTION(timezone_offset_get)
php_date_obj *dateobj;
timelib_time_offset *offset;
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "OO", &object, date_ce_timezone, &dateobject, date_ce_date) == FAILURE) {
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "OO", &object, date_ce_timezone, &dateobject, date_ce_interface) == FAILURE) {
RETURN_FALSE;
}
tzobj = (php_timezone_obj *) zend_object_store_get_object(object TSRMLS_CC);
DATE_CHECK_INITIALIZED(tzobj->initialized, DateTimeZone);
dateobj = (php_date_obj *) zend_object_store_get_object(dateobject TSRMLS_CC);
DATE_CHECK_INITIALIZED(dateobj->time, DateTime);
DATE_CHECK_INITIALIZED(dateobj->time, DateTimeInterface);
switch (tzobj->type) {
case TIMELIB_ZONETYPE_ID:

13
ext/date/tests/68062.phpt Normal file
View File

@@ -0,0 +1,13 @@
--TEST--
DateTimeZone::getOffset() accepts a DateTimeInterface object
--FILE--
<?php
$tz = new DateTimeZone('Europe/London');
$dt = new DateTimeImmutable('2014-09-20', $tz);
echo $tz->getOffset($dt);
echo $tz->getOffset(1);
--EXPECTF--
3600
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, integer given in %s

View File

@@ -112,141 +112,141 @@ fclose( $file_handle );
-- int 0 --
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTime, integer given in %s on line %d
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, integer given in %s on line %d
bool(false)
-- int 1 --
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTime, integer given in %s on line %d
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, integer given in %s on line %d
bool(false)
-- int 12345 --
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTime, integer given in %s on line %d
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, integer given in %s on line %d
bool(false)
-- int -12345 --
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTime, integer given in %s on line %d
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, integer given in %s on line %d
bool(false)
-- float 10.5 --
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTime, double given in %s on line %d
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, double given in %s on line %d
bool(false)
-- float -10.5 --
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTime, double given in %s on line %d
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, double given in %s on line %d
bool(false)
-- float .5 --
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTime, double given in %s on line %d
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, double given in %s on line %d
bool(false)
-- empty array --
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTime, array given in %s on line %d
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, array given in %s on line %d
bool(false)
-- int indexed array --
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTime, array given in %s on line %d
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, array given in %s on line %d
bool(false)
-- associative array --
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTime, array given in %s on line %d
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, array given in %s on line %d
bool(false)
-- nested arrays --
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTime, array given in %s on line %d
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, array given in %s on line %d
bool(false)
-- uppercase NULL --
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTime, null given in %s on line %d
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, null given in %s on line %d
bool(false)
-- lowercase null --
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTime, null given in %s on line %d
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, null given in %s on line %d
bool(false)
-- lowercase true --
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTime, boolean given in %s on line %d
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, boolean given in %s on line %d
bool(false)
-- lowercase false --
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTime, boolean given in %s on line %d
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, boolean given in %s on line %d
bool(false)
-- uppercase TRUE --
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTime, boolean given in %s on line %d
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, boolean given in %s on line %d
bool(false)
-- uppercase FALSE --
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTime, boolean given in %s on line %d
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, boolean given in %s on line %d
bool(false)
-- empty string DQ --
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTime, string given in %s on line %d
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, string given in %s on line %d
bool(false)
-- empty string SQ --
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTime, string given in %s on line %d
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, string given in %s on line %d
bool(false)
-- string DQ --
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTime, string given in %s on line %d
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, string given in %s on line %d
bool(false)
-- string SQ --
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTime, string given in %s on line %d
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, string given in %s on line %d
bool(false)
-- mixed case string --
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTime, string given in %s on line %d
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, string given in %s on line %d
bool(false)
-- heredoc --
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTime, string given in %s on line %d
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, string given in %s on line %d
bool(false)
-- instance of classWithToString --
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTime, object given in %s on line %d
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, object given in %s on line %d
bool(false)
-- instance of classWithoutToString --
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTime, object given in %s on line %d
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, object given in %s on line %d
bool(false)
-- undefined var --
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTime, null given in %s on line %d
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, null given in %s on line %d
bool(false)
-- unset var --
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTime, null given in %s on line %d
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, null given in %s on line %d
bool(false)
-- resource --
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTime, resource given in %s on line %d
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, resource given in %s on line %d
bool(false)
===DONE===

View File

@@ -73,12 +73,12 @@ bool(false)
-- Testing timezone_offset_get() function with an invalid values for $datetime argument --
Warning: timezone_offset_get() expects parameter 2 to be DateTime, object given in %s on line %d
Warning: timezone_offset_get() expects parameter 2 to be DateTimeInterface, object given in %s on line %d
bool(false)
Warning: timezone_offset_get() expects parameter 2 to be DateTime, integer given in %s on line %d
Warning: timezone_offset_get() expects parameter 2 to be DateTimeInterface, integer given in %s on line %d
bool(false)
Warning: timezone_offset_get() expects parameter 2 to be DateTime, null given in %s on line %d
Warning: timezone_offset_get() expects parameter 2 to be DateTimeInterface, null given in %s on line %d
bool(false)
===DONE===

View File

@@ -112,141 +112,141 @@ fclose( $file_handle );
-- int 0 --
Warning: timezone_offset_get() expects parameter 2 to be DateTime, integer given in %s on line %d
Warning: timezone_offset_get() expects parameter 2 to be DateTimeInterface, integer given in %s on line %d
bool(false)
-- int 1 --
Warning: timezone_offset_get() expects parameter 2 to be DateTime, integer given in %s on line %d
Warning: timezone_offset_get() expects parameter 2 to be DateTimeInterface, integer given in %s on line %d
bool(false)
-- int 12345 --
Warning: timezone_offset_get() expects parameter 2 to be DateTime, integer given in %s on line %d
Warning: timezone_offset_get() expects parameter 2 to be DateTimeInterface, integer given in %s on line %d
bool(false)
-- int -12345 --
Warning: timezone_offset_get() expects parameter 2 to be DateTime, integer given in %s on line %d
Warning: timezone_offset_get() expects parameter 2 to be DateTimeInterface, integer given in %s on line %d
bool(false)
-- float 10.5 --
Warning: timezone_offset_get() expects parameter 2 to be DateTime, double given in %s on line %d
Warning: timezone_offset_get() expects parameter 2 to be DateTimeInterface, double given in %s on line %d
bool(false)
-- float -10.5 --
Warning: timezone_offset_get() expects parameter 2 to be DateTime, double given in %s on line %d
Warning: timezone_offset_get() expects parameter 2 to be DateTimeInterface, double given in %s on line %d
bool(false)
-- float .5 --
Warning: timezone_offset_get() expects parameter 2 to be DateTime, double given in %s on line %d
Warning: timezone_offset_get() expects parameter 2 to be DateTimeInterface, double given in %s on line %d
bool(false)
-- empty array --
Warning: timezone_offset_get() expects parameter 2 to be DateTime, array given in %s on line %d
Warning: timezone_offset_get() expects parameter 2 to be DateTimeInterface, array given in %s on line %d
bool(false)
-- int indexed array --
Warning: timezone_offset_get() expects parameter 2 to be DateTime, array given in %s on line %d
Warning: timezone_offset_get() expects parameter 2 to be DateTimeInterface, array given in %s on line %d
bool(false)
-- associative array --
Warning: timezone_offset_get() expects parameter 2 to be DateTime, array given in %s on line %d
Warning: timezone_offset_get() expects parameter 2 to be DateTimeInterface, array given in %s on line %d
bool(false)
-- nested arrays --
Warning: timezone_offset_get() expects parameter 2 to be DateTime, array given in %s on line %d
Warning: timezone_offset_get() expects parameter 2 to be DateTimeInterface, array given in %s on line %d
bool(false)
-- uppercase NULL --
Warning: timezone_offset_get() expects parameter 2 to be DateTime, null given in %s on line %d
Warning: timezone_offset_get() expects parameter 2 to be DateTimeInterface, null given in %s on line %d
bool(false)
-- lowercase null --
Warning: timezone_offset_get() expects parameter 2 to be DateTime, null given in %s on line %d
Warning: timezone_offset_get() expects parameter 2 to be DateTimeInterface, null given in %s on line %d
bool(false)
-- lowercase true --
Warning: timezone_offset_get() expects parameter 2 to be DateTime, boolean given in %s on line %d
Warning: timezone_offset_get() expects parameter 2 to be DateTimeInterface, boolean given in %s on line %d
bool(false)
-- lowercase false --
Warning: timezone_offset_get() expects parameter 2 to be DateTime, boolean given in %s on line %d
Warning: timezone_offset_get() expects parameter 2 to be DateTimeInterface, boolean given in %s on line %d
bool(false)
-- uppercase TRUE --
Warning: timezone_offset_get() expects parameter 2 to be DateTime, boolean given in %s on line %d
Warning: timezone_offset_get() expects parameter 2 to be DateTimeInterface, boolean given in %s on line %d
bool(false)
-- uppercase FALSE --
Warning: timezone_offset_get() expects parameter 2 to be DateTime, boolean given in %s on line %d
Warning: timezone_offset_get() expects parameter 2 to be DateTimeInterface, boolean given in %s on line %d
bool(false)
-- empty string DQ --
Warning: timezone_offset_get() expects parameter 2 to be DateTime, string given in %s on line %d
Warning: timezone_offset_get() expects parameter 2 to be DateTimeInterface, string given in %s on line %d
bool(false)
-- empty string SQ --
Warning: timezone_offset_get() expects parameter 2 to be DateTime, string given in %s on line %d
Warning: timezone_offset_get() expects parameter 2 to be DateTimeInterface, string given in %s on line %d
bool(false)
-- string DQ --
Warning: timezone_offset_get() expects parameter 2 to be DateTime, string given in %s on line %d
Warning: timezone_offset_get() expects parameter 2 to be DateTimeInterface, string given in %s on line %d
bool(false)
-- string SQ --
Warning: timezone_offset_get() expects parameter 2 to be DateTime, string given in %s on line %d
Warning: timezone_offset_get() expects parameter 2 to be DateTimeInterface, string given in %s on line %d
bool(false)
-- mixed case string --
Warning: timezone_offset_get() expects parameter 2 to be DateTime, string given in %s on line %d
Warning: timezone_offset_get() expects parameter 2 to be DateTimeInterface, string given in %s on line %d
bool(false)
-- heredoc --
Warning: timezone_offset_get() expects parameter 2 to be DateTime, string given in %s on line %d
Warning: timezone_offset_get() expects parameter 2 to be DateTimeInterface, string given in %s on line %d
bool(false)
-- instance of classWithToString --
Warning: timezone_offset_get() expects parameter 2 to be DateTime, object given in %s on line %d
Warning: timezone_offset_get() expects parameter 2 to be DateTimeInterface, object given in %s on line %d
bool(false)
-- instance of classWithoutToString --
Warning: timezone_offset_get() expects parameter 2 to be DateTime, object given in %s on line %d
Warning: timezone_offset_get() expects parameter 2 to be DateTimeInterface, object given in %s on line %d
bool(false)
-- undefined var --
Warning: timezone_offset_get() expects parameter 2 to be DateTime, null given in %s on line %d
Warning: timezone_offset_get() expects parameter 2 to be DateTimeInterface, null given in %s on line %d
bool(false)
-- unset var --
Warning: timezone_offset_get() expects parameter 2 to be DateTime, null given in %s on line %d
Warning: timezone_offset_get() expects parameter 2 to be DateTimeInterface, null given in %s on line %d
bool(false)
-- resource --
Warning: timezone_offset_get() expects parameter 2 to be DateTime, resource given in %s on line %d
Warning: timezone_offset_get() expects parameter 2 to be DateTimeInterface, resource given in %s on line %d
bool(false)
===DONE===

View File

@@ -137,6 +137,8 @@ int dom_node_text_content_write(dom_object *obj, zval *newval TSRMLS_DC);
/* nodelist properties */
int dom_nodelist_length_read(dom_object *obj, zval **retval TSRMLS_DC);
xmlNodePtr dom_nodelist_xml_item(dom_nnodemap_object *objmap, long index);
xmlNodePtr dom_nodelist_baseobj_item(dom_nnodemap_object *objmap, long index);
/* notation properties */
int dom_notation_public_id_read(dom_object *obj, zval **retval TSRMLS_DC);

View File

@@ -72,6 +72,7 @@ zend_class_entry *dom_namespace_node_class_entry;
/* }}} */
zend_object_handlers dom_object_handlers;
zend_object_handlers dom_nnodemap_object_handlers;
static HashTable classes;
/* {{{ prop handler tables */
@@ -668,6 +669,10 @@ PHP_MINIT_FUNCTION(dom)
dom_object_handlers.has_property = dom_property_exists;
dom_object_handlers.get_debug_info = dom_get_debug_info;
memcpy(&dom_nnodemap_object_handlers, &dom_object_handlers, sizeof(zend_object_handlers));
dom_nnodemap_object_handlers.read_dimension = dom_nodelist_read_dimension;
dom_nnodemap_object_handlers.has_dimension = dom_nodelist_has_dimension;
zend_hash_init(&classes, 0, NULL, NULL, 1);
INIT_CLASS_ENTRY(ce, "DOMException", php_dom_domexception_class_functions);
@@ -1297,7 +1302,7 @@ zend_object_value dom_nnodemap_objects_new(zend_class_entry *class_type TSRMLS_D
retval.handle = zend_objects_store_put(intern, dom_nnodemap_object_dtor, (zend_objects_free_object_storage_t)dom_nnodemap_objects_free_storage, dom_objects_clone TSRMLS_CC);
intern->handle = retval.handle;
retval.handlers = dom_get_obj_handlers(TSRMLS_C);
retval.handlers = &dom_nnodemap_object_handlers;
return retval;
}
@@ -1674,6 +1679,54 @@ xmlNsPtr dom_get_nsdecl(xmlNode *node, xmlChar *localName) {
}
/* }}} end dom_get_nsdecl */
static inline long dom_get_long(zval *offset) /* {{{ */
{
if (Z_TYPE_P(offset) == IS_LONG) {
return Z_LVAL_P(offset);
} else {
zval tmp;
MAKE_COPY_ZVAL(&offset, &tmp);
convert_to_long(&tmp);
return Z_LVAL(tmp);
}
}
/* }}} */
zval *dom_nodelist_read_dimension(zval *object, zval *offset, int type TSRMLS_DC) /* {{{ */
{
zval *rv, offset_copy = zval_used_for_init;
if (!offset) {
return NULL;
}
ZVAL_LONG(&offset_copy, dom_get_long(offset));
zend_call_method_with_1_params(&object, Z_OBJCE_P(object), NULL, "item", &rv, &offset_copy);
Z_DELREF_P(rv);
return rv;
} /* }}} end dom_nodelist_read_dimension */
int dom_nodelist_has_dimension(zval *object, zval *member, int check_empty TSRMLS_DC)
{
long offset = dom_get_long(member);
if (offset < 0) {
return 0;
} else {
zval *length = zend_read_property(Z_OBJCE_P(object), object, "length", sizeof("length") - 1, 0 TSRMLS_CC);
int ret = length && offset < Z_LVAL_P(length);
FREE_ZVAL(length);
return ret;
}
} /* }}} end dom_nodelist_has_dimension */
#endif /* HAVE_DOM */
/*

View File

@@ -123,6 +123,8 @@ xmlNode *php_dom_libxml_hash_iter(xmlHashTable *ht, int index);
xmlNode *php_dom_libxml_notation_iter(xmlHashTable *ht, int index);
zend_object_iterator *php_dom_get_iterator(zend_class_entry *ce, zval *object, int by_ref TSRMLS_DC);
int dom_set_doc_classmap(php_libxml_ref_obj *document, zend_class_entry *basece, zend_class_entry *ce TSRMLS_DC);
zval *dom_nodelist_read_dimension(zval *object, zval *offset, int type TSRMLS_DC);
int dom_nodelist_has_dimension(zval *object, zval *member, int check_empty TSRMLS_DC);
#define REGISTER_DOM_CLASS(ce, name, parent_ce, funcs, entry) \
INIT_CLASS_ENTRY(ce, name, funcs); \

View File

@@ -0,0 +1,87 @@
--TEST--
Bug #67949: DOMNodeList elements should be accessible through array notation
--FILE--
<?php
$html = <<<HTML
<div>data</div>
<a href="test">hello world</a>
HTML;
$doc = new DOMDocument;
$doc->loadHTML($html);
$nodes = $doc->getElementsByTagName('div');
echo "testing has_dimension\n";
var_dump(isset($nodes[0]));
var_dump(isset($nodes[1]));
var_dump(isset($nodes[-1]));
echo "testing property access\n";
var_dump($nodes[0]->textContent);
var_dump($nodes[1]->textContent);
echo "testing offset not a long\n";
$offset = ['test'];
var_dump($offset);
var_dump(isset($nodes[$offset]), $nodes[$offset]->textContent);
var_dump($offset);
$something = 'test';
$offset = &$something;
var_dump($offset);
var_dump(isset($nodes[$offset]), $nodes[$offset]->textContent);
var_dump($offset);
$offset = 'test';
var_dump($offset);
var_dump(isset($nodes[$offset]), $nodes[$offset]->textContent);
var_dump($offset);
echo "testing read_dimension with null offset\n";
var_dump($nodes[][] = 1);
echo "testing attribute access\n";
$anchor = $doc->getElementsByTagName('a')[0];
var_dump($anchor->attributes[0]->name);
echo "==DONE==\n";
--EXPECTF--
testing has_dimension
bool(true)
bool(false)
bool(false)
testing property access
string(4) "data"
Notice: Trying to get property of non-object in %s on line %d
NULL
testing offset not a long
array(1) {
[0]=>
string(4) "test"
}
Notice: Trying to get property of non-object in %s on line %d
bool(false)
NULL
array(1) {
[0]=>
string(4) "test"
}
string(4) "test"
bool(true)
string(4) "data"
string(4) "test"
string(4) "test"
bool(true)
string(4) "data"
string(4) "test"
testing read_dimension with null offset
NULL
testing attribute access
string(4) "href"
==DONE==

View File

@@ -2416,11 +2416,11 @@ static void* exif_ifd_make_value(image_info_data *info_data, int motorola_intel
data_ptr += 8;
break;
case TAG_FMT_SINGLE:
memmove(data_ptr, &info_data->value.f, byte_count);
memmove(data_ptr, &info_value->f, 4);
data_ptr += 4;
break;
case TAG_FMT_DOUBLE:
memmove(data_ptr, &info_data->value.d, byte_count);
memmove(data_ptr, &info_value->d, 8);
data_ptr += 8;
break;
}

BIN
ext/exif/tests/bug68113.jpg Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 368 B

View File

@@ -0,0 +1,17 @@
--TEST--
Bug #68113 (Heap corruption in exif_thumbnail())
--SKIPIF--
<?php
extension_loaded("exif") or die("skip need exif");
?>
--FILE--
<?php
var_dump(exif_thumbnail(__DIR__."/bug68113.jpg"));
?>
Done
--EXPECTF--
Warning: exif_thumbnail(bug68113.jpg): File structure corrupted in %s/bug68113.php on line 2
Warning: exif_thumbnail(bug68113.jpg): Invalid JPEG file in %s/bug68113.php on line 2
bool(false)
Done

View File

@@ -1,6 +1,6 @@
diff -u libmagic.orig/apprentice.c libmagic/apprentice.c
--- libmagic.orig/apprentice.c Tue Nov 19 22:01:12 2013
+++ libmagic/apprentice.c Mon Mar 31 17:15:53 2014
+++ libmagic/apprentice.c Fri Oct 3 22:48:34 2014
@@ -29,6 +29,8 @@
* apprentice - make one pass through /etc/magic, learning its secrets.
*/
@@ -454,6 +454,15 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c
return NULL;
}
return map;
@@ -1248,7 +1272,7 @@
* the sign extension must have happened.
*/
case FILE_BYTE:
- v = (char) v;
+ v = (signed char) v;
break;
case FILE_SHORT:
case FILE_BESHORT:
@@ -1516,7 +1540,7 @@
if (me->cont_count == me->max_count) {
struct magic *nm;
@@ -822,7 +831,7 @@ diff -u libmagic.orig/ascmagic.c libmagic/ascmagic.c
}
diff -u libmagic.orig/cdf.c libmagic/cdf.c
--- libmagic.orig/cdf.c Tue Feb 26 17:20:42 2013
+++ libmagic/cdf.c Tue Jul 1 08:57:25 2014
+++ libmagic/cdf.c Fri Oct 3 22:48:34 2014
@@ -35,7 +35,7 @@
#include "file.h"
@@ -937,7 +946,7 @@ diff -u libmagic.orig/cdf.c libmagic/cdf.c
/* If the it is not there, just fake it; some docs don't have it */
if (d->d_stream_first_sector < 0)
@@ -796,7 +815,11 @@
@@ -796,11 +815,15 @@
if (cdf_check_stream_offset(sst, h, e, 0, __LINE__) == -1)
goto out;
for (i = 0; i < sh.sh_properties; i++) {
@@ -950,6 +959,11 @@ diff -u libmagic.orig/cdf.c libmagic/cdf.c
q = (const uint8_t *)(const void *)
((const char *)(const void *)p + ofs
- 2 * sizeof(uint32_t));
- if (q > e) {
+ if (q < p || q > e) {
DPRINTF(("Ran of the end %p > %p\n", q, e));
goto out;
}
@@ -810,6 +833,10 @@
i, inp[i].pi_id, inp[i].pi_type, q - p, offs));
if (inp[i].pi_type & CDF_VECTOR) {
@@ -1814,7 +1828,16 @@ diff -u libmagic.orig/fsmagic.c libmagic/fsmagic.c
}
diff -u libmagic.orig/funcs.c libmagic/funcs.c
--- libmagic.orig/funcs.c Thu Feb 13 00:20:53 2014
+++ libmagic/funcs.c Wed Mar 19 13:28:34 2014
+++ libmagic/funcs.c Fri Oct 3 22:48:34 2014
@@ -27,7 +27,7 @@
#include "file.h"
#ifndef lint
-FILE_RCSID("@(#)$File: funcs.c,v 1.67 2014/02/12 23:20:53 christos Exp $")
+FILE_RCSID("@(#)$File: funcs.c,v 1.68 2014/02/18 11:09:31 kim Exp $")
#endif /* lint */
#include "magic.h"
@@ -41,79 +41,79 @@
#if defined(HAVE_WCTYPE_H)
#include <wctype.h>
@@ -1947,7 +1970,26 @@ diff -u libmagic.orig/funcs.c libmagic/funcs.c
{
int m = 0, rv = 0, looks_text = 0;
int mime = ms->flags & MAGIC_MIME;
@@ -203,10 +202,10 @@
@@ -174,8 +173,7 @@
const char *code_mime = "binary";
const char *type = "application/octet-stream";
const char *def = "data";
-
-
+ const char *ftype = NULL;
if (nb == 0) {
def = "empty";
@@ -188,7 +186,7 @@
if ((ms->flags & MAGIC_NO_CHECK_ENCODING) == 0) {
looks_text = file_encoding(ms, ubuf, nb, &u8buf, &ulen,
- &code, &code_mime, &type);
+ &code, &code_mime, &ftype);
}
#ifdef __EMX__
@@ -203,10 +201,10 @@
}
}
#endif
@@ -1961,7 +2003,7 @@ diff -u libmagic.orig/funcs.c libmagic/funcs.c
if ((ms->flags & MAGIC_DEBUG) != 0)
(void)fprintf(stderr, "zmagic %d\n", m);
goto done_encoding;
@@ -221,12 +220,17 @@
@@ -221,12 +219,17 @@
}
/* Check if we have a CDF file */
@@ -1984,7 +2026,16 @@ diff -u libmagic.orig/funcs.c libmagic/funcs.c
/* try soft magic tests */
if ((ms->flags & MAGIC_NO_CHECK_SOFT) == 0)
@@ -300,7 +304,6 @@
@@ -268,7 +271,7 @@
if ((ms->flags & MAGIC_NO_CHECK_ENCODING) == 0) {
if (looks_text == 0)
if ((m = file_ascmagic_with_encoding( ms, ubuf,
- nb, u8buf, ulen, code, type, looks_text))
+ nb, u8buf, ulen, code, ftype, looks_text))
!= 0) {
if ((ms->flags & MAGIC_DEBUG) != 0)
(void)fprintf(stderr,
@@ -300,7 +303,6 @@
return m;
}
@@ -1992,7 +2043,7 @@ diff -u libmagic.orig/funcs.c libmagic/funcs.c
protected int
file_reset(struct magic_set *ms)
@@ -310,11 +313,11 @@
@@ -310,11 +312,11 @@
return -1;
}
if (ms->o.buf) {
@@ -2006,7 +2057,7 @@ diff -u libmagic.orig/funcs.c libmagic/funcs.c
ms->o.pbuf = NULL;
}
ms->event_flags &= ~EVENT_HAD_ERR;
@@ -333,7 +336,7 @@
@@ -333,7 +335,7 @@
protected const char *
file_getbuffer(struct magic_set *ms)
{
@@ -2015,7 +2066,7 @@ diff -u libmagic.orig/funcs.c libmagic/funcs.c
size_t psize, len;
if (ms->event_flags & EVENT_HAD_ERR)
@@ -348,15 +351,13 @@
@@ -348,15 +350,13 @@
/* * 4 is for octal representation, + 1 is for NUL */
len = strlen(ms->o.buf);
if (len > (SIZE_MAX - 1) / 4) {
@@ -2032,7 +2083,7 @@ diff -u libmagic.orig/funcs.c libmagic/funcs.c
#if defined(HAVE_WCHAR_H) && defined(HAVE_MBRTOWC) && defined(HAVE_WCWIDTH)
{
@@ -416,8 +417,8 @@
@@ -416,8 +416,8 @@
if (level >= ms->c.len) {
len = (ms->c.len += 20) * sizeof(*ms->c.li);
ms->c.li = CAST(struct level_info *, (ms->c.li == NULL) ?
@@ -2043,7 +2094,7 @@ diff -u libmagic.orig/funcs.c libmagic/funcs.c
if (ms->c.li == NULL) {
file_oomem(ms, len);
return -1;
@@ -437,32 +438,50 @@
@@ -437,32 +437,50 @@
return ms->o.buf == NULL ? 0 : strlen(ms->o.buf);
}
@@ -2706,7 +2757,7 @@ diff -u libmagic.orig/print.c libmagic/print.c
}
diff -u libmagic.orig/readcdf.c libmagic/readcdf.c
--- libmagic.orig/readcdf.c Tue Jan 7 04:13:42 2014
+++ libmagic/readcdf.c Thu Jun 5 18:05:33 2014
+++ libmagic/readcdf.c Sat Oct 25 11:50:04 2014
@@ -26,11 +26,15 @@
#include "file.h"
@@ -2724,7 +2775,7 @@ diff -u libmagic.orig/readcdf.c libmagic/readcdf.c
#include <string.h>
#include <time.h>
#include <ctype.h>
@@ -69,6 +73,44 @@
@@ -69,6 +73,50 @@
{ NULL, NULL, },
};
@@ -2743,6 +2794,9 @@ diff -u libmagic.orig/readcdf.c libmagic/readcdf.c
+ { 0x00000000000c1084LLU, 0x46000000000000c0LLU },
+#endif
+ "x-msi",
+ },
+ { { 0, 0 },
+ NULL,
+ }
+}, clsid2desc[] = {
+ {
@@ -2753,6 +2807,9 @@ diff -u libmagic.orig/readcdf.c libmagic/readcdf.c
+#endif
+ "MSI Installer",
+ },
+ { { 0, 0 },
+ NULL,
+ }
+};
+
+private const char *
@@ -2769,7 +2826,7 @@ diff -u libmagic.orig/readcdf.c libmagic/readcdf.c
private const char *
cdf_app_to_mime(const char *vbuf, const struct nv *nv)
{
@@ -87,16 +129,21 @@
@@ -87,16 +135,21 @@
private int
cdf_file_property_info(struct magic_set *ms, const cdf_property_info_t *info,
@@ -2793,7 +2850,7 @@ diff -u libmagic.orig/readcdf.c libmagic/readcdf.c
for (i = 0; i < count; i++) {
cdf_print_property_name(buf, sizeof(buf), info[i].pi_id);
switch (info[i].pi_type) {
@@ -153,7 +200,7 @@
@@ -153,7 +206,7 @@
buf, vbuf) == -1)
return -1;
}
@@ -2802,7 +2859,7 @@ diff -u libmagic.orig/readcdf.c libmagic/readcdf.c
CDF_PROPERTY_NAME_OF_APPLICATION) {
str = cdf_app_to_mime(vbuf, app2mime);
}
@@ -162,8 +209,12 @@
@@ -162,8 +215,12 @@
case CDF_FILETIME:
tp = info[i].pi_tp;
if (tp != 0) {
@@ -2817,7 +2874,7 @@ diff -u libmagic.orig/readcdf.c libmagic/readcdf.c
cdf_print_elapsed_time(tbuf,
sizeof(tbuf), tp);
if (NOTMIME(ms) && file_printf(ms,
@@ -171,8 +222,11 @@
@@ -171,8 +228,11 @@
return -1;
} else {
char *c, *ec;
@@ -2831,7 +2888,7 @@ diff -u libmagic.orig/readcdf.c libmagic/readcdf.c
if (c != NULL &&
(ec = strchr(c, '\n')) != NULL)
*ec = '\0';
@@ -200,7 +254,7 @@
@@ -200,7 +260,7 @@
private int
cdf_file_summary_info(struct magic_set *ms, const cdf_header_t *h,
@@ -2840,7 +2897,7 @@ diff -u libmagic.orig/readcdf.c libmagic/readcdf.c
{
cdf_summary_info_header_t si;
cdf_property_info_t *info;
@@ -211,6 +265,8 @@
@@ -211,6 +271,8 @@
return -1;
if (NOTMIME(ms)) {
@@ -2849,7 +2906,7 @@ diff -u libmagic.orig/readcdf.c libmagic/readcdf.c
if (file_printf(ms, "Composite Document File V2 Document")
== -1)
return -1;
@@ -238,9 +294,15 @@
@@ -238,9 +300,15 @@
return -2;
break;
}
@@ -2867,7 +2924,7 @@ diff -u libmagic.orig/readcdf.c libmagic/readcdf.c
free(info);
return m == -1 ? -2 : m;
@@ -258,6 +320,7 @@
@@ -258,6 +326,7 @@
int i;
const char *expn = "";
const char *corrupt = "corrupt: ";
@@ -2875,7 +2932,7 @@ diff -u libmagic.orig/readcdf.c libmagic/readcdf.c
info.i_fd = fd;
info.i_buf = buf;
@@ -291,7 +354,8 @@
@@ -291,7 +360,8 @@
goto out2;
}
@@ -2885,7 +2942,7 @@ diff -u libmagic.orig/readcdf.c libmagic/readcdf.c
expn = "Cannot read short stream";
goto out3;
}
@@ -312,23 +376,21 @@
@@ -312,23 +382,21 @@
#ifdef CDF_DEBUG
cdf_dump_summary_info(&h, &scn);
#endif
@@ -2918,7 +2975,7 @@ diff -u libmagic.orig/readcdf.c libmagic/readcdf.c
if (str != NULL) {
diff -u libmagic.orig/readelf.c libmagic/readelf.c
--- libmagic.orig/readelf.c Tue Nov 5 16:44:01 2013
+++ libmagic/readelf.c Fri Feb 21 00:21:27 2014
+++ libmagic/readelf.c Sat Oct 25 11:50:04 2014
@@ -48,8 +48,8 @@
private int dophn_exec(struct magic_set *, int, int, int, off_t, int, size_t,
off_t, int *, int);
@@ -2983,7 +3040,21 @@ diff -u libmagic.orig/readelf.c libmagic/readelf.c
file_badread(ms);
return -1;
}
@@ -913,24 +928,12 @@
@@ -477,6 +492,13 @@
uint32_t namesz, descsz;
unsigned char *nbuf = CAST(unsigned char *, vbuf);
+ if (xnh_sizeof + offset > size) {
+ /*
+ * We're out of note headers.
+ */
+ return xnh_sizeof + offset;
+ }
+
(void)memcpy(xnh_addr, &nbuf[offset], xnh_sizeof);
offset += xnh_sizeof;
@@ -913,24 +935,12 @@
return 0;
}
@@ -3011,7 +3082,7 @@ diff -u libmagic.orig/readelf.c libmagic/readelf.c
file_badread(ms);
return -1;
}
@@ -955,14 +958,17 @@
@@ -955,14 +965,17 @@
/* Things we can determine when we seek */
switch (xsh_type) {
case SHT_NOTE:
@@ -3034,7 +3105,7 @@ diff -u libmagic.orig/readelf.c libmagic/readelf.c
return -1;
}
@@ -971,25 +977,16 @@
@@ -971,25 +984,16 @@
if (noff >= (off_t)xsh_size)
break;
noff = donote(ms, nbuf, (size_t)noff,
@@ -3065,7 +3136,7 @@ diff -u libmagic.orig/readelf.c libmagic/readelf.c
file_badseek(ms);
return -1;
}
@@ -1001,7 +998,7 @@
@@ -1001,7 +1005,7 @@
MAX(sizeof cap32, sizeof cap64)];
if ((coff += xcap_sizeof) > (off_t)xsh_size)
break;
@@ -3074,7 +3145,7 @@ diff -u libmagic.orig/readelf.c libmagic/readelf.c
(ssize_t)xcap_sizeof) {
file_badread(ms);
return -1;
@@ -1027,13 +1024,12 @@
@@ -1027,13 +1031,12 @@
break;
}
}
@@ -3090,7 +3161,7 @@ diff -u libmagic.orig/readelf.c libmagic/readelf.c
if (file_printf(ms, ", %sstripped", stripped ? "" : "not ") == -1)
return -1;
if (cap_hw1) {
@@ -1112,7 +1108,7 @@
@@ -1112,7 +1115,7 @@
const char *shared_libraries = "";
unsigned char nbuf[BUFSIZ];
ssize_t bufsize;
@@ -3099,7 +3170,7 @@ diff -u libmagic.orig/readelf.c libmagic/readelf.c
if (size != xph_sizeof) {
if (file_printf(ms, ", corrupted program header size") == -1)
@@ -1121,8 +1117,13 @@
@@ -1121,8 +1124,13 @@
}
for ( ; num; num--) {
@@ -3115,7 +3186,7 @@ diff -u libmagic.orig/readelf.c libmagic/readelf.c
return -1;
}
@@ -1160,9 +1161,12 @@
@@ -1160,9 +1168,12 @@
* This is a PT_NOTE section; loop through all the notes
* in the section.
*/
@@ -3131,7 +3202,7 @@ diff -u libmagic.orig/readelf.c libmagic/readelf.c
if (bufsize == -1) {
file_badread(ms);
return -1;
@@ -1223,7 +1227,7 @@
@@ -1223,7 +1234,7 @@
/*
* If we cannot seek, it must be a pipe, socket or fifo.
*/
@@ -3163,7 +3234,7 @@ diff -u libmagic.orig/readelf.h libmagic/readelf.h
typedef uint8_t Elf64_Char;
diff -u libmagic.orig/softmagic.c libmagic/softmagic.c
--- libmagic.orig/softmagic.c Thu Feb 13 00:20:53 2014
+++ libmagic/softmagic.c Tue Jul 1 08:57:25 2014
+++ libmagic/softmagic.c Mon Aug 4 14:58:55 2014
@@ -50,6 +50,11 @@
#include <locale.h>
#endif
@@ -3176,6 +3247,15 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c
private int match(struct magic_set *, struct magic *, uint32_t,
const unsigned char *, size_t, size_t, int, int, int, int, int *, int *,
@@ -62,7 +67,7 @@
private int32_t moffset(struct magic_set *, struct magic *);
private void mdebug(uint32_t, const char *, size_t);
private int mcopy(struct magic_set *, union VALUETYPE *, int, int,
- const unsigned char *, uint32_t, size_t, size_t);
+ const unsigned char *, uint32_t, size_t, struct magic *);
private int mconvert(struct magic_set *, struct magic *, int);
private int print_sep(struct magic_set *, int);
private int handle_annotation(struct magic_set *, struct magic *);
@@ -71,7 +76,8 @@
private void cvt_32(union VALUETYPE *, const struct magic *);
private void cvt_64(union VALUETYPE *, const struct magic *);
@@ -3320,9 +3400,72 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c
while (len--)
*ptr1++ = *ptr2++;
*ptr1 = '\0';
@@ -1178,9 +1170,6 @@
"nbytes=%zu, count=%u)\n", m->type, m->flag, offset, o,
nbytes, count);
@@ -1046,7 +1038,7 @@
private int
mcopy(struct magic_set *ms, union VALUETYPE *p, int type, int indir,
- const unsigned char *s, uint32_t offset, size_t nbytes, size_t linecnt)
+ const unsigned char *s, uint32_t offset, size_t nbytes, struct magic *m)
{
/*
* Note: FILE_SEARCH and FILE_REGEX do not actually copy
@@ -1066,15 +1058,24 @@
const char *last; /* end of search region */
const char *buf; /* start of search region */
const char *end;
- size_t lines;
+ size_t lines, linecnt, bytecnt;
+ linecnt = m->str_range;
+ bytecnt = linecnt * 80;
+
+ if (bytecnt == 0) {
+ bytecnt = 8192;
+ }
+ if (bytecnt > nbytes) {
+ bytecnt = nbytes;
+ }
if (s == NULL) {
ms->search.s_len = 0;
ms->search.s = NULL;
return 0;
}
buf = RCAST(const char *, s) + offset;
- end = last = RCAST(const char *, s) + nbytes;
+ end = last = RCAST(const char *, s) + bytecnt;
/* mget() guarantees buf <= last */
for (lines = linecnt, b = buf; lines && b < end &&
((b = CAST(const char *,
@@ -1087,7 +1088,7 @@
b++;
}
if (lines)
- last = RCAST(const char *, s) + nbytes;
+ last = RCAST(const char *, s) + bytecnt;
ms->search.s = buf;
ms->search.s_len = last - buf;
@@ -1158,7 +1159,6 @@
int *need_separator, int *returnval)
{
uint32_t soffset, offset = ms->offset;
- uint32_t count = m->str_range;
int rv, oneed_separator, in_type;
char *sbuf, *rbuf;
union VALUETYPE *p = &ms->ms_value;
@@ -1170,17 +1170,13 @@
}
if (mcopy(ms, p, m->type, m->flag & INDIR, s, (uint32_t)(offset + o),
- (uint32_t)nbytes, count) == -1)
+ (uint32_t)nbytes, m) == -1)
return -1;
if ((ms->flags & MAGIC_DEBUG) != 0) {
fprintf(stderr, "mget(type=%d, flag=%x, offset=%u, o=%zu, "
- "nbytes=%zu, count=%u)\n", m->type, m->flag, offset, o,
- nbytes, count);
+ "nbytes=%zu)\n", m->type, m->flag, offset, o, nbytes);
mdebug(offset, (char *)(void *)p, sizeof(union VALUETYPE));
-#ifndef COMPILE_ONLY
- file_mdump(m);
@@ -3330,7 +3473,15 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c
}
if (m->flag & INDIR) {
@@ -1679,9 +1668,6 @@
@@ -1672,16 +1668,13 @@
if ((ms->flags & MAGIC_DEBUG) != 0)
fprintf(stderr, "indirect +offs=%u\n", offset);
}
- if (mcopy(ms, p, m->type, 0, s, offset, nbytes, count) == -1)
+ if (mcopy(ms, p, m->type, 0, s, offset, nbytes, m) == -1)
return -1;
ms->offset = offset;
if ((ms->flags & MAGIC_DEBUG) != 0) {
mdebug(offset, (char *)(void *)p,
sizeof(union VALUETYPE));
@@ -3340,7 +3491,7 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c
}
}
@@ -1755,11 +1741,21 @@
@@ -1755,11 +1748,21 @@
ms->offset = soffset;
if (rv == 1) {
if ((ms->flags & (MAGIC_MIME|MAGIC_APPLE)) == 0 &&
@@ -3365,7 +3516,7 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c
}
return rv;
@@ -1875,6 +1871,42 @@
@@ -1875,6 +1878,42 @@
return file_strncmp(a, b, len, flags);
}
@@ -3408,7 +3559,7 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c
private int
magiccheck(struct magic_set *ms, struct magic *m)
{
@@ -2035,63 +2067,151 @@
@@ -2035,63 +2074,151 @@
break;
}
case FILE_REGEX: {
@@ -3444,7 +3595,7 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c
+ zval *retval;
+ zval *subpats;
+ char *haystack;
+
+
+ MAKE_STD_ZVAL(retval);
+ ALLOC_INIT_ZVAL(subpats);
+

View File

@@ -88,6 +88,9 @@ static const struct cv {
{ 0x00000000000c1084LLU, 0x46000000000000c0LLU },
#endif
"x-msi",
},
{ { 0, 0 },
NULL,
}
}, clsid2desc[] = {
{
@@ -98,6 +101,9 @@ static const struct cv {
#endif
"MSI Installer",
},
{ { 0, 0 },
NULL,
}
};
private const char *

View File

@@ -492,6 +492,13 @@ donote(struct magic_set *ms, void *vbuf, size_t offset, size_t size,
uint32_t namesz, descsz;
unsigned char *nbuf = CAST(unsigned char *, vbuf);
if (xnh_sizeof + offset > size) {
/*
* We're out of note headers.
*/
return xnh_sizeof + offset;
}
(void)memcpy(xnh_addr, &nbuf[offset], xnh_sizeof);
offset += xnh_sizeof;

View File

@@ -5118,11 +5118,23 @@ PHP_FUNCTION(imagescale)
return;
}
method = tmp_m;
new_width = tmp_w;
new_height = tmp_h;
ZEND_FETCH_RESOURCE(im, gdImagePtr, &IM, -1, "Image", le_gd);
if (tmp_h < 0) {
/* preserve ratio */
long src_x, src_y;
src_x = gdImageSX(im);
src_y = gdImageSY(im);
if (src_x) {
tmp_h = tmp_w * src_y / src_x;
}
}
new_width = tmp_w;
new_height = tmp_h;
if (gdImageSetInterpolationMethod(im, method)) {
im_scaled = gdImageScale(im, new_width, new_height);
}

View File

@@ -104,6 +104,15 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_gmp_random, 0, 0, 0)
ZEND_ARG_INFO(0, limiter)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_gmp_random_bits, 0, 0, 1)
ZEND_ARG_INFO(0, bits)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_gmp_random_range, 0, 0, 2)
ZEND_ARG_INFO(0, min)
ZEND_ARG_INFO(0, max)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_gmp_setbit, 0, 0, 2)
ZEND_ARG_INFO(0, a)
ZEND_ARG_INFO(0, index)
@@ -161,6 +170,8 @@ const zend_function_entry gmp_functions[] = {
ZEND_FE(gmp_cmp, arginfo_gmp_binary)
ZEND_FE(gmp_sign, arginfo_gmp_unary)
ZEND_FE(gmp_random, arginfo_gmp_random)
ZEND_FE(gmp_random_bits, arginfo_gmp_random_bits)
ZEND_FE(gmp_random_range, arginfo_gmp_random_range)
ZEND_FE(gmp_and, arginfo_gmp_binary)
ZEND_FE(gmp_or, arginfo_gmp_binary)
ZEND_FE(gmp_com, arginfo_gmp_unary)
@@ -352,30 +363,6 @@ static inline void gmp_zval_unary_ui_op(zval *return_value, zval *a_arg, gmp_una
#define gmp_unary_opl(op) _gmp_unary_opl(INTERNAL_FUNCTION_PARAM_PASSTHRU, op)
#define gmp_unary_ui_op(op) _gmp_unary_ui_op(INTERNAL_FUNCTION_PARAM_PASSTHRU, op)
/* {{{ gmp_emalloc
*/
static void *gmp_emalloc(size_t size)
{
return emalloc(size);
}
/* }}} */
/* {{{ gmp_erealloc
*/
static void *gmp_erealloc(void *ptr, size_t old_size, size_t new_size)
{
return erealloc(ptr, new_size);
}
/* }}} */
/* {{{ gmp_efree
*/
static void gmp_efree(void *ptr, size_t size)
{
efree(ptr);
}
/* }}} */
static inline long gmp_get_long(zval *zv) /* {{{ */
{
if (Z_TYPE_P(zv) == IS_LONG) {
@@ -723,8 +710,6 @@ ZEND_MINIT_FUNCTION(gmp)
REGISTER_LONG_CONSTANT("GMP_BIG_ENDIAN", GMP_BIG_ENDIAN, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GMP_NATIVE_ENDIAN", GMP_NATIVE_ENDIAN, CONST_CS | CONST_PERSISTENT);
mp_set_memory_functions(gmp_emalloc, gmp_erealloc, gmp_efree);
return SUCCESS;
}
/* }}} */
@@ -1784,6 +1769,22 @@ ZEND_FUNCTION(gmp_sign)
}
/* }}} */
static void gmp_init_random(TSRMLS_D)
{
if (!GMPG(rand_initialized)) {
/* Initialize */
#if GMP_42_OR_NEWER
gmp_randinit_mt(GMPG(rand_state));
#else
gmp_randinit_lc_2exp(GMPG(rand_state), 32L);
#endif
/* Seed */
gmp_randseed_ui(GMPG(rand_state), GENERATE_SEED());
GMPG(rand_initialized) = 1;
}
}
/* {{{ proto GMP gmp_random([int limiter])
Gets random number */
ZEND_FUNCTION(gmp_random)
@@ -1796,16 +1797,8 @@ ZEND_FUNCTION(gmp_random)
}
INIT_GMP_RETVAL(gmpnum_result);
gmp_init_random(TSRMLS_C);
if (!GMPG(rand_initialized)) {
/* Initialize */
gmp_randinit_lc_2exp_size(GMPG(rand_state), 32L);
/* Seed */
gmp_randseed_ui(GMPG(rand_state), GENERATE_SEED());
GMPG(rand_initialized) = 1;
}
#ifdef GMP_LIMB_BITS
mpz_urandomb(gmpnum_result, GMPG(rand_state), GMP_ABS (limiter) * GMP_LIMB_BITS);
#else
@@ -1814,6 +1807,91 @@ ZEND_FUNCTION(gmp_random)
}
/* }}} */
/* {{{ proto GMP gmp_random_bits(int bits)
Gets a random number in the range 0 to (2 ** n) - 1 */
ZEND_FUNCTION(gmp_random_bits)
{
long bits;
mpz_ptr gmpnum_result;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &bits) == FAILURE) {
return;
}
if (bits <= 0) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "The number of bits must be positive");
RETURN_FALSE;
}
INIT_GMP_RETVAL(gmpnum_result);
gmp_init_random(TSRMLS_C);
mpz_urandomb(gmpnum_result, GMPG(rand_state), bits);
}
/* }}} */
/* {{{ proto GMP gmp_random_range(mixed min, mixed max)
Gets a random number in the range min to max */
ZEND_FUNCTION(gmp_random_range)
{
zval *min_arg, *max_arg;
mpz_ptr gmpnum_min, gmpnum_max, gmpnum_result;
gmp_temp_t temp_a, temp_b;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz", &min_arg, &max_arg) == FAILURE) {
return;
}
gmp_init_random(TSRMLS_C);
FETCH_GMP_ZVAL(gmpnum_max, max_arg, temp_a);
if (Z_TYPE_P(min_arg) == IS_LONG && Z_LVAL_P(min_arg) >= 0) {
if (mpz_cmp_ui(gmpnum_max, Z_LVAL_P(min_arg)) <= 0) {
FREE_GMP_TEMP(temp_a);
php_error_docref(NULL TSRMLS_CC, E_WARNING, "The minimum value must be less than the maximum value");
RETURN_FALSE;
}
INIT_GMP_RETVAL(gmpnum_result);
if (Z_LVAL_P(min_arg)) {
mpz_sub_ui(gmpnum_max, gmpnum_max, Z_LVAL_P(min_arg));
}
mpz_add_ui(gmpnum_max, gmpnum_max, 1);
mpz_urandomm(gmpnum_result, GMPG(rand_state), gmpnum_max);
if (Z_LVAL_P(min_arg)) {
mpz_add_ui(gmpnum_result, gmpnum_result, Z_LVAL_P(min_arg));
}
FREE_GMP_TEMP(temp_a);
}
else {
FETCH_GMP_ZVAL_DEP(gmpnum_min, min_arg, temp_b, temp_a);
if (mpz_cmp(gmpnum_max, gmpnum_min) <= 0) {
FREE_GMP_TEMP(temp_b);
FREE_GMP_TEMP(temp_a);
php_error_docref(NULL TSRMLS_CC, E_WARNING, "The minimum value must be less than the maximum value");
RETURN_FALSE;
}
INIT_GMP_RETVAL(gmpnum_result);
mpz_sub(gmpnum_max, gmpnum_max, gmpnum_min);
mpz_add_ui(gmpnum_max, gmpnum_max, 1);
mpz_urandomm(gmpnum_result, GMPG(rand_state), gmpnum_max);
mpz_add(gmpnum_result, gmpnum_result, gmpnum_min);
FREE_GMP_TEMP(temp_b);
FREE_GMP_TEMP(temp_a);
}
}
/* }}} */
/* {{{ proto GMP gmp_and(mixed a, mixed b)
Calculates logical AND of a and b */
ZEND_FUNCTION(gmp_and)

View File

@@ -66,6 +66,8 @@ ZEND_FUNCTION(gmp_or);
ZEND_FUNCTION(gmp_com);
ZEND_FUNCTION(gmp_xor);
ZEND_FUNCTION(gmp_random);
ZEND_FUNCTION(gmp_random_bits);
ZEND_FUNCTION(gmp_random_range);
ZEND_FUNCTION(gmp_setbit);
ZEND_FUNCTION(gmp_clrbit);
ZEND_FUNCTION(gmp_scan0);

View File

@@ -0,0 +1,45 @@
--TEST--
gmp_random_bits() basic tests
--SKIPIF--
<?php if (!extension_loaded("gmp")) print "skip"; ?>
--FILE--
<?php
var_dump(gmp_random_bits());
var_dump(gmp_random_bits(0));
var_dump(gmp_random_bits(-1));
// If these error the test fails.
gmp_random_bits(1);
gmp_random_bits(1024);
// 2 seconds to make sure the numbers stay in range
$start = microtime(true);
$limit = (2 ** 30) - 1;
while (1) {
for ($i = 0; $i < 5000; $i++) {
$result = gmp_random_bits(30);
if ($result < 0 || $result > $limit) {
print "RANGE VIOLATION\n";
var_dump($result);
break 2;
}
}
if (microtime(true) - $start > 2) {
break;
}
}
echo "Done\n";
?>
--EXPECTF--
Warning: gmp_random_bits() expects exactly 1 parameter, 0 given in %s on line %d
NULL
Warning: gmp_random_bits(): The number of bits must be positive in %s on line %d
bool(false)
Warning: gmp_random_bits(): The number of bits must be positive in %s on line %d
bool(false)
Done

View File

@@ -0,0 +1,81 @@
--TEST--
gmp_random_range() basic tests
--SKIPIF--
<?php if (!extension_loaded("gmp")) print "skip"; ?>
--FILE--
<?php
$minusTen = gmp_init(-1);
$plusTen = gmp_init(1);
$zero = gmp_init(0);
var_dump(gmp_random_range());
var_dump(gmp_random_range(10));
var_dump(gmp_random_range(10, -10));
var_dump(gmp_random_range($plusTen, $minusTen));
var_dump(gmp_random_range($plusTen, $zero));
// If these error the test fails.
gmp_random_range(0, 10);
gmp_random_range(1, 10);
gmp_random_range(-1, 10);
gmp_random_range(-10, 0);
gmp_random_range(-10, -1);
gmp_random_range(0, $plusTen);
gmp_random_range(1, $plusTen);
gmp_random_range(-1, $plusTen);
gmp_random_range($zero, $plusTen);
gmp_random_range($minusTen, $plusTen);
// 2 seconds to make sure the numbers stay in range
$start = microtime(true);
while (1) {
for ($i = 0; $i < 5000; $i++) {
$result = gmp_random_range(0, 1000);
if ($result < 0 || $result > 1000) {
print "RANGE VIOLATION 1\n";
var_dump($result);
break 2;
}
$result = gmp_random_range(-1000, 0);
if ($result < -1000 || $result > 0) {
print "RANGE VIOLATION 2\n";
var_dump($result);
break 2;
}
$result = gmp_random_range(-500, 500);
if ($result < -500 || $result > 500) {
print "RANGE VIOLATION 3\n";
var_dump($result);
break 2;
}
}
if (microtime(true) - $start > 2) {
break;
}
}
echo "Done\n";
?>
--EXPECTF--
Warning: gmp_random_range() expects exactly 2 parameters, 0 given in %s on line %d
NULL
Warning: gmp_random_range() expects exactly 2 parameters, 1 given in %s on line %d
NULL
Warning: gmp_random_range(): The minimum value must be less than the maximum value in %s on line %d
bool(false)
Warning: gmp_random_range(): The minimum value must be less than the maximum value in %s on line %d
bool(false)
Warning: gmp_random_range(): The minimum value must be less than the maximum value in %s on line %d
bool(false)
Done

View File

@@ -58,12 +58,17 @@ dnl
AC_CACHE_CHECK([whether whether compiler supports Decimal32/64/128 types], ac_cv_decimal_fp_supported,[
AC_TRY_RUN( [
#include <stdio.h>
#include <string.h>
int main(int argc, char **argv) {
typedef float dec32 __attribute__((mode(SD)));
dec32 k = 99.49f;
double d2 = (double)k;
return 0;
const char *check_str = "99.49";
char print_str[32];
snprintf(print_str, 32, "%f", d2);
return memcmp(print_str, check_str, 5);
}
],[
ac_cv_decimal_fp_supported=yes

View File

@@ -951,14 +951,15 @@ int odbc_bindcols(odbc_result *result TSRMLS_DC)
SQLUSMALLINT colfieldid;
int charextraalloc;
colfieldid = SQL_COLUMN_DISPLAY_SIZE;
charextraalloc = 0;
result->values = (odbc_result_value *) safe_emalloc(sizeof(odbc_result_value), result->numcols, 0);
result->longreadlen = ODBCG(defaultlrl);
result->binmode = ODBCG(defaultbinmode);
for(i = 0; i < result->numcols; i++) {
charextraalloc = 0;
colfieldid = SQL_COLUMN_DISPLAY_SIZE;
rc = SQLColAttributes(result->stmt, (SQLUSMALLINT)(i+1), SQL_COLUMN_NAME,
result->values[i].name, sizeof(result->values[i].name), &colnamelen, 0);
rc = SQLColAttributes(result->stmt, (SQLUSMALLINT)(i+1), SQL_COLUMN_TYPE,

View File

@@ -0,0 +1,57 @@
--TEST--
odbc_exec(): Getting accurate date data from query
--SKIPIF--
<?php include 'skipif.inc'; ?>
--FILE--
<?php
include 'config.inc';
$id_1_date = '2014-09-23';
$id_2_date = '2014-09-24';
$conn = odbc_connect($dsn, $user, $pass);
@odbc_exec($conn, 'CREATE DATABASE odbcTEST');
odbc_exec($conn, 'CREATE TABLE FOO (ID INT, VARCHAR_COL VARCHAR(100), DATE_COL DATE)');
odbc_exec($conn, "INSERT INTO FOO(ID, VARCHAR_COL, DATE_COL) VALUES (1, 'hello', '$id_1_date')");
odbc_exec($conn, "INSERT INTO FOO(ID, VARCHAR_COL, DATE_COL) VALUES (2, 'helloagain', '$id_2_date')");
$res = odbc_exec($conn, 'SELECT * FROM FOO ORDER BY ID ASC');
while(odbc_fetch_row($res)) {
$id = odbc_result($res, "ID");
$varchar_col = odbc_result($res, "VARCHAR_COL");
$date = odbc_result($res, "DATE_COL");
if ($id == 1) {
if ($date != $id_1_date) {
print "Date_1 mismatched\n";
} else {
print "Date_1 matched\n";
}
} else {
if ($date != $id_2_date) {
print "Date_2 mismatched\n";
} else {
print "Date_2 matched\n";
}
}
}
?>
--EXPECT--
Date_1 matched
Date_2 matched
--CLEAN--
<?php
include 'config.inc';
$conn = odbc_connect($dsn, $user, $pass);
odbc_exec($conn, 'DROP TABLE FOO');
odbc_exec($conn, 'DROP DATABASE odbcTEST');
?>

View File

@@ -252,6 +252,9 @@ if (ZEND_OPTIMIZER_PASS_1 & OPTIMIZATION_LEVEL) {
break;
}
}
if (Z_TYPE(c) == IS_CONSTANT_AST) {
break;
}
literal_dtor(&ZEND_OP2_LITERAL(opline));
MAKE_NOP(opline);
replace_tmp_by_const(op_array, opline, tv, &c TSRMLS_CC);
@@ -303,6 +306,9 @@ if (ZEND_OPTIMIZER_PASS_1 & OPTIMIZATION_LEVEL) {
Z_STRVAL(ZEND_OP2_LITERAL(opline)),
Z_STRLEN(ZEND_OP2_LITERAL(opline)) + 1,
(void **) &c) == SUCCESS) {
if (Z_TYPE_PP(c) == IS_CONSTANT_AST) {
break;
}
if (ZEND_IS_CONSTANT_TYPE(Z_TYPE_PP(c))) {
if (!zend_get_persistent_constant(Z_STRVAL_PP(c), Z_STRLEN_PP(c), &t, 1 TSRMLS_CC) ||
ZEND_IS_CONSTANT_TYPE(Z_TYPE(t))) {

View File

@@ -0,0 +1,19 @@
--TEST--
Bug #68104 (Segfault while pre-evaluating a disabled function)
--CREDITS--
manuel <manuel@mausz.at>
--INI--
opcache.enable=1
opcache.enable_cli=1
disable_functions=dl
--SKIPIF--
<?php require_once('skipif.inc'); ?>
--FILE--
<?php
var_dump(is_callable("dl"));
dl("a.so");
?>
--EXPECTF--
bool(true)
Warning: dl() has been disabled for security reasons in %sbug68104.php on line %d

View File

@@ -1,28 +1,32 @@
-----BEGIN CERTIFICATE-----
MIICCTCCAXICCQCx2JwIhbRefzANBgkqhkiG9w0BAQUFADBJMQswCQYDVQQGEwJT
RzESMBAGA1UECBMJVGVzdHZpbGxlMREwDwYDVQQKEwhkYXRpYmJhdzETMBEGA1UE
AxQKKi50ZXN0LmNvbTAeFw0xNDA5MjQxMTMzNTRaFw0yNDA5MjExMTMzNTRaMEkx
CzAJBgNVBAYTAlNHMRIwEAYDVQQIEwlUZXN0dmlsbGUxETAPBgNVBAoTCGRhdGli
YmF3MRMwEQYDVQQDFAoqLnRlc3QuY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCB
iQKBgQDBnR8DYzsN90kISI87kBvw40TQknS7/fuymWCmSrtRQLED8p2QL8PiYCZ8
UdcFVsv+di7MJvUOzW6dRo2DCu8Rojx3ML8dAtPsQkDdaCXDnOvCTQCAqFmxa1A9
c5kp0hbzCrucKGckb355A4NumFgX1fjQ705MfjGPgQef1ZtozQIDAQABMA0GCSqG
SIb3DQEBBQUAA4GBAGP07nJo0pI4FdsXuAHWr97XxV4EhHopFMw6svOZ3UtsRzmW
ScmmMdgd3c8ciVxOsztgnzvFq/nrUkw/3n/Xz/gtE7kZt9aS18SnCyyHPJcXmmUE
NsbyZ/7srIqCSrxUkP+N//nToqHxg1pqA/A8RzOOQUAp+UIVF6Zl/kkFNgt8
-----END CERTIFICATE-----
-----BEGIN RSA PRIVATE KEY-----
MIICXgIBAAKBgQDBnR8DYzsN90kISI87kBvw40TQknS7/fuymWCmSrtRQLED8p2Q
L8PiYCZ8UdcFVsv+di7MJvUOzW6dRo2DCu8Rojx3ML8dAtPsQkDdaCXDnOvCTQCA
qFmxa1A9c5kp0hbzCrucKGckb355A4NumFgX1fjQ705MfjGPgQef1ZtozQIDAQAB
AoGADAnkAsbpxh2JKf2xAkgcpKbNAZcJsSLCwsEstEpTSWMXXqJ4T53YtTu7SOGh
2BAkkQbyM/l8JVZ6uUbIx8wnPzqAuB2hEDQHKZVyftDyJh+54Uyz0xV0JdWGWrFh
A+uDt/Zncx2g+qlkQG5J5nHnrd9OAns89wJXpBWA6twlsuECQQD/HC4wxOJzh1XI
YSWHWQulOnlNgZ2zERfmJeRfJ0ncmDOV2ofxOFQ+dMJ36XghPaH52KdxqWI1yQaE
yesx8ygFAkEAwkoF4lBuYdsXucJNDYf8o9MlBvazoriH0y26B/YozJ7iAEFqVvcC
TN+iKDIyiRALwR6a3nzhyFYJ4xyzgSIAKQJBAMnw3seQMsnM6aTS8cgwPr2uifNG
lTT4ZPi0KhEAosFSYhNPh6j1NAq0lnQhhgyaIywJypJ4yNtWpChdRiamGpkCQQDB
iUExPpOmMLwCk7VzrCmS+6pftHIevpi2WU99zMy5f+969665MFb/QqniRpamh/Bd
kGIPDPFQQbyZmqaJFNh5AkEAzy0YVbUT3C/QvstPr5i7ztj7WiW/1zJMamFwY/ZS
1J7e7lqHgRICie5uv1Yvh3w/qmV/7lTLhmlQZd9SJMpXhg==
MIICXgIBAAKBgQDU8RgB8O2uR3ApjlxEX5rpCI+gIaZ3h0RBAF9rNA/s0pPTtX/e
NGJgDyuT/TF6mcv0I/0/s2WSmIE50NW6tgWZ7RoBdVw/MiByPt6vK1aDrggbycN/
C6RrxrEsdZe3E9CDZCFM1br8/8tnV19Ju80g8zY2MgDjAjSkeXN5yp3kgQIDAQAB
AoGBANFKKRt3TlRVmHLvndYB1YKmzGtJx5CBXV85247FO8W67lpNcGDYQbxCDMXG
PARQ9vl9CeK7EuDzjUdi7z40uujUOJtsLbMP6ikwKFi/tA2cW1yoLionZ3JkfyEr
4Uu8kkkIut0VLX8uuVz/Y03lt8Uzc+GvD2DPhkSQn80f10SFAkEA94EcjwFcwuVi
QofgOPbf7qfOoWDsXYhlMU9g1CaPJiMcMcvgoLK3V514oMDxlkvuLujlYeG9NvRS
tREluGsbywJBANxARX5MSzAkFRNZNZKDUvifdC0BA2Dqzd2iOJRcTdcebGENd7+e
oub/9lVLGrX7T4U2en8IXwJV4UHxwoQLz2MCQQCI1Bj8ui0VFgj/bOy5sUnVP3IN
Z27kuo3u98o5HuQOmmRw5xxU2thfGJBilqg4hdu0lU6SkWCwq9u5fDRVQumHAkAM
mJBg3LQgGLAr3xo1OtVv6o6WVEyBKmyDlFdwBKde+hpwoniKuOPQGitYTWdFqQ2v
LKJsyWnFlGvBfbYGHzbJAkEA17SgCf7Wx7NxuLCSMj/rd25ul0jlIrjx6+/HfyLb
+T2SXXU4g2DBiPngrfJ9jX8QGoLpZiBGcwX3QxssX5FgJQ==
-----END RSA PRIVATE KEY-----
-----BEGIN CERTIFICATE-----
MIICvDCCAiWgAwIBAgIJANOyJnvPEioVMA0GCSqGSIb3DQEBBQUAMEkxCzAJBgNV
BAYTAlNHMRIwEAYDVQQIEwlUZXN0dmlsbGUxETAPBgNVBAoTCGRhdGliYmF3MRMw
EQYDVQQDFAoqLnRlc3QuY29tMB4XDTE0MTAxNTEzMDg1OFoXDTM0MTAxMDEzMDg1
OFowSTELMAkGA1UEBhMCU0cxEjAQBgNVBAgTCVRlc3R2aWxsZTERMA8GA1UEChMI
ZGF0aWJiYXcxEzARBgNVBAMUCioudGVzdC5jb20wgZ8wDQYJKoZIhvcNAQEBBQAD
gY0AMIGJAoGBANTxGAHw7a5HcCmOXERfmukIj6AhpneHREEAX2s0D+zSk9O1f940
YmAPK5P9MXqZy/Qj/T+zZZKYgTnQ1bq2BZntGgF1XD8yIHI+3q8rVoOuCBvJw38L
pGvGsSx1l7cT0INkIUzVuvz/y2dXX0m7zSDzNjYyAOMCNKR5c3nKneSBAgMBAAGj
gaswgagwHQYDVR0OBBYEFErHO0eHLp9YvBWVvvhty/jGie5wMHkGA1UdIwRyMHCA
FErHO0eHLp9YvBWVvvhty/jGie5woU2kSzBJMQswCQYDVQQGEwJTRzESMBAGA1UE
CBMJVGVzdHZpbGxlMREwDwYDVQQKEwhkYXRpYmJhdzETMBEGA1UEAxQKKi50ZXN0
LmNvbYIJANOyJnvPEioVMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADgYEA
gMv2HUUp0FMTYQ6tL9YgNUNARukxJzGDWweo4/YuNSgI+Ljpye4Nf1MpyDWfhZGc
QbUhfm5CdEvcBzZBtI0lLXs61yGdLnDH/6QHViXP2rlH0yeAABw8+wSdxuiZN1yR
ed4pNXU+tczgW2Ri2+T0ScOZd0XommKHrQnu2T9mMBY=
-----END CERTIFICATE-----

View File

@@ -1807,59 +1807,13 @@ static size_t php_openssl_sockop_write(php_stream *stream, const char *buf, size
}
/* }}} */
static void php_openssl_stream_wait_for_data(php_netstream_data_t *sock)
{
int retval;
struct timeval *ptimeout;
if (sock->socket == -1) {
return;
}
sock->timeout_event = 0;
if (sock->timeout.tv_sec == -1)
ptimeout = NULL;
else
ptimeout = &sock->timeout;
while(1) {
retval = php_pollfd_for(sock->socket, PHP_POLLREADABLE, ptimeout);
if (retval == 0)
sock->timeout_event = 1;
if (retval >= 0)
break;
if (php_socket_errno() != EINTR)
break;
}
}
static size_t php_openssl_sockop_read(php_stream *stream, char *buf, size_t count TSRMLS_DC) /* {{{ */
{
php_openssl_netstream_data_t *sslsock = (php_openssl_netstream_data_t*)stream->abstract;
php_netstream_data_t *sock;
int nr_bytes = 0;
if (sslsock->ssl_active) {
int retry = 1;
sock = (php_netstream_data_t*)stream->abstract;
/* The SSL_read() function will block indefinitely waiting for data on a blocking
socket. If we don't poll for readability first this operation has the potential
to hang forever. To avoid this scenario we poll with a timeout before performing
the actual read. If it times out we're finished.
*/
if (sock->is_blocked && SSL_pending(sslsock->ssl_handle) == 0) {
php_openssl_stream_wait_for_data(sock);
if (sock->timeout_event) {
stream->eof = 1;
php_error_docref(NULL TSRMLS_CC, E_WARNING, "SSL read operation timed out");
return nr_bytes;
}
}
do {
nr_bytes = SSL_read(sslsock->ssl_handle, buf, count);
@@ -2179,21 +2133,6 @@ static int php_openssl_sockop_cast(php_stream *stream, int castas, void **ret TS
case PHP_STREAM_AS_FD_FOR_SELECT:
if (ret) {
/* OpenSSL has an internal buffer which select() cannot see. If we don't
* fetch it into the stream's buffer, no activity will be reported on the
* stream even though there is data waiting to be read - but we only fetch
* the lower of bytes OpenSSL has ready to give us or chunk_size since we
* weren't asked for any data at this stage. This is only likely to cause
* issues with non-blocking streams, but it's harmless to always do it. */
size_t pending;
if (stream->writepos == stream->readpos
&& sslsock->ssl_active
&& (pending = (size_t)SSL_pending(sslsock->ssl_handle)) > 0) {
php_stream_fill_read_buffer(stream, pending < stream->chunk_size
? pending
: stream->chunk_size);
}
*(php_socket_t *)ret = sslsock->s.socket;
}
return SUCCESS;

View File

@@ -465,6 +465,15 @@ static int pdo_pgsql_check_liveness(pdo_dbh_t *dbh TSRMLS_DC)
}
/* }}} */
static int pgsql_handle_in_transaction(pdo_dbh_t *dbh TSRMLS_DC)
{
pdo_pgsql_db_handle *H;
H = (pdo_pgsql_db_handle *)dbh->driver_data;
return PQtransactionStatus(H->server) > PQTRANS_IDLE;
}
static int pdo_pgsql_transaction_cmd(const char *cmd, pdo_dbh_t *dbh TSRMLS_DC)
{
pdo_pgsql_db_handle *H = (pdo_pgsql_db_handle *)dbh->driver_data;
@@ -489,7 +498,15 @@ static int pgsql_handle_begin(pdo_dbh_t *dbh TSRMLS_DC)
static int pgsql_handle_commit(pdo_dbh_t *dbh TSRMLS_DC)
{
return pdo_pgsql_transaction_cmd("COMMIT", dbh TSRMLS_CC);
int ret = pdo_pgsql_transaction_cmd("COMMIT", dbh TSRMLS_CC);
/* When deferred constraints are used the commit could
fail, and a ROLLBACK implicitly ran. See bug #67462 */
if (!ret) {
dbh->in_txn = pgsql_handle_in_transaction(dbh TSRMLS_CC);
}
return ret;
}
static int pgsql_handle_rollback(pdo_dbh_t *dbh TSRMLS_DC)
@@ -497,15 +514,6 @@ static int pgsql_handle_rollback(pdo_dbh_t *dbh TSRMLS_DC)
return pdo_pgsql_transaction_cmd("ROLLBACK", dbh TSRMLS_CC);
}
static int pgsql_handle_in_transaction(pdo_dbh_t *dbh TSRMLS_DC)
{
pdo_pgsql_db_handle *H;
H = (pdo_pgsql_db_handle *)dbh->driver_data;
return PQtransactionStatus(H->server);
}
/* {{{ proto string PDO::pgsqlCopyFromArray(string $table_name , array $rows [, string $delimiter [, string $null_as ] [, string $fields])
Returns true if the copy worked fine or false if error */
static PHP_METHOD(PDO, pgsqlCopyFromArray)
@@ -1058,10 +1066,16 @@ static PHP_METHOD(PDO, pgsqlGetNotify)
if (result_type == PDO_FETCH_NUM || result_type == PDO_FETCH_BOTH) {
add_index_string(return_value, 0, pgsql_notify->relname, 1);
add_index_long(return_value, 1, pgsql_notify->be_pid);
if (pgsql_notify->extra && pgsql_notify->extra[0]) {
add_index_string(return_value, 2, pgsql_notify->extra, 1);
}
}
if (result_type == PDO_FETCH_ASSOC || result_type == PDO_FETCH_BOTH) {
add_assoc_string(return_value, "message", pgsql_notify->relname, 1);
add_assoc_long(return_value, "pid", pgsql_notify->be_pid);
if (pgsql_notify->extra && pgsql_notify->extra[0]) {
add_assoc_string(return_value, "payload", pgsql_notify->extra, 1);
}
}
PQfreemem(pgsql_notify);

View File

@@ -297,7 +297,7 @@ static int pgsql_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_data *
sizeof(Oid));
}
if (param->paramno >= 0) {
if (param->paramno > zend_hash_num_elements(stmt->bound_param_map)) {
if (param->paramno >= zend_hash_num_elements(stmt->bound_param_map)) {
pdo_pgsql_error_stmt(stmt, PGRES_FATAL_ERROR, "HY105");
return 0;
}

View File

@@ -0,0 +1,66 @@
--TEST--
PDO PgSQL Bug #66584 (Segmentation fault on statement deallocation)
--SKIPIF--
<?php
if (!extension_loaded('pdo') || !extension_loaded('pdo_pgsql')) die('skip not loaded');
require dirname(__FILE__) . '/config.inc';
require dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc';
PDOTest::skip();
?>
--FILE--
<?php
require dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc';
$pdo = PDOTest::test_factory(dirname(__FILE__) . '/common.phpt');
$pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
$pdo->beginTransaction();
$pdo->query("CREATE TABLE b66584 (a int)");
$pdo->query("INSERT INTO b66584 VALUES (165)");
for ($i = 1; $i >= 0; $i--) {
$pdo->setAttribute(\PDO::ATTR_EMULATE_PREPARES, (bool)$i);
try {
run($pdo, [0 => 1, 2 => 165, 5 => 3]);
} catch (\Exception $e) {
var_dump($e->getMessage());
}
try {
run($pdo, json_decode('{"0":234,"1":165,"2":221,"3":207,"4":188,"5":216,"6":1150,"7":916,"8":967,"9":987,"10":951,"11":990,"12":959,"13":896,"14":947,"15":877,"16":1000,"17":1023,"18":904,"19":856,"20":860,"21":866,"22":930,"23":974,"24":1032,"25":1016,"26":1050,"27":1059,"28":1040,"29":1064,"30":1004,"31":214,"32":189,"33":166,"34":1002,"35":167,"36":191,"37":859,"38":204,"39":181,"40":1001,"42":208,"43":198,"44":177,"45":1003,"46":858,"47":190,"48":162,"49":210,"50":171,"51":197,"52":168,"53":194,"54":209,"55":200,"56":192,"57":180,"58":232,"59":222,"60":163,"61":196,"62":217,"64":176,"65":193,"66":172,"67":195,"68":170,"69":173,"70":233,"71":223,"72":218,"73":186,"74":175,"75":224,"76":205,"77":211,"78":235,"79":1101,"80":225,"81":236,"82":1102,"83":1164,"84":1083,"85":1005,"86":861,"87":1179,"88":960,"89":991,"90":1187,"91":880,"92":1149,"93":1033,"94":931,"95":1006,"96":862,"97":1151,"98":917,"99":881,"100":1148,"101":1065,"102":867,"103":952,"104":1152,"105":918,"106":961,"107":1180,"108":992,"109":1188,"110":932,"111":933,"112":968,"113":868,"114":882,"115":1147,"116":1017,"117":1131,"118":1174,"119":1178,"120":1186,"121":869,"122":1051,"123":934,"124":969,"125":975,"126":1066,"127":237,"128":953,"129":1024,"130":1146,"131":883,"132":1145,"133":884,"134":885,"135":1144,"136":886,"137":1143,"138":1025,"139":897,"140":898,"141":899,"142":1026,"143":1142,"144":887,"145":1141,"146":888,"147":889,"148":1140,"149":1189,"150":993,"151":1139,"152":890,"153":1138,"154":891,"155":900,"156":892,"157":1137,"158":1027,"159":901,"160":1136,"161":893,"162":870,"163":1052,"164":954,"165":1041,"166":1018,"167":1165,"168":1084,"169":962,"170":1181,"171":994,"172":1190,"173":1042,"174":935,"175":226,"176":871,"177":1191,"178":995,"179":977,"180":948,"181":1175,"182":1053,"183":955,"184":1182,"185":963,"186":1067,"187":919,"188":1153,"189":920,"190":1154,"191":1055,"192":1054,"193":1056,"194":863,"195":872,"196":1028,"197":921,"198":1155,"199":936,"200":970,"201":1019,"202":1166,"203":1085,"204":1135,"205":894,"206":1034,"207":905,"208":873,"209":937,"210":902,"211":1029,"212":1007,"213":864,"214":1043,"215":1057,"216":956,"217":957,"218":939,"219":1086,"220":1167,"221":1087,"222":1168,"223":1173,"224":1108,"225":978,"226":1044,"227":1183,"228":964,"229":965,"230":1184,"231":1045,"232":874,"233":940,"234":1046,"235":979,"236":903,"237":980,"238":1156,"239":922,"240":1035,"241":906,"242":971,"243":972,"244":878,"245":1134,"246":879,"247":1133,"248":907,"249":1036,"250":908,"251":1132,"252":895,"253":909,"254":1060,"255":981,"256":1068,"257":996,"258":1192,"259":941,"260":865,"261":1008,"262":910,"263":997,"264":1193,"265":982,"266":942,"267":1020,"268":983,"269":1061,"270":949,"271":1176,"272":875,"273":911,"274":1069,"275":1157,"276":923,"277":1158,"278":924,"279":988,"280":984,"281":925,"282":1159,"283":1062,"284":1047,"285":1194,"286":998,"287":1021,"288":1030,"289":1031,"290":1070,"291":1088,"292":1169,"293":958,"294":1195,"295":999,"296":966,"297":1185,"298":944,"299":945,"300":1022,"301":1103,"302":220,"303":1099,"304":1048,"305":927,"306":1161,"307":989,"308":973,"309":1071,"310":1074,"311":1072,"312":1073,"313":912,"314":1037,"315":913,"316":914,"317":1177,"318":950,"319":1049,"320":876,"321":985,"322":915,"323":1038,"324":946,"325":1089,"326":1170,"327":1090,"328":1171,"329":1091,"330":1172,"331":1063,"332":986,"333":928,"334":1162,"335":929,"336":1163,"337":976,"338":231,"339":201,"340":1098,"341":215}', true));
} catch (\Exception $e) {
var_dump($e->getMessage());
}
}
try {
$pdo->query("DROP TABLE b66584");
$pdo->rollback();
} catch (\Exception $e) {
}
function run($pdo, $data)
{
$bind = join(', ', array_fill(0, count($data), '?'));
$stmt = $pdo->prepare("SELECT COUNT(*) FROM b66584 WHERE a IN ({$bind})");
var_dump(count($data));
$stmt->execute($data);
var_dump($stmt->fetchColumn());
}
?>
--EXPECTF--
int(3)
string(%d) "SQLSTATE%s"
int(340)
string(%d) "SQLSTATE%s"
int(3)
string(%d) "SQLSTATE%s"
int(340)
string(%d) "SQLSTATE%s"

View File

@@ -0,0 +1,34 @@
--TEST--
PDO PgSQL Bug #67462 (PDO_PGSQL::beginTransaction() wrongly throws exception when not in transaction)
--SKIPIF--
<?php
if (!extension_loaded('pdo') || !extension_loaded('pdo_pgsql')) die('skip not loaded');
require dirname(__FILE__) . '/config.inc';
require dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc';
PDOTest::skip();
?>
--FILE--
<?php
require dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc';
$pdo = PDOTest::test_factory(dirname(__FILE__) . '/common.phpt');
$pdo->setAttribute (\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
$pdo->beginTransaction();
try {
$pdo->query("CREATE TABLE b67462 (a int NOT NULL PRIMARY KEY DEFERRABLE INITIALLY DEFERRED)");
$pdo->query("INSERT INTO b67462 VALUES (1), (1)");
var_dump($pdo->inTransaction());
$pdo->commit(); // This should fail!
} catch (\Exception $e) {
var_dump($pdo->inTransaction());
var_dump($pdo->beginTransaction());
}
?>
--EXPECT--
bool(true)
bool(false)
bool(true)

View File

@@ -0,0 +1,109 @@
--TEST--
Bug #68199 (PDO::pgsqlGetNotify doesn't support NOTIFY payloads)
--SKIPIF--
<?php # vim:se ft=php:
if (!extension_loaded('pdo') || !extension_loaded('pdo_pgsql')) die('skip not loaded');
require dirname(__FILE__) . '/config.inc';
require dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc';
PDOTest::skip();
$db = PDOTest::factory();
if (version_compare($db->getAttribute(PDO::ATTR_SERVER_VERSION), '9.0.0') < 0) {
die("skip Requires 9.0+");
}
?>
--FILE--
<?php
require dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc';
$db = PDOTest::test_factory(dirname(__FILE__) . '/common.phpt');
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
// pgsqlGetPid should return something meaningful
$pid = $db->pgsqlGetPid();
var_dump($pid > 0);
// No listen, no notifies
var_dump($db->pgsqlGetNotify());
// Listen started, no notifies
$db->exec("LISTEN notifies_phpt");
var_dump($db->pgsqlGetNotify());
// No parameters with payload, use default PDO::FETCH_NUM
$db->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_NUM);
$db->exec("NOTIFY notifies_phpt, 'payload'");
$notify = $db->pgsqlGetNotify();
var_dump(count($notify));
var_dump($notify[0]);
var_dump($notify[1] == $pid);
var_dump($notify[2]);
// No parameters with payload, use default PDO::FETCH_ASSOC
$db->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
$db->exec("NOTIFY notifies_phpt, 'payload'");
$notify = $db->pgsqlGetNotify();
var_dump(count($notify));
var_dump($notify['message']);
var_dump($notify['pid'] == $pid);
var_dump($notify['payload']);
// Test PDO::FETCH_NUM as parameter with payload
$db->exec("NOTIFY notifies_phpt, 'payload'");
$notify = $db->pgsqlGetNotify(PDO::FETCH_NUM);
var_dump(count($notify));
var_dump($notify[0]);
var_dump($notify[1] == $pid);
var_dump($notify[2]);
// Test PDO::FETCH_ASSOC as parameter with payload
$db->exec("NOTIFY notifies_phpt, 'payload'");
$notify = $db->pgsqlGetNotify(PDO::FETCH_ASSOC);
var_dump(count($notify));
var_dump($notify['message']);
var_dump($notify['pid'] == $pid);
var_dump($notify['payload']);
// Test PDO::FETCH_BOTH as parameter with payload
$db->exec("NOTIFY notifies_phpt, 'payload'");
$notify = $db->pgsqlGetNotify(PDO::FETCH_BOTH);
var_dump(count($notify));
var_dump($notify['message']);
var_dump($notify['pid'] == $pid);
var_dump($notify['payload']);
var_dump($notify[0]);
var_dump($notify[1] == $pid);
var_dump($notify[2]);
// Verify that there are no notifies queued
var_dump($db->pgsqlGetNotify());
?>
--EXPECT--
bool(true)
bool(false)
bool(false)
int(3)
string(13) "notifies_phpt"
bool(true)
string(7) "payload"
int(3)
string(13) "notifies_phpt"
bool(true)
string(7) "payload"
int(3)
string(13) "notifies_phpt"
bool(true)
string(7) "payload"
int(3)
string(13) "notifies_phpt"
bool(true)
string(7) "payload"
int(6)
string(13) "notifies_phpt"
bool(true)
string(7) "payload"
string(13) "notifies_phpt"
bool(true)
string(7) "payload"
bool(false)

View File

@@ -1,10 +1,12 @@
<?php
// These vars are used to connect db and create test table.
// values can be set to meet your environment
// "test" database must be existed. i.e. "createdb test" before testing
// PostgreSQL uses login name as username, user must have access to "test" database.
$conn_str = "host=localhost dbname=test port=5432"; // connection string
// These vars are used to connect db and create test table.
// values can be set to meet your environment with the
// environment var PGSQL_TEST_CONNSTR
// "test" database must exist. i.e. "createdb test" before testing
$conn_str = getenv('PGSQL_TEST_CONNSTR') ?: "host=localhost dbname=test port=5432"; // connection string
$table_name = "php_pgsql_test"; // test table that will be created
$table_name_92 = "php_pgsql_test_92"; // test table that will be created
$num_test_record = 1000; // Number of records to create

View File

@@ -3356,6 +3356,7 @@ static zend_op_array *phar_compile_file(zend_file_handle *file_handle, int type
zend_try {
failed = 0;
CG(zend_lineno) = 0;
res = phar_orig_compile_file(file_handle, type TSRMLS_CC);
} zend_catch {
failed = 1;

View File

@@ -6098,7 +6098,7 @@ ZEND_END_ARG_INFO()
static const zend_function_entry reflection_zend_extension_functions[] = {
ZEND_ME(reflection, __clone, arginfo_reflection__void, ZEND_ACC_PRIVATE|ZEND_ACC_FINAL)
ZEND_ME(reflection_zend_extension, export, arginfo_reflection_extension_export, ZEND_ACC_STATIC|ZEND_ACC_PUBLIC)
ZEND_ME(reflection_zend_extension, __construct, arginfo_reflection_extension___construct, 0)
ZEND_ME(reflection_zend_extension, __construct, arginfo_reflection_zend_extension___construct, 0)
ZEND_ME(reflection_zend_extension, __toString, arginfo_reflection__void, 0)
ZEND_ME(reflection_zend_extension, getName, arginfo_reflection__void, 0)
ZEND_ME(reflection_zend_extension, getVersion, arginfo_reflection__void, 0)

View File

@@ -49,6 +49,41 @@ static inline int spl_instantiate_arg_ex2(zend_class_entry *pce, zval **retval,
}
/* }}} */
/* {{{ spl_instantiate_arg_n */
static inline void spl_instantiate_arg_n(zend_class_entry *pce, zval **retval, int argc, zval ***argv TSRMLS_DC)
{
zend_function *func = pce->constructor;
zend_fcall_info fci;
zend_fcall_info_cache fcc;
zval *dummy;
zval z_name;
spl_instantiate(pce, retval, 0 TSRMLS_CC);
ZVAL_STRING(&z_name, func->common.function_name, 0);
fci.size = sizeof(zend_fcall_info);
fci.function_table = &pce->function_table;
fci.function_name = &z_name;
fci.object_ptr = *retval;
fci.symbol_table = NULL;
fci.retval_ptr_ptr = &dummy;
fci.param_count = argc;
fci.params = argv;
fci.no_separation = 1;
fcc.initialized = 1;
fcc.function_handler = func;
fcc.calling_scope = EG(scope);
fcc.called_scope = pce;
fcc.object_ptr = *retval;
zend_call_function(&fci, &fcc TSRMLS_CC);
zval_ptr_dtor(&dummy);
}
/* }}} */
#endif /* SPL_ENGINE_H */
/*

View File

@@ -2045,8 +2045,10 @@ SPL_METHOD(RegexIterator, accept)
if (intern->current.data == NULL) {
RETURN_FALSE;
} else if (Z_TYPE_P(intern->current.data) == IS_ARRAY) {
RETURN_FALSE;
}
if (intern->u.regex.flags & REGIT_USE_KEY) {
subject_ptr = intern->current.key;
} else {
@@ -2080,8 +2082,7 @@ SPL_METHOD(RegexIterator, accept)
ALLOC_INIT_ZVAL(intern->current.data);
php_pcre_match_impl(intern->u.regex.pce, subject, subject_len, &zcount,
intern->current.data, intern->u.regex.mode == REGIT_MODE_ALL_MATCHES, intern->u.regex.use_flags, intern->u.regex.preg_flags, 0 TSRMLS_CC);
count = zend_hash_num_elements(Z_ARRVAL_P(intern->current.data));
RETVAL_BOOL(count > 0);
RETVAL_BOOL(Z_LVAL(zcount) > 0);
break;
case REGIT_MODE_SPLIT:
@@ -2259,7 +2260,7 @@ SPL_METHOD(RecursiveRegexIterator, __construct)
SPL_METHOD(RecursiveRegexIterator, getChildren)
{
spl_dual_it_object *intern;
zval *retval, *regex;
zval *retval;
if (zend_parse_parameters_none() == FAILURE) {
return;
@@ -2269,16 +2270,61 @@ SPL_METHOD(RecursiveRegexIterator, getChildren)
zend_call_method_with_0_params(&intern->inner.zobject, intern->inner.ce, NULL, "getchildren", &retval);
if (!EG(exception)) {
zval **args[5], *object, *regex, *mode, *flags, *preg_flags;
MAKE_STD_ZVAL(object);
MAKE_STD_ZVAL(regex);
MAKE_STD_ZVAL(mode);
MAKE_STD_ZVAL(flags);
MAKE_STD_ZVAL(preg_flags);
MAKE_COPY_ZVAL(&retval, object);
ZVAL_STRING(regex, intern->u.regex.regex, 1);
spl_instantiate_arg_ex2(Z_OBJCE_P(getThis()), &return_value, 0, retval, regex TSRMLS_CC);
ZVAL_LONG(mode, intern->u.regex.mode);
ZVAL_LONG(flags, intern->u.regex.flags);
ZVAL_LONG(preg_flags, intern->u.regex.preg_flags);
args[0] = &object;
args[1] = &regex;
args[2] = &mode;
args[3] = &flags;
args[4] = &preg_flags;
spl_instantiate_arg_n(Z_OBJCE_P(getThis()), &return_value, 5, args TSRMLS_CC);
zval_ptr_dtor(&object);
zval_ptr_dtor(&regex);
zval_ptr_dtor(&mode);
zval_ptr_dtor(&flags);
zval_ptr_dtor(&preg_flags);
}
if (retval) {
zval_ptr_dtor(&retval);
}
} /* }}} */
SPL_METHOD(RecursiveRegexIterator, accept)
{
spl_dual_it_object *intern;
zval *rv;
if (zend_parse_parameters_none() == FAILURE) {
return;
}
SPL_FETCH_AND_CHECK_DUAL_IT(intern, getThis());
if (intern->current.data == NULL) {
RETURN_FALSE;
} else if (Z_TYPE_P(intern->current.data) == IS_ARRAY) {
RETURN_BOOL(zend_hash_num_elements(Z_ARRVAL_P(intern->current.data)) > 0);
}
zend_call_method_with_0_params(&(getThis()), spl_ce_RegexIterator, NULL, "accept", &rv);
RETURN_ZVAL(rv, 1, 1);
}
#endif
/* {{{ spl_dual_it_dtor */
@@ -2469,6 +2515,7 @@ ZEND_END_ARG_INFO();
static const zend_function_entry spl_funcs_RecursiveRegexIterator[] = {
SPL_ME(RecursiveRegexIterator, __construct, arginfo_rec_regex_it___construct, ZEND_ACC_PUBLIC)
SPL_ME(RecursiveRegexIterator, accept, arginfo_recursive_it_void, ZEND_ACC_PUBLIC)
SPL_ME(RecursiveFilterIterator, hasChildren, arginfo_recursive_it_void, ZEND_ACC_PUBLIC)
SPL_ME(RecursiveRegexIterator, getChildren, arginfo_recursive_it_void, ZEND_ACC_PUBLIC)
PHP_FE_END

View File

@@ -0,0 +1,91 @@
--TEST--
Bug #68128 - RecursiveRegexIterator raises "Array to string conversion" notice
--FILE--
<?php
$array = new ArrayIterator(array('a', array('b', 'c')));
$regex = new RegexIterator($array, '/Array/');
foreach ($regex as $match) {
var_dump($match);
}
$rArrayIterator = new RecursiveArrayIterator(array('test1', array('tet3', 'test4', 'test5')));
$rRegexIterator = new RecursiveRegexIterator($rArrayIterator, '/^(t)est(\d*)/',
RecursiveRegexIterator::ALL_MATCHES, 0, PREG_PATTERN_ORDER);
foreach ($rRegexIterator as $key1 => $value1) {
if ($rRegexIterator->hasChildren()) {
// print all children
echo "Children: ";
foreach ($rRegexIterator->getChildren() as $key => $value) {
print_r($value);
}
echo "\n";
} else {
echo "No children ";
print_r($value1);
echo "\n";
}
}
?>
--EXPECT--
No children Array
(
[0] => Array
(
[0] => test1
)
[1] => Array
(
[0] => t
)
[2] => Array
(
[0] => 1
)
)
Children: Array
(
[0] => Array
(
[0] => test4
)
[1] => Array
(
[0] => t
)
[2] => Array
(
[0] => 4
)
)
Array
(
[0] => Array
(
[0] => test5
)
[1] => Array
(
[0] => t
)
[2] => Array
(
[0] => 5
)
)

View File

@@ -13,11 +13,6 @@ class MyRecursiveRegexIterator extends RecursiveRegexIterator
var_dump($v);
}
}
function accept()
{
return $this->hasChildren() || parent::accept();
}
}
$ar = new RecursiveArrayIterator(array('Foo', array('Bar'), 'FooBar', array('Baz'), 'Biz'));

View File

@@ -46,8 +46,6 @@ array(3) {
[2]=>
%s(1) "2"
}
Notice: Array to string conversion in %siterator_050.php on line %d
int(0)
array(2) {
[0]=>
@@ -69,8 +67,6 @@ array(2) {
[1]=>
%s(1) "1"
}
Notice: Array to string conversion in %siterator_050.php on line %d
object(ArrayIterator)#%d (1) {
%s"storage"%s"ArrayIterator":private]=>
array(9) {

View File

@@ -46,18 +46,6 @@ var_dump($ar);
<?php exit(0); ?>
--EXPECTF--
bool(true)
int(0)
array(3) {
[0]=>
array(0) {
}
[1]=>
array(0) {
}
[2]=>
array(0) {
}
}
bool(true)
int(1)
array(3) {
@@ -97,85 +85,11 @@ array(3) {
}
}
bool(true)
int(3)
array(3) {
[0]=>
array(0) {
}
[1]=>
array(0) {
}
[2]=>
array(0) {
}
}
bool(true)
int(4)
array(3) {
[0]=>
array(0) {
}
[1]=>
array(0) {
}
[2]=>
array(0) {
}
}
Notice: Array to string conversion in %siterator_052.php on line %d
bool(false)
bool(true)
int(5)
array(3) {
[0]=>
array(0) {
}
[1]=>
array(0) {
}
[2]=>
array(0) {
}
}
bool(true)
int(6)
array(3) {
[0]=>
array(0) {
}
[1]=>
array(0) {
}
[2]=>
array(0) {
}
}
bool(true)
int(7)
array(3) {
[0]=>
array(0) {
}
[1]=>
array(0) {
}
[2]=>
array(0) {
}
}
bool(true)
int(8)
array(3) {
[0]=>
array(0) {
}
[1]=>
array(0) {
}
[2]=>
array(0) {
}
}
bool(true)
int(0)
array(2) {
@@ -231,67 +145,11 @@ array(2) {
}
}
bool(true)
int(3)
array(2) {
[0]=>
array(0) {
}
[1]=>
array(0) {
}
}
bool(true)
int(4)
array(2) {
[0]=>
array(0) {
}
[1]=>
array(0) {
}
}
Notice: Array to string conversion in %siterator_052.php on line %d
bool(false)
bool(true)
int(5)
array(2) {
[0]=>
array(0) {
}
[1]=>
array(0) {
}
}
bool(true)
int(6)
array(2) {
[0]=>
array(0) {
}
[1]=>
array(0) {
}
}
bool(true)
int(7)
array(2) {
[0]=>
array(0) {
}
[1]=>
array(0) {
}
}
bool(true)
int(8)
array(2) {
[0]=>
array(0) {
}
[1]=>
array(0) {
}
}
object(ArrayIterator)#%d (1) {
["storage":"ArrayIterator":private]=>
array(9) {

View File

@@ -46,122 +46,14 @@ var_dump($ar);
<?php exit(0); ?>
--EXPECTF--
bool(true)
int(0)
array(3) {
[0]=>
array(0) {
}
[1]=>
array(0) {
}
[2]=>
array(0) {
}
}
bool(true)
int(1)
array(3) {
[0]=>
array(0) {
}
[1]=>
array(0) {
}
[2]=>
array(0) {
}
}
bool(true)
int(2)
array(3) {
[0]=>
array(0) {
}
[1]=>
array(0) {
}
[2]=>
array(0) {
}
}
bool(true)
int(3)
array(3) {
[0]=>
array(0) {
}
[1]=>
array(0) {
}
[2]=>
array(0) {
}
}
bool(true)
int(4)
array(3) {
[0]=>
array(0) {
}
[1]=>
array(0) {
}
[2]=>
array(0) {
}
}
bool(false)
bool(true)
int(5)
array(3) {
[0]=>
array(0) {
}
[1]=>
array(0) {
}
[2]=>
array(0) {
}
}
bool(true)
int(6)
array(3) {
[0]=>
array(0) {
}
[1]=>
array(0) {
}
[2]=>
array(0) {
}
}
bool(true)
int(7)
array(3) {
[0]=>
array(0) {
}
[1]=>
array(0) {
}
[2]=>
array(0) {
}
}
bool(true)
int(8)
array(3) {
[0]=>
array(0) {
}
[1]=>
array(0) {
}
[2]=>
array(0) {
}
}
bool(true)
int(0)
array(2) {
@@ -232,20 +124,7 @@ array(2) {
string(1) "4"
}
}
bool(true)
int(5)
array(2) {
[0]=>
array(1) {
[0]=>
string(1) "5"
}
[1]=>
array(1) {
[0]=>
string(1) "5"
}
}
bool(false)
bool(true)
int(6)
array(2) {

View File

@@ -42,8 +42,6 @@ array(3) {
[2]=>
string(1) "3"
}
Notice: Array to string conversion in %siterator_054.php on line %d
int(7)
array(2) {
[0]=>

View File

@@ -5051,7 +5051,7 @@ static int user_tick_function_compare(user_tick_function_entry * tick_fe1, user_
}
/* }}} */
void php_call_shutdown_functions(TSRMLS_D) /* {{{ */
PHPAPI void php_call_shutdown_functions(TSRMLS_D) /* {{{ */
{
if (BG(user_shutdown_function_names)) {
zend_try {
@@ -5063,7 +5063,7 @@ void php_call_shutdown_functions(TSRMLS_D) /* {{{ */
}
/* }}} */
void php_free_shutdown_functions(TSRMLS_D) /* {{{ */
PHPAPI void php_free_shutdown_functions(TSRMLS_D) /* {{{ */
{
if (BG(user_shutdown_function_names))
zend_try {

View File

@@ -261,4 +261,8 @@ PHPAPI extern zend_bool register_user_shutdown_function(char *function_name, siz
PHPAPI extern zend_bool remove_user_shutdown_function(char *function_name, size_t function_len TSRMLS_DC);
PHPAPI extern zend_bool append_user_shutdown_function(php_shutdown_function_entry shutdown_function_entry TSRMLS_DC);
PHPAPI void php_call_shutdown_functions(TSRMLS_D);
PHPAPI void php_free_shutdown_functions(TSRMLS_D);
#endif /* BASIC_FUNCTIONS_H */

View File

@@ -82,6 +82,13 @@ static int machine_endian_long_map[4];
static int big_endian_long_map[4];
static int little_endian_long_map[4];
#if SIZEOF_LONG > 4
/* Mappings of bytes from quads (64bit) for all endian environments */
static int machine_endian_longlong_map[8];
static int big_endian_longlong_map[8];
static int little_endian_longlong_map[8];
#endif
/* {{{ php_pack
*/
static void php_pack(zval **val, int size, int *map, char *output)
@@ -98,8 +105,8 @@ static void php_pack(zval **val, int size, int *map, char *output)
}
/* }}} */
/* pack() idea stolen from Perl (implemented formats behave the same as there)
* Implemented formats are Z, A, a, h, H, c, C, s, S, i, I, l, L, n, N, f, d, x, X, @.
/* pack() idea stolen from Perl (implemented formats behave the same as there except J and P)
* Implemented formats are Z, A, a, h, H, c, C, s, S, i, I, l, L, n, N, q, Q, J, P, f, d, x, X, @.
*/
/* {{{ proto string pack(string format, mixed arg1 [, mixed arg2 [, mixed ...]])
Takes one or more arguments and packs them into a binary string according to the format argument */
@@ -199,6 +206,17 @@ PHP_FUNCTION(pack)
break;
/* Use as many args as specified */
case 'q':
case 'Q':
case 'J':
case 'P':
#if SIZEOF_LONG < 8
efree(argv);
efree(formatcodes);
efree(formatargs);
php_error_docref(NULL TSRMLS_CC, E_WARNING, "64-bit format codes are not available for 32-bit versions of PHP");
RETURN_FALSE;
#endif
case 'c':
case 'C':
case 's':
@@ -283,6 +301,15 @@ PHP_FUNCTION(pack)
INC_OUTPUTPOS(arg,4) /* 32 bit per arg */
break;
#if SIZEOF_LONG > 4
case 'q':
case 'Q':
case 'J':
case 'P':
INC_OUTPUTPOS(arg,8) /* 32 bit per arg */
break;
#endif
case 'f':
INC_OUTPUTPOS(arg,sizeof(float))
break;
@@ -437,6 +464,27 @@ PHP_FUNCTION(pack)
break;
}
#if SIZEOF_LONG > 4
case 'q':
case 'Q':
case 'J':
case 'P': {
int *map = machine_endian_longlong_map;
if (code == 'J') {
map = big_endian_longlong_map;
} else if (code == 'P') {
map = little_endian_longlong_map;
}
while (arg-- > 0) {
php_pack(argv[currentarg++], 8, map, &output[outputpos]);
outputpos += 8;
}
break;
}
#endif
case 'f': {
float v;
@@ -522,7 +570,7 @@ static long php_unpack(char *data, int size, int issigned, int *map)
* chars1, chars2, and ints.
* Numeric pack types will return numbers, a and A will return strings,
* f and d will return doubles.
* Implemented formats are Z, A, a, h, H, c, C, s, S, i, I, l, L, n, N, f, d, x, X, @.
* Implemented formats are Z, A, a, h, H, c, C, s, S, i, I, l, L, n, N, q, Q, J, P, f, d, x, X, @.
*/
/* {{{ proto array unpack(string format, string input)
Unpack binary string into named array elements according to format argument */
@@ -637,6 +685,20 @@ PHP_FUNCTION(unpack)
size = 4;
break;
/* Use 8 bytes of input */
case 'q':
case 'Q':
case 'J':
case 'P':
#if SIZEOF_LONG > 4
size = 8;
break;
#else
php_error_docref(NULL TSRMLS_CC, E_WARNING, "64-bit format codes are not available for 32-bit versions of PHP");
zval_dtor(return_value);
RETURN_FALSE;
#endif
/* Use sizeof(float) bytes of input */
case 'f':
size = sizeof(float);
@@ -860,6 +922,38 @@ PHP_FUNCTION(unpack)
break;
}
#if SIZEOF_LONG > 4
case 'q':
case 'Q':
case 'J':
case 'P': {
int issigned = 0;
int *map = machine_endian_longlong_map;
long v = 0;
if (type == 'q' || type == 'Q') {
issigned = input[inputpos + (machine_little_endian ? 7 : 0)] & 0x80;
} else if (type == 'J') {
issigned = input[inputpos] & 0x80;
map = big_endian_longlong_map;
} else if (type == 'P') {
issigned = input[inputpos + 7] & 0x80;
map = little_endian_longlong_map;
}
v = php_unpack(&input[inputpos], 8, issigned, map);
if (type == 'q') {
v = (signed long int) v;
} else {
v = (unsigned long int) v;
}
add_assoc_long(return_value, n, v);
break;
}
#endif
case 'f': {
float v;
@@ -961,6 +1055,33 @@ PHP_MINIT_FUNCTION(pack)
little_endian_long_map[1] = 1;
little_endian_long_map[2] = 2;
little_endian_long_map[3] = 3;
#if SIZEOF_LONG > 4
machine_endian_longlong_map[0] = 0;
machine_endian_longlong_map[1] = 1;
machine_endian_longlong_map[2] = 2;
machine_endian_longlong_map[3] = 3;
machine_endian_longlong_map[4] = 4;
machine_endian_longlong_map[5] = 5;
machine_endian_longlong_map[6] = 6;
machine_endian_longlong_map[7] = 7;
big_endian_longlong_map[0] = 7;
big_endian_longlong_map[1] = 6;
big_endian_longlong_map[2] = 5;
big_endian_longlong_map[3] = 4;
big_endian_longlong_map[4] = 3;
big_endian_longlong_map[5] = 2;
big_endian_longlong_map[6] = 1;
big_endian_longlong_map[7] = 0;
little_endian_longlong_map[0] = 0;
little_endian_longlong_map[1] = 1;
little_endian_longlong_map[2] = 2;
little_endian_longlong_map[3] = 3;
little_endian_longlong_map[4] = 4;
little_endian_longlong_map[5] = 5;
little_endian_longlong_map[6] = 6;
little_endian_longlong_map[7] = 7;
#endif
}
else {
zval val;
@@ -993,6 +1114,33 @@ PHP_MINIT_FUNCTION(pack)
little_endian_long_map[1] = size - 2;
little_endian_long_map[2] = size - 3;
little_endian_long_map[3] = size - 4;
#if SIZEOF_LONG > 4
machine_endian_longlong_map[0] = size - 8;
machine_endian_longlong_map[1] = size - 7;
machine_endian_longlong_map[2] = size - 6;
machine_endian_longlong_map[3] = size - 5;
machine_endian_longlong_map[0] = size - 4;
machine_endian_longlong_map[1] = size - 3;
machine_endian_longlong_map[2] = size - 2;
machine_endian_longlong_map[3] = size - 1;
big_endian_longlong_map[0] = size - 8;
big_endian_longlong_map[1] = size - 7;
big_endian_longlong_map[2] = size - 6;
big_endian_longlong_map[3] = size - 5;
big_endian_longlong_map[0] = size - 4;
big_endian_longlong_map[1] = size - 3;
big_endian_longlong_map[2] = size - 2;
big_endian_longlong_map[3] = size - 1;
little_endian_longlong_map[0] = size - 1;
little_endian_longlong_map[1] = size - 2;
little_endian_longlong_map[2] = size - 3;
little_endian_longlong_map[3] = size - 4;
little_endian_longlong_map[0] = size - 5;
little_endian_longlong_map[1] = size - 6;
little_endian_longlong_map[2] = size - 7;
little_endian_longlong_map[3] = size - 8;
#endif
}
return SUCCESS;

View File

@@ -1,71 +1,63 @@
--TEST--
Bug #52820 (writes to fopencookie FILE* not committed when seeking the stream)
--SKIPIF--
<?php
if (!function_exists('leak_variable'))
die("skip only for debug builds");
/* unfortunately no standard function does a cast to FILE*, so we need
* curl to test this */
if (!extension_loaded("curl")) exit("skip curl extension not loaded");
$handle=curl_init('http://127.0.0.1:37349/');
curl_setopt($handle, CURLOPT_VERBOSE, true);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
if (!curl_setopt($handle, CURLOPT_STDERR, fopen("php://memory", "w+")))
die("skip fopencookie not supported on this platform");
--FILE--
<?php
function do_stuff($url) {
$handle=curl_init('http://127.0.0.1:37349/');
curl_setopt($handle, CURLOPT_VERBOSE, true);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
curl_setopt($handle, CURLOPT_STDERR, $o = fopen($url, "w+"));
curl_exec($handle);
echo "About to rewind!\n";
rewind($o);
echo stream_get_contents($o);
return $o;
}
echo "temp stream (close after):\n";
fclose(do_stuff("php://temp"));
echo "\nmemory stream (close after):\n";
fclose(do_stuff("php://memory"));
echo "\ntemp stream (leak):\n";
leak_variable(do_stuff("php://temp"), true);
echo "\nmemory stream (leak):\n";
leak_variable(do_stuff("php://memory"), true);
echo "\nDone.\n";
--EXPECTF--
temp stream (close after):
About to rewind!
* About to connect() to 127.0.0.1 port 37349%r.*%r
* Trying 127.0.0.1...%A* Connection refused
* couldn't connect to host%S
* Closing connection #0
memory stream (close after):
About to rewind!
* About to connect() to 127.0.0.1 port 37349%r.*%r
* Trying 127.0.0.1...%A* Connection refused
* couldn't connect to host%S
* Closing connection #0
temp stream (leak):
About to rewind!
* About to connect() to 127.0.0.1 port 37349%r.*%r
* Trying 127.0.0.1...%A* Connection refused
* couldn't connect to host%S
* Closing connection #0
memory stream (leak):
About to rewind!
* About to connect() to 127.0.0.1 port 37349%r.*%r
* Trying 127.0.0.1...%A* Connection refused
* couldn't connect to host%S
* Closing connection #0
Done.
--TEST--
Bug #52820 (writes to fopencookie FILE* not committed when seeking the stream)
--SKIPIF--
<?php
if (!function_exists('leak_variable'))
die("skip only for debug builds");
/* unfortunately no standard function does a cast to FILE*, so we need
* curl to test this */
if (!extension_loaded("curl")) exit("skip curl extension not loaded");
$handle=curl_init('http://127.0.0.1:37349/');
curl_setopt($handle, CURLOPT_VERBOSE, true);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
if (!curl_setopt($handle, CURLOPT_STDERR, fopen("php://memory", "w+")))
die("skip fopencookie not supported on this platform");
--FILE--
<?php
function do_stuff($url) {
$handle=curl_init('http://127.0.0.1:37349/');
curl_setopt($handle, CURLOPT_VERBOSE, true);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
curl_setopt($handle, CURLOPT_STDERR, $o = fopen($url, "w+"));
curl_exec($handle);
echo "About to rewind!\n";
rewind($o);
echo stream_get_contents($o);
return $o;
}
echo "temp stream (close after):\n";
fclose(do_stuff("php://temp"));
echo "\nmemory stream (close after):\n";
fclose(do_stuff("php://memory"));
echo "\ntemp stream (leak):\n";
leak_variable(do_stuff("php://temp"), true);
echo "\nmemory stream (leak):\n";
leak_variable(do_stuff("php://memory"), true);
echo "\nDone.\n";
--EXPECTF--
temp stream (close after):
About to rewind!
* %ATrying 127.0.0.1...%AConnection refused%A
* Closing connection%A%d
memory stream (close after):
About to rewind!
* %ATrying 127.0.0.1...%AConnection refused%A
* Closing connection%A%d
temp stream (leak):
About to rewind!
* %ATrying 127.0.0.1...%AConnection refused%A
* Closing connection%A%d
memory stream (leak):
About to rewind!
* %ATrying 127.0.0.1...%AConnection refused%A
* Closing connection%A%d
Done.

View File

@@ -0,0 +1,12 @@
--TEST--
Bug #68044 Integer overflow in unserialize() (32-bits only)
--FILE--
<?php
echo unserialize('C:3:"XYZ":18446744075857035259:{}');
?>
===DONE==
--EXPECTF--
Warning: Insufficient data for unserializing - %d required, 1 present in %s/bug68044.php on line 2
Notice: unserialize(): Error at offset 32 of 33 bytes in %s/bug68044.php on line 2
===DONE==

View File

@@ -0,0 +1,115 @@
--TEST--
64bit pack()/unpack() tests
--SKIPIF--
<?php
if (PHP_INT_SIZE < 8) {
die("skip 64bit test only");
}
?>
--FILE--
<?php
print_r(unpack("Q", pack("Q", 0xfffffffffffe)));
print_r(unpack("Q", pack("Q", 0)));
print_r(unpack("Q", pack("Q", 0x8000000000000002)));
print_r(unpack("Q", pack("Q", -1)));
print_r(unpack("Q", pack("Q", 0x8000000000000000)));
print_r(unpack("J", pack("J", 0xfffffffffffe)));
print_r(unpack("J", pack("J", 0)));
print_r(unpack("J", pack("J", 0x8000000000000002)));
print_r(unpack("J", pack("J", -1)));
print_r(unpack("J", pack("J", 0x8000000000000000)));
print_r(unpack("P", pack("P", 0xfffffffffffe)));
print_r(unpack("P", pack("P", 0)));
print_r(unpack("P", pack("P", 0x8000000000000002)));
print_r(unpack("P", pack("P", -1)));
print_r(unpack("P", pack("P", 0x8000000000000000)));
print_r(unpack("q", pack("q", 0xfffffffffffe)));
print_r(unpack("q", pack("q", 0)));
print_r(unpack("q", pack("q", 0x8000000000000002)));
print_r(unpack("q", pack("q", -1)));
print_r(unpack("q", pack("q", 0x8000000000000000)));
?>
--EXPECTF--
Array
(
[1] => 281474976710654
)
Array
(
[1] => 0
)
Array
(
[1] => -9223372036854775808
)
Array
(
[1] => -1
)
Array
(
[1] => -9223372036854775808
)
Array
(
[1] => 281474976710654
)
Array
(
[1] => 0
)
Array
(
[1] => -9223372036854775808
)
Array
(
[1] => -1
)
Array
(
[1] => -9223372036854775808
)
Array
(
[1] => 281474976710654
)
Array
(
[1] => 0
)
Array
(
[1] => -9223372036854775808
)
Array
(
[1] => -1
)
Array
(
[1] => -9223372036854775808
)
Array
(
[1] => 281474976710654
)
Array
(
[1] => 0
)
Array
(
[1] => -9223372036854775808
)
Array
(
[1] => -1
)
Array
(
[1] => -9223372036854775808
)

View File

@@ -0,0 +1,44 @@
--TEST--
64bit pack()/unpack() tests
--SKIPIF--
<?php
if (PHP_INT_SIZE > 4) {
die("skip 32bit test only");
}
?>
--FILE--
<?php
var_dump(pack("Q", 0));
var_dump(pack("J", 0));
var_dump(pack("P", 0));
var_dump(pack("q", 0));
var_dump(unpack("Q", ''));
var_dump(unpack("J", ''));
var_dump(unpack("P", ''));
var_dump(unpack("q", ''));
?>
--EXPECTF--
Warning: pack(): 64-bit format codes are not available for 32-bit versions of PHP in %s on line %d
bool(false)
Warning: pack(): 64-bit format codes are not available for 32-bit versions of PHP in %s on line %d
bool(false)
Warning: pack(): 64-bit format codes are not available for 32-bit versions of PHP in %s on line %d
bool(false)
Warning: pack(): 64-bit format codes are not available for 32-bit versions of PHP in %s on line %d
bool(false)
Warning: unpack(): 64-bit format codes are not available for 32-bit versions of PHP in %s on line %d
bool(false)
Warning: unpack(): 64-bit format codes are not available for 32-bit versions of PHP in %s on line %d
bool(false)
Warning: unpack(): 64-bit format codes are not available for 32-bit versions of PHP in %s on line %d
bool(false)
Warning: unpack(): 64-bit format codes are not available for 32-bit versions of PHP in %s on line %d
bool(false)

View File

@@ -75,6 +75,7 @@ $sample_urls = array (
);
foreach ($sample_urls as $url) {
echo "\n--> $url: ";
var_dump(@parse_url($url));
}
@@ -84,21 +85,24 @@ $sample_urls = array (
}
?>
--EXPECT--
array(1) {
--> : array(1) {
["path"]=>
string(0) ""
}
array(1) {
--> 64.246.30.37: array(1) {
["path"]=>
string(12) "64.246.30.37"
}
array(2) {
--> http://64.246.30.37: array(2) {
["scheme"]=>
string(4) "http"
["host"]=>
string(12) "64.246.30.37"
}
array(3) {
--> http://64.246.30.37/: array(3) {
["scheme"]=>
string(4) "http"
["host"]=>
@@ -106,11 +110,13 @@ array(3) {
["path"]=>
string(1) "/"
}
array(1) {
--> 64.246.30.37/: array(1) {
["path"]=>
string(13) "64.246.30.37/"
}
array(3) {
--> 64.246.30.37:80/: array(3) {
["host"]=>
string(12) "64.246.30.37"
["port"]=>
@@ -118,21 +124,25 @@ array(3) {
["path"]=>
string(1) "/"
}
array(1) {
--> php.net: array(1) {
["path"]=>
string(7) "php.net"
}
array(1) {
--> php.net/: array(1) {
["path"]=>
string(8) "php.net/"
}
array(2) {
--> http://php.net: array(2) {
["scheme"]=>
string(4) "http"
["host"]=>
string(7) "php.net"
}
array(3) {
--> http://php.net/: array(3) {
["scheme"]=>
string(4) "http"
["host"]=>
@@ -140,21 +150,25 @@ array(3) {
["path"]=>
string(1) "/"
}
array(1) {
--> www.php.net: array(1) {
["path"]=>
string(11) "www.php.net"
}
array(1) {
--> www.php.net/: array(1) {
["path"]=>
string(12) "www.php.net/"
}
array(2) {
--> http://www.php.net: array(2) {
["scheme"]=>
string(4) "http"
["host"]=>
string(11) "www.php.net"
}
array(3) {
--> http://www.php.net/: array(3) {
["scheme"]=>
string(4) "http"
["host"]=>
@@ -162,13 +176,15 @@ array(3) {
["path"]=>
string(1) "/"
}
array(2) {
--> www.php.net:80: array(2) {
["host"]=>
string(11) "www.php.net"
["port"]=>
int(80)
}
array(3) {
--> http://www.php.net:80: array(3) {
["scheme"]=>
string(4) "http"
["host"]=>
@@ -176,7 +192,8 @@ array(3) {
["port"]=>
int(80)
}
array(4) {
--> http://www.php.net:80/: array(4) {
["scheme"]=>
string(4) "http"
["host"]=>
@@ -186,7 +203,8 @@ array(4) {
["path"]=>
string(1) "/"
}
array(3) {
--> http://www.php.net/index.php: array(3) {
["scheme"]=>
string(4) "http"
["host"]=>
@@ -194,11 +212,13 @@ array(3) {
["path"]=>
string(10) "/index.php"
}
array(1) {
--> www.php.net/?: array(1) {
["path"]=>
string(12) "www.php.net/"
}
array(3) {
--> www.php.net:80/?: array(3) {
["host"]=>
string(11) "www.php.net"
["port"]=>
@@ -206,7 +226,8 @@ array(3) {
["path"]=>
string(1) "/"
}
array(3) {
--> http://www.php.net/?: array(3) {
["scheme"]=>
string(4) "http"
["host"]=>
@@ -214,7 +235,8 @@ array(3) {
["path"]=>
string(1) "/"
}
array(4) {
--> http://www.php.net:80/?: array(4) {
["scheme"]=>
string(4) "http"
["host"]=>
@@ -224,7 +246,8 @@ array(4) {
["path"]=>
string(1) "/"
}
array(4) {
--> http://www.php.net:80/index.php: array(4) {
["scheme"]=>
string(4) "http"
["host"]=>
@@ -234,7 +257,8 @@ array(4) {
["path"]=>
string(10) "/index.php"
}
array(4) {
--> http://www.php.net:80/foo/bar/index.php: array(4) {
["scheme"]=>
string(4) "http"
["host"]=>
@@ -244,7 +268,8 @@ array(4) {
["path"]=>
string(18) "/foo/bar/index.php"
}
array(4) {
--> http://www.php.net:80/this/is/a/very/deep/directory/structure/and/file.php: array(4) {
["scheme"]=>
string(4) "http"
["host"]=>
@@ -254,7 +279,8 @@ array(4) {
["path"]=>
string(53) "/this/is/a/very/deep/directory/structure/and/file.php"
}
array(5) {
--> http://www.php.net:80/this/is/a/very/deep/directory/structure/and/file.php?lots=1&of=2&parameters=3&too=4&here=5: array(5) {
["scheme"]=>
string(4) "http"
["host"]=>
@@ -266,7 +292,8 @@ array(5) {
["query"]=>
string(37) "lots=1&of=2&parameters=3&too=4&here=5"
}
array(4) {
--> http://www.php.net:80/this/is/a/very/deep/directory/structure/and/: array(4) {
["scheme"]=>
string(4) "http"
["host"]=>
@@ -276,7 +303,8 @@ array(4) {
["path"]=>
string(45) "/this/is/a/very/deep/directory/structure/and/"
}
array(4) {
--> http://www.php.net:80/this/is/a/very/deep/directory/structure/and/file.php: array(4) {
["scheme"]=>
string(4) "http"
["host"]=>
@@ -286,7 +314,8 @@ array(4) {
["path"]=>
string(53) "/this/is/a/very/deep/directory/structure/and/file.php"
}
array(4) {
--> http://www.php.net:80/this/../a/../deep/directory: array(4) {
["scheme"]=>
string(4) "http"
["host"]=>
@@ -296,7 +325,8 @@ array(4) {
["path"]=>
string(28) "/this/../a/../deep/directory"
}
array(4) {
--> http://www.php.net:80/this/../a/../deep/directory/: array(4) {
["scheme"]=>
string(4) "http"
["host"]=>
@@ -306,7 +336,8 @@ array(4) {
["path"]=>
string(29) "/this/../a/../deep/directory/"
}
array(4) {
--> http://www.php.net:80/this/is/a/very/deep/directory/../file.php: array(4) {
["scheme"]=>
string(4) "http"
["host"]=>
@@ -316,7 +347,8 @@ array(4) {
["path"]=>
string(42) "/this/is/a/very/deep/directory/../file.php"
}
array(4) {
--> http://www.php.net:80/index.php: array(4) {
["scheme"]=>
string(4) "http"
["host"]=>
@@ -326,7 +358,8 @@ array(4) {
["path"]=>
string(10) "/index.php"
}
array(4) {
--> http://www.php.net:80/index.php?: array(4) {
["scheme"]=>
string(4) "http"
["host"]=>
@@ -336,7 +369,8 @@ array(4) {
["path"]=>
string(10) "/index.php"
}
array(5) {
--> http://www.php.net:80/#foo: array(5) {
["scheme"]=>
string(4) "http"
["host"]=>
@@ -348,7 +382,8 @@ array(5) {
["fragment"]=>
string(3) "foo"
}
array(4) {
--> http://www.php.net:80/?#: array(4) {
["scheme"]=>
string(4) "http"
["host"]=>
@@ -358,7 +393,8 @@ array(4) {
["path"]=>
string(1) "/"
}
array(5) {
--> http://www.php.net:80/?test=1: array(5) {
["scheme"]=>
string(4) "http"
["host"]=>
@@ -370,7 +406,8 @@ array(5) {
["query"]=>
string(6) "test=1"
}
array(4) {
--> http://www.php.net/?test=1&: array(4) {
["scheme"]=>
string(4) "http"
["host"]=>
@@ -380,7 +417,8 @@ array(4) {
["query"]=>
string(7) "test=1&"
}
array(5) {
--> http://www.php.net:80/?&: array(5) {
["scheme"]=>
string(4) "http"
["host"]=>
@@ -392,7 +430,8 @@ array(5) {
["query"]=>
string(1) "&"
}
array(5) {
--> http://www.php.net:80/index.php?test=1&: array(5) {
["scheme"]=>
string(4) "http"
["host"]=>
@@ -404,7 +443,8 @@ array(5) {
["query"]=>
string(7) "test=1&"
}
array(4) {
--> http://www.php.net/index.php?&: array(4) {
["scheme"]=>
string(4) "http"
["host"]=>
@@ -414,7 +454,8 @@ array(4) {
["query"]=>
string(1) "&"
}
array(5) {
--> http://www.php.net:80/index.php?foo&: array(5) {
["scheme"]=>
string(4) "http"
["host"]=>
@@ -426,7 +467,8 @@ array(5) {
["query"]=>
string(4) "foo&"
}
array(4) {
--> http://www.php.net/index.php?&foo: array(4) {
["scheme"]=>
string(4) "http"
["host"]=>
@@ -436,7 +478,8 @@ array(4) {
["query"]=>
string(4) "&foo"
}
array(5) {
--> http://www.php.net:80/index.php?test=1&test2=char&test3=mixesCI: array(5) {
["scheme"]=>
string(4) "http"
["host"]=>
@@ -448,7 +491,8 @@ array(5) {
["query"]=>
string(31) "test=1&test2=char&test3=mixesCI"
}
array(5) {
--> www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123: array(5) {
["host"]=>
string(11) "www.php.net"
["port"]=>
@@ -460,7 +504,8 @@ array(5) {
["fragment"]=>
string(16) "some_page_ref123"
}
array(7) {
--> http://secret@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123: array(7) {
["scheme"]=>
string(4) "http"
["host"]=>
@@ -476,13 +521,16 @@ array(7) {
["fragment"]=>
string(16) "some_page_ref123"
}
array(6) {
--> http://secret:@www.php.net/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123: array(7) {
["scheme"]=>
string(4) "http"
["host"]=>
string(11) "www.php.net"
["user"]=>
string(6) "secret"
["pass"]=>
string(0) ""
["path"]=>
string(10) "/index.php"
["query"]=>
@@ -490,13 +538,16 @@ array(6) {
["fragment"]=>
string(16) "some_page_ref123"
}
array(7) {
--> http://:hideout@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123: array(8) {
["scheme"]=>
string(4) "http"
["host"]=>
string(11) "www.php.net"
["port"]=>
int(80)
["user"]=>
string(0) ""
["pass"]=>
string(7) "hideout"
["path"]=>
@@ -506,7 +557,8 @@ array(7) {
["fragment"]=>
string(16) "some_page_ref123"
}
array(7) {
--> http://secret:hideout@www.php.net/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123: array(7) {
["scheme"]=>
string(4) "http"
["host"]=>
@@ -522,7 +574,8 @@ array(7) {
["fragment"]=>
string(16) "some_page_ref123"
}
array(7) {
--> http://secret@hideout@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123: array(7) {
["scheme"]=>
string(4) "http"
["host"]=>
@@ -538,7 +591,8 @@ array(7) {
["fragment"]=>
string(16) "some_page_ref123"
}
array(8) {
--> http://secret:hid:out@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123: array(8) {
["scheme"]=>
string(4) "http"
["host"]=>
@@ -556,13 +610,15 @@ array(8) {
["fragment"]=>
string(16) "some_page_ref123"
}
array(2) {
--> nntp://news.php.net: array(2) {
["scheme"]=>
string(4) "nntp"
["host"]=>
string(12) "news.php.net"
}
array(3) {
--> ftp://ftp.gnu.org/gnu/glic/glibc.tar.gz: array(3) {
["scheme"]=>
string(3) "ftp"
["host"]=>
@@ -570,25 +626,29 @@ array(3) {
["path"]=>
string(22) "/gnu/glic/glibc.tar.gz"
}
array(2) {
--> zlib:http://foo@bar: array(2) {
["scheme"]=>
string(4) "zlib"
["path"]=>
string(14) "http://foo@bar"
}
array(2) {
--> zlib:filename.txt: array(2) {
["scheme"]=>
string(4) "zlib"
["path"]=>
string(12) "filename.txt"
}
array(2) {
--> zlib:/path/to/my/file/file.txt: array(2) {
["scheme"]=>
string(4) "zlib"
["path"]=>
string(25) "/path/to/my/file/file.txt"
}
array(3) {
--> foo://foo@bar: array(3) {
["scheme"]=>
string(3) "foo"
["host"]=>
@@ -596,25 +656,29 @@ array(3) {
["user"]=>
string(3) "foo"
}
array(2) {
--> mailto:me@mydomain.com: array(2) {
["scheme"]=>
string(6) "mailto"
["path"]=>
string(15) "me@mydomain.com"
}
array(2) {
--> /foo.php?a=b&c=d: array(2) {
["path"]=>
string(8) "/foo.php"
["query"]=>
string(7) "a=b&c=d"
}
array(2) {
--> foo.php?a=b&c=d: array(2) {
["path"]=>
string(7) "foo.php"
["query"]=>
string(7) "a=b&c=d"
}
array(6) {
--> http://user:passwd@www.example.com:8080?bar=1&boom=0: array(6) {
["scheme"]=>
string(4) "http"
["host"]=>
@@ -628,13 +692,15 @@ array(6) {
["query"]=>
string(12) "bar=1&boom=0"
}
array(2) {
--> file:///path/to/file: array(2) {
["scheme"]=>
string(4) "file"
["path"]=>
string(13) "/path/to/file"
}
array(3) {
--> file://path/to/file: array(3) {
["scheme"]=>
string(4) "file"
["host"]=>
@@ -642,13 +708,15 @@ array(3) {
["path"]=>
string(8) "/to/file"
}
array(2) {
--> file:/path/to/file: array(2) {
["scheme"]=>
string(4) "file"
["path"]=>
string(13) "/path/to/file"
}
array(4) {
--> http://1.2.3.4:/abc.asp?a=1&b=2: array(4) {
["scheme"]=>
string(4) "http"
["host"]=>
@@ -658,7 +726,8 @@ array(4) {
["query"]=>
string(7) "a=1&b=2"
}
array(3) {
--> http://foo.com#bar: array(3) {
["scheme"]=>
string(4) "http"
["host"]=>
@@ -666,11 +735,13 @@ array(3) {
["fragment"]=>
string(3) "bar"
}
array(1) {
--> scheme:: array(1) {
["scheme"]=>
string(6) "scheme"
}
array(4) {
--> foo+bar://baz@bang/bla: array(4) {
["scheme"]=>
string(7) "foo+bar"
["host"]=>
@@ -680,13 +751,15 @@ array(4) {
["path"]=>
string(4) "/bla"
}
array(2) {
--> gg:9130731: array(2) {
["scheme"]=>
string(2) "gg"
["path"]=>
string(7) "9130731"
}
array(7) {
--> http://user:@pass@host/path?argument?value#etc: array(7) {
["scheme"]=>
string(4) "http"
["host"]=>
@@ -710,3 +783,4 @@ string(7) "hideout"
string(10) "/index.php"
string(31) "test=1&test2=char&test3=mixesCI"
string(16) "some_page_ref123"

View File

@@ -454,13 +454,15 @@ echo "Done";
string(16) "some_page_ref123"
}
--> http://secret:@www.php.net/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123: array(6) {
--> http://secret:@www.php.net/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123: array(7) {
["scheme"]=>
string(4) "http"
["host"]=>
string(11) "www.php.net"
["user"]=>
string(6) "secret"
["pass"]=>
string(0) ""
["path"]=>
string(10) "/index.php"
["query"]=>
@@ -469,13 +471,15 @@ echo "Done";
string(16) "some_page_ref123"
}
--> http://:hideout@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123: array(7) {
--> http://:hideout@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123: array(8) {
["scheme"]=>
string(4) "http"
["host"]=>
string(11) "www.php.net"
["port"]=>
int(80)
["user"]=>
string(0) ""
["pass"]=>
string(7) "hideout"
["path"]=>

View File

@@ -66,7 +66,7 @@ echo "Done";
--> www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : NULL
--> http://secret@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(6) "secret"
--> http://secret:@www.php.net/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(6) "secret"
--> http://:hideout@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : NULL
--> http://:hideout@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(0) ""
--> http://secret:hideout@www.php.net/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(6) "secret"
--> http://secret@hideout@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(14) "secret@hideout"
--> http://secret:hid:out@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(6) "secret"

View File

@@ -65,7 +65,7 @@ echo "Done";
--> http://www.php.net:80/index.php?test=1&test2=char&test3=mixesCI : NULL
--> www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : NULL
--> http://secret@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : NULL
--> http://secret:@www.php.net/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : NULL
--> http://secret:@www.php.net/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(0) ""
--> http://:hideout@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(7) "hideout"
--> http://secret:hideout@www.php.net/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(7) "hideout"
--> http://secret@hideout@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : NULL

View File

@@ -240,16 +240,12 @@ PHPAPI php_url *php_url_parse_ex(char const *str, int length)
/* check for login and password */
if ((p = zend_memrchr(s, '@', (e-s)))) {
if ((pp = memchr(s, ':', (p-s)))) {
if ((pp-s) > 0) {
ret->user = estrndup(s, (pp-s));
php_replace_controlchars_ex(ret->user, (pp - s));
}
ret->user = estrndup(s, (pp-s));
php_replace_controlchars_ex(ret->user, (pp - s));
pp++;
if (p-pp > 0) {
ret->pass = estrndup(pp, (p-pp));
php_replace_controlchars_ex(ret->pass, (p-pp));
}
ret->pass = estrndup(pp, (p-pp));
php_replace_controlchars_ex(ret->pass, (p-pp));
} else {
ret->user = estrndup(s, (p-s));
php_replace_controlchars_ex(ret->user, (p-s));

View File

@@ -1,4 +1,4 @@
/* Generated by re2c 0.13.5 on Fri Apr 18 15:07:27 2014 */
/* Generated by re2c 0.13.5 */
#line 1 "ext/standard/var_unserializer.re"
/*
+----------------------------------------------------------------------+
@@ -371,7 +371,7 @@ static inline int object_custom(UNSERIALIZE_PARAMETER, zend_class_entry *ce)
(*p) += 2;
if (datalen < 0 || (*p) + datalen >= max) {
if (datalen < 0 || (max - (*p)) <= datalen) {
zend_error(E_WARNING, "Insufficient data for unserializing - %ld required, %ld present", datalen, (long)(max - (*p)));
return 0;
}

View File

@@ -375,7 +375,7 @@ static inline int object_custom(UNSERIALIZE_PARAMETER, zend_class_entry *ce)
(*p) += 2;
if (datalen < 0 || (*p) + datalen >= max) {
if (datalen < 0 || (max - (*p)) <= datalen) {
zend_error(E_WARNING, "Insufficient data for unserializing - %ld required, %ld present", datalen, (long)(max - (*p)));
return 0;
}

View File

@@ -201,9 +201,13 @@ static int date_from_ISO8601 (const char *text, time_t * value) {
}
p++;
}
text = buf;
*p2 = 0;
text = buf;
}
if (strlen(text)<17) {
return -1;
}
tm.tm_isdst = -1;
@@ -219,16 +223,19 @@ static int date_from_ISO8601 (const char *text, time_t * value) {
n = 10;
tm.tm_mon = 0;
for(i = 0; i < 2; i++) {
XMLRPC_IS_NUMBER(text[i])
XMLRPC_IS_NUMBER(text[i+4])
tm.tm_mon += (text[i+4]-'0')*n;
n /= 10;
}
tm.tm_mon --;
if(tm.tm_mon < 0 || tm.tm_mon > 11) {
return -1;
}
n = 10;
tm.tm_mday = 0;
for(i = 0; i < 2; i++) {
XMLRPC_IS_NUMBER(text[i])
XMLRPC_IS_NUMBER(text[i+6])
tm.tm_mday += (text[i+6]-'0')*n;
n /= 10;
}
@@ -236,7 +243,7 @@ static int date_from_ISO8601 (const char *text, time_t * value) {
n = 10;
tm.tm_hour = 0;
for(i = 0; i < 2; i++) {
XMLRPC_IS_NUMBER(text[i])
XMLRPC_IS_NUMBER(text[i+9])
tm.tm_hour += (text[i+9]-'0')*n;
n /= 10;
}
@@ -244,7 +251,7 @@ static int date_from_ISO8601 (const char *text, time_t * value) {
n = 10;
tm.tm_min = 0;
for(i = 0; i < 2; i++) {
XMLRPC_IS_NUMBER(text[i])
XMLRPC_IS_NUMBER(text[i+12])
tm.tm_min += (text[i+12]-'0')*n;
n /= 10;
}
@@ -252,7 +259,7 @@ static int date_from_ISO8601 (const char *text, time_t * value) {
n = 10;
tm.tm_sec = 0;
for(i = 0; i < 2; i++) {
XMLRPC_IS_NUMBER(text[i])
XMLRPC_IS_NUMBER(text[i+15])
tm.tm_sec += (text[i+15]-'0')*n;
n /= 10;
}

View File

@@ -0,0 +1,44 @@
--TEST--
Bug #68027 (buffer overflow in mkgmtime() function)
--SKIPIF--
<?php
if (!extension_loaded("xmlrpc")) print "skip";
?>
--FILE--
<?php
$d = '6-01-01 20:00:00';
xmlrpc_set_type($d, 'datetime');
var_dump($d);
$datetime = "2001-0-08T21:46:40-0400";
$obj = xmlrpc_decode("<?xml version=\"1.0\"?><methodResponse><params><param><value><dateTime.iso8601>$datetime</dateTime.iso8601></value></param></params></methodResponse>");
print_r($obj);
$datetime = "34770-0-08T21:46:40-0400";
$obj = xmlrpc_decode("<?xml version=\"1.0\"?><methodResponse><params><param><value><dateTime.iso8601>$datetime</dateTime.iso8601></value></param></params></methodResponse>");
print_r($obj);
echo "Done\n";
?>
--EXPECTF--
object(stdClass)#1 (3) {
["scalar"]=>
string(16) "6-01-01 20:00:00"
["xmlrpc_type"]=>
string(8) "datetime"
["timestamp"]=>
int(%d)
}
stdClass Object
(
[scalar] => 2001-0-08T21:46:40-0400
[xmlrpc_type] => datetime
[timestamp] => %s
)
stdClass Object
(
[scalar] => 34770-0-08T21:46:40-0400
[xmlrpc_type] => datetime
[timestamp] => %d
)
Done

View File

@@ -59,9 +59,17 @@ PHPAPI int php_getopt(int argc, char* const *argv, const opt_struct opts[], char
{
static int optchr = 0;
static int dash = 0; /* have already seen the - */
static char **prev_optarg = NULL;
php_optidx = -1;
if(prev_optarg && prev_optarg != optarg) {
/* reset the state */
optchr = 0;
dash = 0;
}
prev_optarg = optarg;
if (*optind >= argc) {
return(EOF);
}

View File

@@ -35,7 +35,7 @@
#include "zend_stack.h"
#include "php_output.h"
ZEND_DECLARE_MODULE_GLOBALS(output);
PHPAPI ZEND_DECLARE_MODULE_GLOBALS(output);
const char php_output_default_handler_name[sizeof("default output handler")] = "default output handler";
const char php_output_devnull_handler_name[sizeof("null output handler")] = "null output handler";

View File

@@ -50,9 +50,6 @@ PHPAPI int php_handle_auth_data(const char *auth TSRMLS_DC);
PHPAPI void php_html_puts(const char *str, uint siz TSRMLS_DC);
PHPAPI int php_stream_open_for_zend_ex(const char *filename, zend_file_handle *handle, int mode TSRMLS_DC);
extern void php_call_shutdown_functions(TSRMLS_D);
extern void php_free_shutdown_functions(TSRMLS_D);
/* environment module */
extern int php_init_environ(void);
extern int php_shutdown_environ(void);

View File

@@ -152,6 +152,8 @@ ZEND_BEGIN_MODULE_GLOBALS(output)
int output_start_lineno;
ZEND_END_MODULE_GLOBALS(output)
PHPAPI ZEND_EXTERN_MODULE_GLOBALS(output);
/* there should not be a need to use OG() from outside of output.c */
#ifdef ZTS
# define OG(v) TSRMG(output_globals_id, zend_output_globals *, v)

View File

@@ -297,9 +297,6 @@ PHPAPI size_t _php_stream_write(php_stream *stream, const char *buf, size_t coun
#define php_stream_write_string(stream, str) _php_stream_write(stream, str, strlen(str) TSRMLS_CC)
#define php_stream_write(stream, buf, count) _php_stream_write(stream, (buf), (count) TSRMLS_CC)
PHPAPI void _php_stream_fill_read_buffer(php_stream *stream, size_t size TSRMLS_DC);
#define php_stream_fill_read_buffer(stream, size) _php_stream_fill_read_buffer((stream), (size) TSRMLS_CC)
#ifdef ZTS
PHPAPI size_t _php_stream_printf(php_stream *stream TSRMLS_DC, const char *fmt, ...) PHP_ATTRIBUTE_FORMAT(printf, 3, 4);
#else

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 2
#define PHP_RELEASE_VERSION 4
#define PHP_EXTRA_VERSION "-dev"
#define PHP_VERSION "5.6.2-dev"
#define PHP_VERSION_ID 50602
#define PHP_VERSION "5.6.4-dev"
#define PHP_VERSION_ID 50604

View File

@@ -311,7 +311,7 @@ PHPAPI char *php_gcvt(double value, int ndigit, char dec_point, char exponent, c
* is declared as buf[ 100 ], buf_end should be &buf[ 100 ])
*/
/* char * ap_php_conv_10() {{{ */
char * ap_php_conv_10(register wide_int num, register bool_int is_unsigned,
PHPAPI char * ap_php_conv_10(register wide_int num, register bool_int is_unsigned,
register bool_int * is_negative, char *buf_end, register int *len)
{
register char *p = buf_end;
@@ -474,7 +474,7 @@ PHPAPI char * php_conv_fp(register char format, register double num,
* which is a pointer to the END of the buffer + 1 (i.e. if the buffer
* is declared as buf[ 100 ], buf_end should be &buf[ 100 ])
*/
char * ap_php_conv_p2(register u_wide_int num, register int nbits, char format, char *buf_end, register int *len) /* {{{ */
PHPAPI char * ap_php_conv_p2(register u_wide_int num, register int nbits, char format, char *buf_end, register int *len) /* {{{ */
{
register int mask = (1 << nbits) - 1;
register char *p = buf_end;

View File

@@ -152,10 +152,10 @@ typedef enum {
typedef WIDE_INT wide_int;
typedef unsigned WIDE_INT u_wide_int;
extern char * ap_php_conv_10(register wide_int num, register bool_int is_unsigned,
PHPAPI char * ap_php_conv_10(register wide_int num, register bool_int is_unsigned,
register bool_int * is_negative, char *buf_end, register int *len);
extern char * ap_php_conv_p2(register u_wide_int num, register int nbits,
PHPAPI char * ap_php_conv_p2(register u_wide_int num, register int nbits,
char format, char *buf_end, register int *len);
/* The maximum precision that's allowed for float conversion. Does not include

View File

@@ -568,7 +568,7 @@ fprintf(stderr, "stream_free: %s:%p[%s] preserve_handle=%d release_cast=%d remov
/* {{{ generic stream operations */
PHPAPI void _php_stream_fill_read_buffer(php_stream *stream, size_t size TSRMLS_DC)
static void php_stream_fill_read_buffer(php_stream *stream, size_t size TSRMLS_DC)
{
/* allocate/fill the buffer */
@@ -736,7 +736,7 @@ PHPAPI size_t _php_stream_read(php_stream *stream, char *buf, size_t size TSRMLS
break;
}
} else {
php_stream_fill_read_buffer(stream, size);
php_stream_fill_read_buffer(stream, size TSRMLS_CC);
toread = stream->writepos - stream->readpos;
if (toread > size) {
@@ -972,7 +972,7 @@ PHPAPI char *_php_stream_get_line(php_stream *stream, char *buf, size_t maxlen,
}
}
php_stream_fill_read_buffer(stream, toread);
php_stream_fill_read_buffer(stream, toread TSRMLS_CC);
if (stream->writepos - stream->readpos == 0) {
break;
@@ -1047,7 +1047,7 @@ PHPAPI char *php_stream_get_record(php_stream *stream, size_t maxlen, size_t *re
to_read_now = MIN(maxlen - buffered_len, stream->chunk_size);
php_stream_fill_read_buffer(stream, buffered_len + to_read_now);
php_stream_fill_read_buffer(stream, buffered_len + to_read_now TSRMLS_CC);
just_read = STREAM_BUFFERED_AMOUNT(stream) - buffered_len;

View File

@@ -2718,7 +2718,7 @@ function junit_mark_test_as($type, $file_name, $test_name, $time = null, $messag
if (is_array($type)) {
$output_type = $type[0] . 'ED';
$temp = array_intersect(array('XFAIL', 'FAIL'), $type);
$temp = array_intersect(array('XFAIL', 'FAIL', 'WARN'), $type);
$type = reset($temp);
} else {
$output_type = $type . 'ED';
@@ -2732,6 +2732,9 @@ function junit_mark_test_as($type, $file_name, $test_name, $time = null, $messag
} elseif ('SKIP' == $type) {
junit_suite_record($suite, 'test_skip');
$JUNIT['files'][$file_name]['xml'] .= "<skipped>$escaped_message</skipped>\n";
} elseif ('WARN' == $type) {
junit_suite_record($suite, 'test_warn');
$JUNIT['files'][$file_name]['xml'] .= "<warning>$escaped_message</warning>\n";
} elseif('FAIL' == $type) {
junit_suite_record($suite, 'test_fail');
$JUNIT['files'][$file_name]['xml'] .= "<failure type='$output_type' message='$escaped_message'>$escaped_details</failure>\n";

View File

@@ -3,12 +3,15 @@ dnl $Id$
dnl
PHP_ARG_ENABLE(phpdbg, for phpdbg support,
[ --enable-phpdbg Build phpdbg], no, no)
[ --enable-phpdbg Build phpdbg], no, no)
PHP_ARG_ENABLE(phpdbg-webhelper, for phpdbg web SAPI support,
[ --enable-phpdbg-webhelper Build phpdbg web SAPI support], yes, yes)
PHP_ARG_ENABLE(phpdbg-debug, for phpdbg debug build,
[ --enable-phpdbg-debug Build phpdbg in debug mode], no, no)
[ --enable-phpdbg-debug Build phpdbg in debug mode], no, no)
if test "$PHP_PHPDBG" != "no"; then
if test "$BUILD_PHPDBG" == "" && test "$PHP_PHPDBG" != "no"; then
AC_HEADER_TIOCGWINSZ
AC_DEFINE(HAVE_PHPDBG, 1, [ ])
@@ -18,8 +21,15 @@ if test "$PHP_PHPDBG" != "no"; then
AC_DEFINE(PHPDBG_DEBUG, 0, [ ])
fi
if test "$PHP_PHPDBG_WEBHELPER" != "no"; then
if ! test -d $abs_srcdir/ext/phpdbg_webhelper; then
ln -s ../sapi/phpdbg $abs_srcdir/ext/phpdbg_webhelper
fi
PHP_NEW_EXTENSION(phpdbg_webhelper, phpdbg_rinit_hook.c phpdbg_webdata_transfer.c, $ext_shared)
fi
PHP_PHPDBG_CFLAGS="-D_GNU_SOURCE"
PHP_PHPDBG_FILES="phpdbg.c phpdbg_parser.c phpdbg_lexer.c phpdbg_prompt.c phpdbg_help.c phpdbg_break.c phpdbg_print.c phpdbg_bp.c phpdbg_opcode.c phpdbg_list.c phpdbg_utils.c phpdbg_info.c phpdbg_cmd.c phpdbg_set.c phpdbg_frame.c phpdbg_watch.c phpdbg_btree.c"
PHP_PHPDBG_FILES="phpdbg.c phpdbg_parser.c phpdbg_lexer.c phpdbg_prompt.c phpdbg_help.c phpdbg_break.c phpdbg_print.c phpdbg_bp.c phpdbg_opcode.c phpdbg_list.c phpdbg_utils.c phpdbg_info.c phpdbg_cmd.c phpdbg_set.c phpdbg_frame.c phpdbg_watch.c phpdbg_btree.c phpdbg_sigsafe.c phpdbg_wait.c phpdbg_io.c phpdbg_eol.c phpdbg_out.c"
if test "$PHP_READLINE" != "no" -o "$PHP_LIBEDIT" != "no"; then
PHPDBG_EXTRA_LIBS="$PHP_READLINE_LIBS"

View File

@@ -1,7 +1,12 @@
ARG_ENABLE('phpdbg', 'Build phpdbg', 'no');
ARG_ENABLE('phpdbgs', 'Build phpdbg shared', 'no');
ARG_ENABLE('phpdbg-webhelper', 'Build phpdbg webhelper', 'yes');
PHPDBG_SOURCES='phpdbg.c phpdbg_prompt.c phpdbg_cmd.c phpdbg_info.c phpdbg_help.c phpdbg_break.c phpdbg_print.c phpdbg_bp.c phpdbg_opcode.c phpdbg_list.c phpdbg_utils.c phpdbg_set.c phpdbg_frame.c phpdbg_watch.c phpdbg_win.c phpdbg_btree.c phpdbg_parser.c phpdbg_lexer.c';
PHPDBG_SOURCES='phpdbg.c phpdbg_prompt.c phpdbg_cmd.c phpdbg_info.c phpdbg_help.c phpdbg_break.c ' +
'phpdbg_print.c phpdbg_bp.c phpdbg_opcode.c phpdbg_list.c phpdbg_utils.c ' +
'phpdbg_set.c phpdbg_frame.c phpdbg_watch.c phpdbg_win.c phpdbg_btree.c '+
'phpdbg_parser.c phpdbg_lexer.c phpdbg_sigsafe.c phpdbg_wait.c phpdbg_io.c ' +
'phpdbg_sigio_win32.c phpdbg_eol.c phpdbg_out.c';
PHPDBG_DLL='php' + PHP_VERSION + 'phpdbg.dll';
PHPDBG_EXE='phpdbg.exe';
@@ -9,6 +14,11 @@ if (PHP_PHPDBG == "yes") {
SAPI('phpdbg', PHPDBG_SOURCES, PHPDBG_EXE);
ADD_FLAG("LIBS_PHPDBG", "ws2_32.lib user32.lib");
ADD_FLAG("CFLAGS_PHPDBG", "/D YY_NO_UNISTD_H");
ADD_FLAG("LDFLAGS_PHPDBG", "/stack:8388608");
if (PHP_PHPDBG_WEBHELPER == "yes") {
EXTENSION('phpdbg_webhelper', 'phpdbg_rinit_hook.c phpdbg_webdata_transfer.c');
}
}
if (PHP_PHPDBGS == "yes") {

File diff suppressed because it is too large Load Diff

View File

@@ -21,6 +21,8 @@
#ifndef PHPDBG_H
#define PHPDBG_H
#define PHPDBG_IN_DEV 0
#ifdef PHP_WIN32
# define PHPDBG_API __declspec(dllexport)
#elif defined(__GNUC__) && __GNUC__ >= 4
@@ -29,6 +31,12 @@
# define PHPDBG_API
#endif
#ifndef PHP_WIN32
# include <stdint.h>
# include <stddef.h>
#else
# include "win32/php_stdint.h"
#endif
#include "php.h"
#include "php_globals.h"
#include "php_variables.h"
@@ -40,20 +48,20 @@
#include "zend_ini_scanner.h"
#include "zend_stream.h"
#ifndef _WIN32
# include "zend_signal.h"
# include "zend_signal.h"
#endif
#include "SAPI.h"
#include <fcntl.h>
#include <sys/types.h>
#if defined(_WIN32) && !defined(__MINGW32__)
# include <windows.h>
# include "config.w32.h"
# undef strcasecmp
# undef strncasecmp
# define strcasecmp _stricmp
# define strncasecmp _strnicmp
# include <windows.h>
# include "config.w32.h"
# undef strcasecmp
# undef strncasecmp
# define strcasecmp _stricmp
# define strncasecmp _strnicmp
#else
# include "php_config.h"
# include "php_config.h"
#endif
#ifndef O_BINARY
# define O_BINARY 0
@@ -64,21 +72,41 @@
# include "TSRM.h"
#endif
#ifdef LIBREADLINE
# include <readline/readline.h>
# include <readline/history.h>
#ifdef HAVE_LIBREADLINE
# include <readline/readline.h>
# include <readline/history.h>
#endif
#ifdef HAVE_LIBEDIT
# include <editline/readline.h>
# include <editline/readline.h>
#endif
#include "phpdbg_lexer.h"
#include "phpdbg_cmd.h"
#include "phpdbg_utils.h"
#include "phpdbg_btree.h"
#include "phpdbg_watch.h"
/* {{{ remote console headers */
#ifndef _WIN32
# include <sys/socket.h>
# include <sys/un.h>
# include <sys/select.h>
# include <sys/types.h>
# include <netdb.h>
#endif /* }}} */
int phpdbg_do_parse(phpdbg_param_t *stack, char *input TSRMLS_DC);
/* {{{ strings */
#define PHPDBG_NAME "phpdbg"
#define PHPDBG_AUTHORS "Felipe Pena, Joe Watkins and Bob Weinand" /* Ordered by last name */
#define PHPDBG_URL "http://phpdbg.com"
#define PHPDBG_ISSUES "http://github.com/krakjoe/phpdbg/issues"
#define PHPDBG_VERSION "0.4.0"
#define PHPDBG_INIT_FILENAME ".phpdbginit"
#define PHPDBG_DEFAULT_PROMPT "prompt>"
/* }}} */
/* Hey, apple. One shouldn't define *functions* from the standard C library as marcos. */
#ifdef memcpy
#define memcpy_tmp(...) memcpy(__VA_ARGS__)
#undef memcpy
#define memcpy(...) memcpy_tmp(__VA_ARGS__)
#endif
#if !defined(PHPDBG_WEBDATA_TRANSFER_H) && !defined(PHPDBG_WEBHELPER_H)
#ifdef ZTS
# define PHPDBG_G(v) TSRMG(phpdbg_globals_id, zend_phpdbg_globals *, v)
@@ -86,6 +114,20 @@ int phpdbg_do_parse(phpdbg_param_t *stack, char *input TSRMLS_DC);
# define PHPDBG_G(v) (phpdbg_globals.v)
#endif
#include "phpdbg_sigsafe.h"
#include "phpdbg_out.h"
#include "phpdbg_lexer.h"
#include "phpdbg_cmd.h"
#include "phpdbg_utils.h"
#include "phpdbg_btree.h"
#include "phpdbg_watch.h"
#include "phpdbg_bp.h"
#ifdef PHP_WIN32
# include "phpdbg_sigio_win32.h"
#endif
int phpdbg_do_parse(phpdbg_param_t *stack, char *input TSRMLS_DC);
#define PHPDBG_NEXT 2
#define PHPDBG_UNTIL 3
#define PHPDBG_FINISH 4
@@ -95,84 +137,87 @@ int phpdbg_do_parse(phpdbg_param_t *stack, char *input TSRMLS_DC);
BEGIN: DO NOT CHANGE DO NOT CHANGE DO NOT CHANGE
*/
/* {{{ tables */
#define PHPDBG_BREAK_FILE 0
#define PHPDBG_BREAK_SYM 1
#define PHPDBG_BREAK_OPLINE 2
#define PHPDBG_BREAK_METHOD 3
#define PHPDBG_BREAK_COND 4
#define PHPDBG_BREAK_OPCODE 5
#define PHPDBG_BREAK_FUNCTION_OPLINE 6
#define PHPDBG_BREAK_METHOD_OPLINE 7
#define PHPDBG_BREAK_FILE_OPLINE 8
#define PHPDBG_BREAK_MAP 9
#define PHPDBG_BREAK_TABLES 10 /* }}} */
/* {{{ flags */
#define PHPDBG_HAS_FILE_BP (1<<1)
#define PHPDBG_HAS_SYM_BP (1<<2)
#define PHPDBG_HAS_OPLINE_BP (1<<3)
#define PHPDBG_HAS_METHOD_BP (1<<4)
#define PHPDBG_HAS_COND_BP (1<<5)
#define PHPDBG_HAS_OPCODE_BP (1<<6)
#define PHPDBG_HAS_FUNCTION_OPLINE_BP (1<<7)
#define PHPDBG_HAS_METHOD_OPLINE_BP (1<<8)
#define PHPDBG_HAS_FILE_OPLINE_BP (1<<9) /* }}} */
#define PHPDBG_HAS_FILE_BP (1ULL<<1)
#define PHPDBG_HAS_PENDING_FILE_BP (1ULL<<2)
#define PHPDBG_HAS_SYM_BP (1ULL<<3)
#define PHPDBG_HAS_OPLINE_BP (1ULL<<4)
#define PHPDBG_HAS_METHOD_BP (1ULL<<5)
#define PHPDBG_HAS_COND_BP (1ULL<<6)
#define PHPDBG_HAS_OPCODE_BP (1ULL<<7)
#define PHPDBG_HAS_FUNCTION_OPLINE_BP (1ULL<<8)
#define PHPDBG_HAS_METHOD_OPLINE_BP (1ULL<<9)
#define PHPDBG_HAS_FILE_OPLINE_BP (1ULL<<10) /* }}} */
/*
END: DO NOT CHANGE DO NOT CHANGE DO NOT CHANGE
*/
#define PHPDBG_IN_COND_BP (1<<10)
#define PHPDBG_IN_EVAL (1<<11)
#define PHPDBG_IN_COND_BP (1ULL<<11)
#define PHPDBG_IN_EVAL (1ULL<<12)
#define PHPDBG_IS_STEPPING (1<<12)
#define PHPDBG_STEP_OPCODE (1<<13)
#define PHPDBG_IS_QUIET (1<<14)
#define PHPDBG_IS_QUITTING (1<<15)
#define PHPDBG_IS_COLOURED (1<<16)
#define PHPDBG_IS_CLEANING (1<<17)
#define PHPDBG_IS_STEPPING (1ULL<<13)
#define PHPDBG_STEP_OPCODE (1ULL<<14)
#define PHPDBG_IS_QUIET (1ULL<<15)
#define PHPDBG_IS_QUITTING (1ULL<<16)
#define PHPDBG_IS_COLOURED (1ULL<<17)
#define PHPDBG_IS_CLEANING (1ULL<<18)
#define PHPDBG_IS_RUNNING (1ULL<<19)
#define PHPDBG_IN_UNTIL (1<<18)
#define PHPDBG_IN_FINISH (1<<19)
#define PHPDBG_IN_LEAVE (1<<20)
#define PHPDBG_IN_UNTIL (1ULL<<20)
#define PHPDBG_IN_FINISH (1ULL<<21)
#define PHPDBG_IN_LEAVE (1ULL<<22)
#define PHPDBG_IS_REGISTERED (1<<21)
#define PHPDBG_IS_STEPONEVAL (1<<22)
#define PHPDBG_IS_INITIALIZING (1<<23)
#define PHPDBG_IS_SIGNALED (1<<24)
#define PHPDBG_IS_INTERACTIVE (1<<25)
#define PHPDBG_IS_BP_ENABLED (1<<26)
#define PHPDBG_IS_REMOTE (1<<27)
#define PHPDBG_IS_DISCONNECTED (1<<28)
#define PHPDBG_IS_REGISTERED (1ULL<<23)
#define PHPDBG_IS_STEPONEVAL (1ULL<<24)
#define PHPDBG_IS_INITIALIZING (1ULL<<25)
#define PHPDBG_IS_SIGNALED (1ULL<<26)
#define PHPDBG_IS_INTERACTIVE (1ULL<<27)
#define PHPDBG_IS_BP_ENABLED (1ULL<<28)
#define PHPDBG_IS_REMOTE (1ULL<<29)
#define PHPDBG_IS_DISCONNECTED (1ULL<<30)
#define PHPDBG_WRITE_XML (1ULL<<31)
#define PHPDBG_SHOW_REFCOUNTS (1<<29)
#define PHPDBG_SHOW_REFCOUNTS (1ULL<<32)
#define PHPDBG_SEEK_MASK (PHPDBG_IN_UNTIL|PHPDBG_IN_FINISH|PHPDBG_IN_LEAVE)
#define PHPDBG_BP_RESOLVE_MASK (PHPDBG_HAS_FUNCTION_OPLINE_BP|PHPDBG_HAS_METHOD_OPLINE_BP|PHPDBG_HAS_FILE_OPLINE_BP)
#define PHPDBG_BP_MASK (PHPDBG_HAS_FILE_BP|PHPDBG_HAS_SYM_BP|PHPDBG_HAS_METHOD_BP|PHPDBG_HAS_OPLINE_BP|PHPDBG_HAS_COND_BP|PHPDBG_HAS_OPCODE_BP|PHPDBG_HAS_FUNCTION_OPLINE_BP|PHPDBG_HAS_METHOD_OPLINE_BP|PHPDBG_HAS_FILE_OPLINE_BP)
#define PHPDBG_IN_SIGNAL_HANDLER (1ULL<<33)
#define PHPDBG_DISCARD_OUTPUT (1ULL<<34)
#define PHPDBG_SEEK_MASK (PHPDBG_IN_UNTIL | PHPDBG_IN_FINISH | PHPDBG_IN_LEAVE)
#define PHPDBG_BP_RESOLVE_MASK (PHPDBG_HAS_FUNCTION_OPLINE_BP | PHPDBG_HAS_METHOD_OPLINE_BP | PHPDBG_HAS_FILE_OPLINE_BP)
#define PHPDBG_BP_MASK (PHPDBG_HAS_FILE_BP | PHPDBG_HAS_SYM_BP | PHPDBG_HAS_METHOD_BP | PHPDBG_HAS_OPLINE_BP | PHPDBG_HAS_COND_BP | PHPDBG_HAS_OPCODE_BP | PHPDBG_HAS_FUNCTION_OPLINE_BP | PHPDBG_HAS_METHOD_OPLINE_BP | PHPDBG_HAS_FILE_OPLINE_BP)
#define PHPDBG_IS_STOPPING (PHPDBG_IS_QUITTING | PHPDBG_IS_CLEANING)
#define PHPDBG_PRESERVE_FLAGS_MASK (PHPDBG_SHOW_REFCOUNTS | PHPDBG_IS_STEPONEVAL | PHPDBG_IS_BP_ENABLED | PHPDBG_STEP_OPCODE | PHPDBG_IS_QUIET | PHPDBG_IS_COLOURED | PHPDBG_IS_REMOTE | PHPDBG_WRITE_XML | PHPDBG_IS_DISCONNECTED)
#ifndef _WIN32
# define PHPDBG_DEFAULT_FLAGS (PHPDBG_IS_QUIET|PHPDBG_IS_COLOURED|PHPDBG_IS_BP_ENABLED)
# define PHPDBG_DEFAULT_FLAGS (PHPDBG_IS_QUIET | PHPDBG_IS_COLOURED | PHPDBG_IS_BP_ENABLED)
#else
# define PHPDBG_DEFAULT_FLAGS (PHPDBG_IS_QUIET|PHPDBG_IS_BP_ENABLED)
# define PHPDBG_DEFAULT_FLAGS (PHPDBG_IS_QUIET | PHPDBG_IS_BP_ENABLED)
#endif /* }}} */
/* {{{ strings */
#define PHPDBG_NAME "phpdbg"
#define PHPDBG_AUTHORS "Felipe Pena, Joe Watkins and Bob Weinand" /* Ordered by last name */
#define PHPDBG_URL "http://phpdbg.com"
#define PHPDBG_ISSUES "http://github.com/krakjoe/phpdbg/issues"
#define PHPDBG_VERSION "0.4.0"
#define PHPDBG_INIT_FILENAME ".phpdbginit"
/* }}} */
/* {{{ output descriptors */
#define PHPDBG_STDIN 0
#define PHPDBG_STDOUT 1
#define PHPDBG_STDERR 2
#define PHPDBG_IO_FDS 3 /* }}} */
#define phpdbg_try_access \
{ \
JMP_BUF *__orig_bailout = PHPDBG_G(sigsegv_bailout); \
JMP_BUF __bailout; \
\
PHPDBG_G(sigsegv_bailout) = &__bailout; \
if (SETJMP(__bailout) == 0) {
#define phpdbg_catch_access \
} else { \
PHPDBG_G(sigsegv_bailout) = __orig_bailout;
#define phpdbg_end_try_access() \
} \
PHPDBG_G(sigsegv_bailout) = __orig_bailout; \
}
/* {{{ structs */
ZEND_BEGIN_MODULE_GLOBALS(phpdbg)
@@ -202,29 +247,54 @@ ZEND_BEGIN_MODULE_GLOBALS(phpdbg)
int bp_count; /* breakpoint count */
int vmret; /* return from last opcode handler execution */
zend_op_array *(*compile_file)(zend_file_handle *file_handle, int type TSRMLS_DC);
HashTable file_sources;
FILE *oplog; /* opline log */
FILE *io[PHPDBG_IO_FDS]; /* io */
struct {
FILE *ptr;
int fd;
} io[PHPDBG_IO_FDS]; /* io */
int eol; /* type of line ending to use */
size_t (*php_stdiop_write)(php_stream *, const char *, size_t TSRMLS_DC);
int in_script_xml; /* in <stream> output mode */
struct {
zend_bool active;
int type;
int fd;
char *tag;
char *msg;
int msglen;
char *xml;
int xmllen;
} err_buf; /* error buffer */
zend_ulong req_id; /* "request id" to keep track of commands */
char *prompt[2]; /* prompt */
const phpdbg_color_t *colors[PHPDBG_COLORS]; /* colors */
char *buffer; /* buffer */
zend_bool last_was_newline; /* check if we don't need to output a newline upon next phpdbg_error or phpdbg_notice */
zend_ulong flags; /* phpdbg flags */
char input_buffer[PHPDBG_MAX_CMD]; /* stdin input buffer */
int input_buflen; /* length of stdin input buffer */
phpdbg_signal_safe_mem sigsafe_mem; /* memory to use in async safe environment (only once!) */
JMP_BUF *sigsegv_bailout; /* bailout address for accesibility probing */
uint64_t flags; /* phpdbg flags */
char *socket_path; /* phpdbg.path ini setting */
char *sapi_name_ptr; /* store sapi name to free it if necessary to not leak memory */
int socket_fd; /* file descriptor to socket (wait command) (-1 if unused) */
int socket_server_fd; /* file descriptor to master socket (wait command) (-1 if unused) */
#ifdef PHP_WIN32
HANDLE sigio_watcher_thread; /* sigio watcher thread handle */
struct win32_sigio_watcher_data swd;
#endif
struct _zend_phpdbg_globals *backup; /* backup of data to store */
ZEND_END_MODULE_GLOBALS(phpdbg) /* }}} */
/* the beginning (= the important part) of the _zend_mm_heap struct defined in Zend/zend_alloc.c
Needed for realizing watchpoints */
struct _zend_mm_heap {
int use_zend_alloc;
void *(*_malloc)(size_t);
void (*_free)(void *);
void *(*_realloc)(void *, size_t);
size_t free_bitmap;
size_t large_free_bitmap;
size_t block_size;
size_t compact_size;
zend_mm_segment *segments_list;
zend_mm_storage *storage;
};
#endif
#endif /* PHPDBG_H */

File diff suppressed because it is too large Load Diff

View File

@@ -21,6 +21,20 @@
#ifndef PHPDBG_BP_H
#define PHPDBG_BP_H
/* {{{ defines */
#define PHPDBG_BREAK_FILE 0
#define PHPDBG_BREAK_FILE_PENDING 1
#define PHPDBG_BREAK_SYM 2
#define PHPDBG_BREAK_OPLINE 3
#define PHPDBG_BREAK_METHOD 4
#define PHPDBG_BREAK_COND 5
#define PHPDBG_BREAK_OPCODE 6
#define PHPDBG_BREAK_FUNCTION_OPLINE 7
#define PHPDBG_BREAK_METHOD_OPLINE 8
#define PHPDBG_BREAK_FILE_OPLINE 9
#define PHPDBG_BREAK_MAP 10
#define PHPDBG_BREAK_TABLES 11 /* }}} */
/* {{{ */
typedef struct _zend_op *phpdbg_opline_ptr_t; /* }}} */
@@ -103,10 +117,12 @@ typedef struct _phpdbg_breakcond_t {
zend_op_array *ops;
} phpdbg_breakcond_t;
/* {{{ Opline breaks API */
/* {{{ Resolving breaks API */
PHPDBG_API void phpdbg_resolve_op_array_breaks(zend_op_array *op_array TSRMLS_DC);
PHPDBG_API int phpdbg_resolve_op_array_break(phpdbg_breakopline_t *brake, zend_op_array *op_array TSRMLS_DC);
PHPDBG_API int phpdbg_resolve_opline_break(phpdbg_breakopline_t *new_break TSRMLS_DC); /* }}} */
PHPDBG_API int phpdbg_resolve_opline_break(phpdbg_breakopline_t *new_break TSRMLS_DC);
PHPDBG_API HashTable *phpdbg_resolve_pending_file_break_ex(const char *file, uint filelen, const char *cur, uint curlen, HashTable *fileht TSRMLS_DC);
PHPDBG_API void phpdbg_resolve_pending_file_break(const char *file TSRMLS_DC); /* }}} */
/* {{{ Breakpoint Creation API */
PHPDBG_API void phpdbg_set_breakpoint_file(const char* filename, long lineno TSRMLS_DC);
@@ -141,6 +157,7 @@ PHPDBG_API phpdbg_breakbase_t *phpdbg_find_breakbase(zend_ulong id TSRMLS_DC);
PHPDBG_API phpdbg_breakbase_t *phpdbg_find_breakbase_ex(zend_ulong id, HashTable ***table, HashPosition *position TSRMLS_DC); /* }}} */
/* {{{ Breakpoint Exportation API */
PHPDBG_API void phpdbg_export_breakpoints(FILE *handle TSRMLS_DC); /* }}} */
PHPDBG_API void phpdbg_export_breakpoints(FILE *handle TSRMLS_DC);
PHPDBG_API void phpdbg_export_breakpoints_to_string(char **str TSRMLS_DC); /* }}} */
#endif /* PHPDBG_BP_H */

View File

@@ -28,15 +28,15 @@
ZEND_EXTERN_MODULE_GLOBALS(phpdbg);
#define PHPDBG_BREAK_COMMAND_D(f, h, a, m, l, s) \
PHPDBG_COMMAND_D_EXP(f, h, a, m, l, s, &phpdbg_prompt_commands[10])
#define PHPDBG_BREAK_COMMAND_D(f, h, a, m, l, s, flags) \
PHPDBG_COMMAND_D_EXP(f, h, a, m, l, s, &phpdbg_prompt_commands[10], flags)
/**
* Commands
*/
const phpdbg_command_t phpdbg_break_commands[] = {
PHPDBG_BREAK_COMMAND_D(at, "specify breakpoint by location and condition", '@', break_at, NULL, "*c"),
PHPDBG_BREAK_COMMAND_D(del, "delete breakpoint by identifier number", '~', break_del, NULL, "n"),
PHPDBG_BREAK_COMMAND_D(at, "specify breakpoint by location and condition", '@', break_at, NULL, "*c", 0),
PHPDBG_BREAK_COMMAND_D(del, "delete breakpoint by identifier number", '~', break_del, NULL, "n", 0),
PHPDBG_END_COMMAND
};

View File

@@ -23,6 +23,7 @@
#include "phpdbg_utils.h"
#include "phpdbg_set.h"
#include "phpdbg_prompt.h"
#include "phpdbg_io.h"
ZEND_EXTERN_MODULE_GLOBALS(phpdbg);
@@ -39,7 +40,7 @@ static inline const char *phpdbg_command_name(const phpdbg_command_t *command, c
memcpy(&buffer[pos], command->name, command->name_len);
pos += command->name_len;
buffer[pos] = 0;
return buffer;
}
@@ -69,79 +70,6 @@ PHPDBG_API const char *phpdbg_get_param_type(const phpdbg_param_t *param TSRMLS_
}
}
PHPDBG_API phpdbg_param_type phpdbg_parse_param(const char *str, size_t len, phpdbg_param_t *param TSRMLS_DC) /* {{{ */
{
char *class_name, *func_name;
if (len == 0) {
param->type = EMPTY_PARAM;
goto parsed;
}
if (phpdbg_is_addr(str)) {
param->addr = strtoul(str, 0, 16);
param->type = ADDR_PARAM;
goto parsed;
} else if (phpdbg_is_numeric(str)) {
param->num = strtol(str, NULL, 0);
param->type = NUMERIC_PARAM;
goto parsed;
} else if (phpdbg_is_class_method(str, len+1, &class_name, &func_name)) {
param->method.class = class_name;
param->method.name = func_name;
param->type = METHOD_PARAM;
goto parsed;
} else {
char *line_pos = strrchr(str, ':');
if (line_pos && phpdbg_is_numeric(line_pos+1)) {
if (strchr(str, ':') == line_pos) {
char path[MAXPATHLEN];
memcpy(path, str, line_pos - str);
path[line_pos - str] = 0;
*line_pos = 0;
param->file.name = phpdbg_resolve_path(path TSRMLS_CC);
param->file.line = strtol(line_pos+1, NULL, 0);
param->type = FILE_PARAM;
goto parsed;
}
}
line_pos = strrchr(str, '#');
if (line_pos && phpdbg_is_numeric(line_pos+1)) {
if (strchr(str, '#') == line_pos) {
param->num = strtol(line_pos + 1, NULL, 0);
if (phpdbg_is_class_method(str, line_pos - str, &class_name, &func_name)) {
param->method.class = class_name;
param->method.name = func_name;
param->type = NUMERIC_METHOD_PARAM;
} else {
param->len = line_pos - str;
param->str = estrndup(str, param->len);
param->type = NUMERIC_FUNCTION_PARAM;
}
goto parsed;
}
}
}
param->str = estrndup(str, len);
param->len = len;
param->type = STR_PARAM;
parsed:
phpdbg_debug("phpdbg_parse_param(\"%s\", %lu): %s",
str, len, phpdbg_get_param_type(param TSRMLS_CC));
return param->type;
} /* }}} */
PHPDBG_API void phpdbg_clear_param(phpdbg_param_t *param TSRMLS_DC) /* {{{ */
{
if (param) {
@@ -231,12 +159,12 @@ PHPDBG_API void phpdbg_copy_param(const phpdbg_param_t* src, phpdbg_param_t* des
case STACK_PARAM:
/* nope */
break;
case STR_PARAM:
dest->str = estrndup(src->str, src->len);
dest->len = src->len;
break;
case OP_PARAM:
dest->str = estrndup(src->str, src->len);
dest->len = src->len;
@@ -276,7 +204,7 @@ PHPDBG_API void phpdbg_copy_param(const phpdbg_param_t* src, phpdbg_param_t* des
break;
case EMPTY_PARAM: { /* do nothing */ } break;
default: {
/* not yet */
}
@@ -291,7 +219,7 @@ PHPDBG_API zend_ulong phpdbg_hash_param(const phpdbg_param_t *param TSRMLS_DC) /
case STACK_PARAM:
/* nope */
break;
case STR_PARAM:
hash += zend_inline_hash_func(param->str, param->len);
break;
@@ -329,7 +257,7 @@ PHPDBG_API zend_ulong phpdbg_hash_param(const phpdbg_param_t *param TSRMLS_DC) /
break;
case EMPTY_PARAM: { /* do nothing */ } break;
default: {
/* not yet */
}
@@ -347,7 +275,7 @@ PHPDBG_API zend_bool phpdbg_match_param(const phpdbg_param_t *l, const phpdbg_pa
/* nope, or yep */
return 1;
break;
case NUMERIC_FUNCTION_PARAM:
if (l->num != r->num) {
break;
@@ -402,7 +330,7 @@ PHPDBG_API zend_bool phpdbg_match_param(const phpdbg_param_t *l, const phpdbg_pa
case EMPTY_PARAM:
return 1;
default: {
/* not yet */
}
@@ -419,43 +347,43 @@ PHPDBG_API void phpdbg_param_debug(const phpdbg_param_t *param, const char *msg)
case STR_PARAM:
fprintf(stderr, "%s STR_PARAM(%s=%lu)\n", msg, param->str, param->len);
break;
case ADDR_PARAM:
fprintf(stderr, "%s ADDR_PARAM(%lu)\n", msg, param->addr);
break;
case NUMERIC_FILE_PARAM:
fprintf(stderr, "%s NUMERIC_FILE_PARAM(%s:#%lu)\n", msg, param->file.name, param->file.line);
break;
case FILE_PARAM:
fprintf(stderr, "%s FILE_PARAM(%s:%lu)\n", msg, param->file.name, param->file.line);
break;
case METHOD_PARAM:
fprintf(stderr, "%s METHOD_PARAM(%s::%s)\n", msg, param->method.class, param->method.name);
break;
case NUMERIC_METHOD_PARAM:
fprintf(stderr, "%s NUMERIC_METHOD_PARAM(%s::%s)\n", msg, param->method.class, param->method.name);
break;
case NUMERIC_FUNCTION_PARAM:
fprintf(stderr, "%s NUMERIC_FUNCTION_PARAM(%s::%ld)\n", msg, param->str, param->num);
break;
case NUMERIC_PARAM:
fprintf(stderr, "%s NUMERIC_PARAM(%ld)\n", msg, param->num);
break;
case COND_PARAM:
fprintf(stderr, "%s COND_PARAM(%s=%lu)\n", msg, param->str, param->len);
break;
case OP_PARAM:
fprintf(stderr, "%s OP_PARAM(%s=%lu)\n", msg, param->str, param->len);
break;
default: {
/* not yet */
}
@@ -467,13 +395,13 @@ PHPDBG_API void phpdbg_param_debug(const phpdbg_param_t *param, const char *msg)
PHPDBG_API void phpdbg_stack_free(phpdbg_param_t *stack) {
if (stack && stack->next) {
phpdbg_param_t *remove = stack->next;
while (remove) {
phpdbg_param_t *next = NULL;
if (remove->next)
next = remove->next;
switch (remove->type) {
case NUMERIC_METHOD_PARAM:
case METHOD_PARAM:
@@ -487,29 +415,30 @@ PHPDBG_API void phpdbg_stack_free(phpdbg_param_t *stack) {
case STR_PARAM:
case OP_PARAM:
if (remove->str)
free(remove->str);
free(remove->str);
break;
case NUMERIC_FILE_PARAM:
case FILE_PARAM:
if (remove->file.name)
free(remove->file.name);
break;
default: {
/* nothing */
}
}
free(remove);
remove = NULL;
if (next)
remove = next;
remove = next;
else break;
}
}
stack->next = NULL;
} /* }}} */
@@ -537,30 +466,29 @@ PHPDBG_API void phpdbg_stack_push(phpdbg_param_t *stack, phpdbg_param_t *param)
stack->len++;
} /* }}} */
PHPDBG_API int phpdbg_stack_verify(const phpdbg_command_t *command, phpdbg_param_t **stack, char **why TSRMLS_DC) {
PHPDBG_API int phpdbg_stack_verify(const phpdbg_command_t *command, phpdbg_param_t **stack TSRMLS_DC) {
if (command) {
char buffer[128] = {0,};
const phpdbg_param_t *top = (stack != NULL) ? *stack : NULL;
const char *arg = command->args;
size_t least = 0L,
received = 0L,
current = 0L;
received = 0L,
current = 0L;
zend_bool optional = 0;
/* check for arg spec */
if (!(arg) || !(*arg)) {
if (!top) {
return SUCCESS;
}
asprintf(why,
"The command \"%s\" expected no arguments",
phpdbg_error("command", "type=\"toomanyargs\" command=\"%s\" expected=\"0\"", "The command \"%s\" expected no arguments",
phpdbg_command_name(command, buffer));
return FAILURE;
}
least = 0L;
/* count least amount of arguments */
while (arg && *arg) {
if (arg[0] == '|') {
@@ -569,21 +497,19 @@ PHPDBG_API int phpdbg_stack_verify(const phpdbg_command_t *command, phpdbg_param
least++;
arg++;
}
arg = command->args;
#define verify_arg(e, a, t) if (!(a)) { \
if (!optional) { \
asprintf(why, \
"The command \"%s\" expected %s and got nothing at parameter %lu", \
phpdbg_error("command", "type=\"noarg\" command=\"%s\" expected=\"%s\" num=\"%lu\"", "The command \"%s\" expected %s and got nothing at parameter %lu", \
phpdbg_command_name(command, buffer), \
(e), \
current); \
return FAILURE;\
} \
} else if ((a)->type != (t)) { \
asprintf(why, \
"The command \"%s\" expected %s and got %s at parameter %lu", \
phpdbg_error("command", "type=\"wrongarg\" command=\"%s\" expected=\"%s\" got=\"%s\" num=\"%lu\"", "The command \"%s\" expected %s and got %s at parameter %lu", \
phpdbg_command_name(command, buffer), \
(e),\
phpdbg_get_param_type((a) TSRMLS_CC), \
@@ -593,14 +519,14 @@ PHPDBG_API int phpdbg_stack_verify(const phpdbg_command_t *command, phpdbg_param
while (arg && *arg) {
current++;
switch (*arg) {
case '|': {
current--;
optional = 1;
arg++;
} continue;
case 'i': verify_arg("raw input", top, STR_PARAM); break;
case 's': verify_arg("string", top, STR_PARAM); break;
case 'n': verify_arg("number", top, NUMERIC_PARAM); break;
@@ -610,14 +536,14 @@ PHPDBG_API int phpdbg_stack_verify(const phpdbg_command_t *command, phpdbg_param
case 'c': verify_arg("condition", top, COND_PARAM); break;
case 'o': verify_arg("opcode", top, OP_PARAM); break;
case 'b': verify_arg("boolean", top, NUMERIC_PARAM); break;
case '*': { /* do nothing */ } break;
}
if (top ) {
top = top->next;
} else break;
received++;
arg++;
}
@@ -625,28 +551,27 @@ PHPDBG_API int phpdbg_stack_verify(const phpdbg_command_t *command, phpdbg_param
#undef verify_arg
if ((received < least)) {
asprintf(why,
"The command \"%s\" expected at least %lu arguments (%s) and received %lu",
phpdbg_error("command", "type=\"toofewargs\" command=\"%s\" expected=\"%d\" argtypes=\"%s\" got=\"%d\"", "The command \"%s\" expected at least %lu arguments (%s) and received %lu",
phpdbg_command_name(command, buffer),
least,
command->args,
command->args,
received);
return FAILURE;
}
}
return SUCCESS;
}
/* {{{ */
PHPDBG_API const phpdbg_command_t* phpdbg_stack_resolve(const phpdbg_command_t *commands, const phpdbg_command_t *parent, phpdbg_param_t **top, char **why) {
PHPDBG_API const phpdbg_command_t *phpdbg_stack_resolve(const phpdbg_command_t *commands, const phpdbg_command_t *parent, phpdbg_param_t **top TSRMLS_DC) {
const phpdbg_command_t *command = commands;
phpdbg_param_t *name = *top;
const phpdbg_command_t *matched[3] = {NULL, NULL, NULL};
ulong matches = 0L;
while (command && command->name && command->handler) {
if ((name->len == 1) || (command->name_len >= name->len)) {
if (name->len == 1 || command->name_len >= name->len) {
/* match single letter alias */
if (command->alias && (name->len == 1)) {
if (command->alias == (*name->str)) {
@@ -654,85 +579,76 @@ PHPDBG_API const phpdbg_command_t* phpdbg_stack_resolve(const phpdbg_command_t *
matches++;
}
} else {
/* match full, case insensitive, command name */
if (strncasecmp(command->name, name->str, name->len) == SUCCESS) {
if (matches < 3) {
/* only allow abbreviating commands that can be aliased */
if (((name->len != command->name_len) && command->alias) ||
(name->len == command->name_len)) {
if ((name->len != command->name_len && command->alias) || name->len == command->name_len) {
matched[matches] = command;
matches++;
}
/* exact match */
if (name->len == command->name_len)
if (name->len == command->name_len) {
break;
} else break;
}
} else {
break;
}
}
}
}
command++;
}
switch (matches) {
case 0: {
case 0:
if (parent) {
asprintf(
why,
"The command \"%s %s\" could not be found",
parent->name, name->str);
} else asprintf(
why,
"The command \"%s\" could not be found",
name->str);
} return parent;
case 1: {
phpdbg_error("command", "type=\"notfound\" command=\"%s\" subcommand=\"%s\"", "The command \"%s %s\" could not be found", parent->name, name->str);
} else {
phpdbg_error("command", "type=\"notfound\" command=\"%s\"", "The command \"%s\" could not be found", name->str);
}
return parent;
case 1:
(*top) = (*top)->next;
command = matched[0];
} break;
break;
default: {
char *list = NULL;
zend_uint it = 0;
size_t pos = 0;
while (it < matches) {
if (!list) {
list = malloc(
matched[it]->name_len + 1 +
((it+1) < matches ? sizeof(", ")-1 : 0));
list = emalloc(matched[it]->name_len + 1 + (it + 1 < matches ? sizeof(", ") - 1 : 0));
} else {
list = realloc(list,
(pos + matched[it]->name_len) + 1 +
((it+1) < matches ? sizeof(", ")-1 : 0));
list = erealloc(list, (pos + matched[it]->name_len) + 1 + (it + 1 < matches ? sizeof(", ") - 1 : 0));
}
memcpy(&list[pos], matched[it]->name, matched[it]->name_len);
pos += matched[it]->name_len;
if ((it+1) < matches) {
memcpy(&list[pos], ", ", sizeof(", ")-1);
if ((it + 1) < matches) {
memcpy(&list[pos], ", ", sizeof(", ") - 1);
pos += (sizeof(", ") - 1);
}
list[pos] = 0;
it++;
}
asprintf(
why,
"The command \"%s\" is ambigious, matching %lu commands (%s)",
name->str, matches, list);
free(list);
} return NULL;
/* ", " separated matches */
phpdbg_error("command", "type=\"ambiguous\" command=\"%s\" matches=\"%lu\" matched=\"%s\"", "The command \"%s\" is ambigious, matching %lu commands (%s)", name->str, matches, list);
efree(list);
return NULL;
}
}
if (command->subs && (*top) && ((*top)->type == STR_PARAM)) {
return phpdbg_stack_resolve(command->subs, command, top, why);
return phpdbg_stack_resolve(command->subs, command, top TSRMLS_CC);
} else {
return command;
}
@@ -741,102 +657,97 @@ PHPDBG_API const phpdbg_command_t* phpdbg_stack_resolve(const phpdbg_command_t *
} /* }}} */
/* {{{ */
PHPDBG_API int phpdbg_stack_execute(phpdbg_param_t *stack, char **why TSRMLS_DC) {
PHPDBG_API int phpdbg_stack_execute(phpdbg_param_t *stack, zend_bool allow_async_unsafe TSRMLS_DC) {
phpdbg_param_t *top = NULL;
const phpdbg_command_t *handler = NULL;
if (stack->type != STACK_PARAM) {
asprintf(
why, "The passed argument was not a stack !!");
phpdbg_error("command", "type=\"nostack\"", "The passed argument was not a stack !");
return FAILURE;
}
if (!stack->len) {
asprintf(
why, "The stack contains nothing !!");
phpdbg_error("command", "type=\"emptystack\"", "The stack contains nothing !");
return FAILURE;
}
top = (phpdbg_param_t*) stack->next;
top = (phpdbg_param_t *) stack->next;
switch (top->type) {
case EVAL_PARAM:
phpdbg_activate_err_buf(0 TSRMLS_CC);
phpdbg_free_err_buf(TSRMLS_C);
return PHPDBG_COMMAND_HANDLER(ev)(top TSRMLS_CC);
case RUN_PARAM:
if (!allow_async_unsafe) {
phpdbg_error("signalsegv", "command=\"run\"", "run command is disallowed during hard interrupt");
}
phpdbg_activate_err_buf(0 TSRMLS_CC);
phpdbg_free_err_buf(TSRMLS_C);
return PHPDBG_COMMAND_HANDLER(run)(top TSRMLS_CC);
case SHELL_PARAM:
if (!allow_async_unsafe) {
phpdbg_error("signalsegv", "command=\"sh\"", "sh command is disallowed during hard interrupt");
return FAILURE;
}
phpdbg_activate_err_buf(0 TSRMLS_CC);
phpdbg_free_err_buf(TSRMLS_C);
return PHPDBG_COMMAND_HANDLER(sh)(top TSRMLS_CC);
case STR_PARAM: {
handler = phpdbg_stack_resolve(
phpdbg_prompt_commands, NULL, &top, why);
handler = phpdbg_stack_resolve(phpdbg_prompt_commands, NULL, &top TSRMLS_CC);
if (handler) {
if (phpdbg_stack_verify(handler, &top, why TSRMLS_CC) == SUCCESS) {
if (!allow_async_unsafe && !(handler->flags & PHPDBG_ASYNC_SAFE)) {
phpdbg_error("signalsegv", "command=\"%s\"", "%s command is disallowed during hard interrupt", handler->name);
return FAILURE;
}
if (phpdbg_stack_verify(handler, &top TSRMLS_CC) == SUCCESS) {
phpdbg_activate_err_buf(0 TSRMLS_CC);
phpdbg_free_err_buf(TSRMLS_C);
return handler->handler(top TSRMLS_CC);
}
}
} return FAILURE;
default:
asprintf(
why, "The first parameter makes no sense !!");
phpdbg_error("command", "type=\"invalidcommand\"", "The first parameter makes no sense !");
return FAILURE;
}
return SUCCESS;
} /* }}} */
PHPDBG_API char* phpdbg_read_input(char *buffered TSRMLS_DC) /* {{{ */
PHPDBG_API char *phpdbg_read_input(char *buffered TSRMLS_DC) /* {{{ */
{
char *cmd = NULL;
#if !defined(HAVE_LIBREADLINE) && !defined(HAVE_LIBEDIT)
char buf[PHPDBG_MAX_CMD];
#endif
char *cmd = NULL;
char *buffer = NULL;
if (!(PHPDBG_G(flags) & PHPDBG_IS_QUITTING)) {
if ((PHPDBG_G(flags) & PHPDBG_IS_REMOTE) &&
(buffered == NULL)) {
fflush(PHPDBG_G(io)[PHPDBG_STDOUT]);
if ((PHPDBG_G(flags) & (PHPDBG_IS_STOPPING | PHPDBG_IS_RUNNING)) != PHPDBG_IS_STOPPING) {
if ((PHPDBG_G(flags) & PHPDBG_IS_REMOTE) && (buffered == NULL) && !phpdbg_active_sigsafe_mem(TSRMLS_C)) {
fflush(PHPDBG_G(io)[PHPDBG_STDOUT].ptr);
}
if (buffered == NULL) {
disconnect:
if (0) {
PHPDBG_G(flags) |= (PHPDBG_IS_QUITTING|PHPDBG_IS_DISCONNECTED);
zend_bailout();
return NULL;
}
#if !defined(HAVE_LIBREADLINE) && !defined(HAVE_LIBEDIT)
if (!(PHPDBG_G(flags) & PHPDBG_IS_REMOTE)) {
if (!phpdbg_write("%s", phpdbg_get_prompt(TSRMLS_C))) {
goto disconnect;
}
}
/* note: EOF is ignored */
readline:
if (!fgets(buf, PHPDBG_MAX_CMD, PHPDBG_G(io)[PHPDBG_STDIN])) {
/* the user has gone away */
if ((PHPDBG_G(flags) & PHPDBG_IS_REMOTE)) {
goto disconnect;
} else goto readline;
}
cmd = buf;
#else
/* note: EOF makes readline write prompt again in local console mode */
#define USE_LIB_STAR (defined(HAVE_LIBREADLINE) || defined(HAVE_LIBEDIT))
/* note: EOF makes readline write prompt again in local console mode - and ignored if compiled without readline */
#if USE_LIB_STAR
readline:
if ((PHPDBG_G(flags) & PHPDBG_IS_REMOTE)) {
char buf[PHPDBG_MAX_CMD];
if (fgets(buf, PHPDBG_MAX_CMD, PHPDBG_G(io)[PHPDBG_STDIN])) {
cmd = buf;
} else goto disconnect;
} else cmd = readline(phpdbg_get_prompt(TSRMLS_C));
if (PHPDBG_G(flags) & PHPDBG_IS_REMOTE)
#endif
{
phpdbg_write("prompt", "", "%s", phpdbg_get_prompt(TSRMLS_C));
phpdbg_consume_stdin_line(cmd = buf TSRMLS_CC);
}
#if USE_LIB_STAR
else {
cmd = readline(phpdbg_get_prompt(TSRMLS_C));
PHPDBG_G(last_was_newline) = 1;
}
if (!cmd) {
goto readline;
@@ -846,13 +757,14 @@ readline:
add_history(cmd);
}
#endif
} else cmd = buffered;
} else {
cmd = buffered;
}
buffer = estrdup(cmd);
#if defined(HAVE_LIBREADLINE) || defined(HAVE_LIBEDIT)
if (!buffered && cmd &&
!(PHPDBG_G(flags) & PHPDBG_IS_REMOTE)) {
#if USE_LIB_STAR
if (!buffered && cmd && !(PHPDBG_G(flags) & PHPDBG_IS_REMOTE)) {
free(cmd);
}
#endif
@@ -878,7 +790,7 @@ readline:
buffer = estrdup(PHPDBG_G(buffer));
}
}
return buffer;
} /* }}} */
@@ -887,3 +799,23 @@ PHPDBG_API void phpdbg_destroy_input(char **input TSRMLS_DC) /*{{{ */
efree(*input);
} /* }}} */
PHPDBG_API int phpdbg_ask_user_permission(const char *question TSRMLS_DC) {
if (!(PHPDBG_G(flags) & PHPDBG_WRITE_XML)) {
char buf[PHPDBG_MAX_CMD];
phpdbg_out("%s", question);
phpdbg_out(" (type y or n): ");
while (1) {
phpdbg_consume_stdin_line(buf TSRMLS_CC);
if (buf[1] == '\n' && (buf[0] == 'y' || buf[0] == 'n')) {
if (buf[0] == 'y') {
return SUCCESS;
}
return FAILURE;
}
phpdbg_out("Please enter either y (yes) or n (no): ");
}
}
return SUCCESS;
}

View File

@@ -86,6 +86,8 @@ struct _phpdbg_param {
#define YYSTYPE phpdbg_param_t
#endif
#define PHPDBG_ASYNC_SAFE 1
typedef int (*phpdbg_command_handler_t)(const phpdbg_param_t* TSRMLS_DC);
typedef struct _phpdbg_command_t phpdbg_command_t;
@@ -97,8 +99,9 @@ struct _phpdbg_command_t {
char alias; /* Alias */
phpdbg_command_handler_t handler; /* Command handler */
const phpdbg_command_t *subs; /* Sub Commands */
char *args; /* Argument Spec */
const phpdbg_command_t *parent; /* Parent Command */
char *args; /* Argument Spec */
const phpdbg_command_t *parent; /* Parent Command */
zend_bool flags; /* General flags */
};
/* }}} */
@@ -106,7 +109,7 @@ struct _phpdbg_command_t {
#define PHPDBG_STRL(s) s, sizeof(s)-1
#define PHPDBG_MAX_CMD 500
#define PHPDBG_FRAME(v) (PHPDBG_G(frame).v)
#define PHPDBG_EX(v) (EG(current_execute_data)->v)
#define PHPDBG_EX(v) (EG(current_execute_data)->v)
typedef struct {
int num;
@@ -128,20 +131,20 @@ typedef struct {
*/
PHPDBG_API char* phpdbg_read_input(char *buffered TSRMLS_DC);
PHPDBG_API void phpdbg_destroy_input(char** TSRMLS_DC);
PHPDBG_API int phpdbg_ask_user_permission(const char *question TSRMLS_DC);
/**
* Stack Management
*/
PHPDBG_API void phpdbg_stack_push(phpdbg_param_t *stack, phpdbg_param_t *param);
PHPDBG_API const phpdbg_command_t* phpdbg_stack_resolve(const phpdbg_command_t *commands, const phpdbg_command_t *parent, phpdbg_param_t **top, char **why);
PHPDBG_API int phpdbg_stack_verify(const phpdbg_command_t *command, phpdbg_param_t **stack, char **why TSRMLS_DC);
PHPDBG_API int phpdbg_stack_execute(phpdbg_param_t *stack, char **why TSRMLS_DC);
PHPDBG_API const phpdbg_command_t *phpdbg_stack_resolve(const phpdbg_command_t *commands, const phpdbg_command_t *parent, phpdbg_param_t **top TSRMLS_DC);
PHPDBG_API int phpdbg_stack_verify(const phpdbg_command_t *command, phpdbg_param_t **stack TSRMLS_DC);
PHPDBG_API int phpdbg_stack_execute(phpdbg_param_t *stack, zend_bool allow_async_unsafe TSRMLS_DC);
PHPDBG_API void phpdbg_stack_free(phpdbg_param_t *stack);
/*
* Parameter Management
*/
PHPDBG_API phpdbg_param_type phpdbg_parse_param(const char*, size_t, phpdbg_param_t* TSRMLS_DC);
PHPDBG_API void phpdbg_clear_param(phpdbg_param_t* TSRMLS_DC);
PHPDBG_API void phpdbg_copy_param(const phpdbg_param_t*, phpdbg_param_t* TSRMLS_DC);
PHPDBG_API zend_bool phpdbg_match_param(const phpdbg_param_t *, const phpdbg_param_t * TSRMLS_DC);
@@ -155,27 +158,27 @@ PHPDBG_API void phpdbg_param_debug(const phpdbg_param_t *param, const char *msg)
*/
#define PHPDBG_COMMAND_HANDLER(name) phpdbg_do_##name
#define PHPDBG_COMMAND_D_EXP(name, tip, alias, handler, children, args, parent) \
{PHPDBG_STRL(#name), tip, sizeof(tip)-1, alias, phpdbg_do_##handler, children, args, parent}
#define PHPDBG_COMMAND_D_EXP(name, tip, alias, handler, children, args, parent, flags) \
{PHPDBG_STRL(#name), tip, sizeof(tip)-1, alias, phpdbg_do_##handler, children, args, parent, flags}
#define PHPDBG_COMMAND_D_EX(name, tip, alias, handler, children, args) \
{PHPDBG_STRL(#name), tip, sizeof(tip)-1, alias, phpdbg_do_##handler, children, args, NULL}
#define PHPDBG_COMMAND_D_EX(name, tip, alias, handler, children, args, flags) \
{PHPDBG_STRL(#name), tip, sizeof(tip)-1, alias, phpdbg_do_##handler, children, args, NULL, flags}
#define PHPDBG_COMMAND_D(name, tip, alias, children, args) \
{PHPDBG_STRL(#name), tip, sizeof(tip)-1, alias, phpdbg_do_##name, children, args, NULL}
#define PHPDBG_COMMAND_D(name, tip, alias, children, args, flags) \
{PHPDBG_STRL(#name), tip, sizeof(tip)-1, alias, phpdbg_do_##name, children, args, NULL, flags}
#define PHPDBG_COMMAND(name) int phpdbg_do_##name(const phpdbg_param_t *param TSRMLS_DC)
#define PHPDBG_COMMAND_ARGS param TSRMLS_CC
#define PHPDBG_END_COMMAND {NULL, 0, NULL, 0, '\0', NULL, NULL, '\0', NULL}
#define PHPDBG_END_COMMAND {NULL, 0, NULL, 0, '\0', NULL, NULL, NULL, NULL, 0}
/*
* Default Switch Case
*/
#define phpdbg_default_switch_case() \
default: \
phpdbg_error("Unsupported parameter type (%s) for command", phpdbg_get_param_type(param TSRMLS_CC)); \
phpdbg_error("command", "type=\"wrongarg\" got=\"%s\"", "Unsupported parameter type (%s) for command", phpdbg_get_param_type(param TSRMLS_CC)); \
break
#endif /* PHPDBG_CMD_H */

172
sapi/phpdbg/phpdbg_eol.c Normal file
View File

@@ -0,0 +1,172 @@
/*
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2014 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Anatol Belski <ab@php.net> |
+----------------------------------------------------------------------+
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "phpdbg.h"
#include "phpdbg_eol.h"
ZEND_EXTERN_MODULE_GLOBALS(phpdbg);
#define EOL_LIST_LEN 4
struct phpdbg_eol_rep phpdbg_eol_list[EOL_LIST_LEN] = {
{"CRLF", "\r\n", PHPDBG_EOL_CRLF},
/* {"LFCR", "\n\r", PHPDBG_EOL_LFCR},*/
{"LF", "\n", PHPDBG_EOL_LF},
{"CR", "\r", PHPDBG_EOL_CR},
};
int phpdbg_eol_global_update(char *name TSRMLS_DC)
{
if (0 == memcmp(name, "CRLF", 4) || 0 == memcmp(name, "crlf", 4) || 0 == memcmp(name, "DOS", 3) || 0 == memcmp(name, "dos", 3)) {
PHPDBG_G(eol) = PHPDBG_EOL_CRLF;
} else if (0 == memcmp(name, "LF", 2) || 0 == memcmp(name, "lf", 2) || 0 == memcmp(name, "UNIX", 4) || 0 == memcmp(name, "unix", 4)) {
PHPDBG_G(eol) = PHPDBG_EOL_LF;
} else if (0 == memcmp(name, "CR", 2) || 0 == memcmp(name, "cr", 2) || 0 == memcmp(name, "MAC", 3) || 0 == memcmp(name, "mac", 3)) {
PHPDBG_G(eol) = PHPDBG_EOL_CR;
} else {
return FAILURE;
}
return SUCCESS;
}
char *phpdbg_eol_name(int id)
{
size_t i = 0;
while (i < EOL_LIST_LEN) {
if (id == phpdbg_eol_list[i].id) {
return phpdbg_eol_list[i].name;
}
i++;
}
return NULL;
}
char *phpdbg_eol_rep(int id)
{
size_t i = 0;
while (i < EOL_LIST_LEN) {
if (id == phpdbg_eol_list[i].id) {
return phpdbg_eol_list[i].rep;
}
i++;
}
return NULL;
}
/* Inspired by https://ccrma.stanford.edu/~craig/utility/flip/flip.cpp */
void phpdbg_eol_convert(char **str, int *len TSRMLS_DC)
{
char *in = *str, *out ;
int in_len = *len, out_len, cursor, i;
char last, cur;
if ((PHPDBG_G(flags) & PHPDBG_IS_REMOTE) != PHPDBG_IS_REMOTE) {
return;
}
out_len = *len;
if (PHPDBG_EOL_CRLF == PHPDBG_G(eol)) { /* XXX add LFCR case if it's gonna be needed */
/* depending on the source EOL the out str will have all CR/LF duplicated */
for (i = 0; i < in_len; i++) {
if (0x0a == in[i] || 0x0d == in[i]) {
out_len++;
}
}
out = (char *)emalloc(out_len);
last = cur = in[0];
i = cursor = 0;
for (; i < in_len;) {
if (0x0a == cur && last != 0x0d) {
out[cursor] = 0x0d;
cursor++;
out[cursor] = cur;
} else if(0x0d == cur) {
if (i + 1 < in_len && 0x0a != in[i+1]) {
out[cursor] = cur;
cursor++;
out[cursor] = 0x0a;
last = 0x0a;
} else {
out[cursor] = 0x0d;
last = 0x0d;
}
} else {
out[cursor] = cur;
last = cur;
}
i++;
cursor++;
cur = in[i];
}
} else if (PHPDBG_EOL_LF == PHPDBG_G(eol) || PHPDBG_EOL_CR == PHPDBG_G(eol)) {
char want, kick;
if (PHPDBG_EOL_LF == PHPDBG_G(eol)) {
want = 0x0a;
kick = 0x0d;
} else {
want = 0x0d;
kick = 0x0a;
}
/* We gonna have a smaller or equally long string, estimation is almost neglecting */
out = (char *)emalloc(out_len);
last = cur = in[0];
i = cursor = 0;
for (; cursor < in_len;) {
if (kick == cur) {
out[cursor] = want;
} else if (want == cur) {
if (kick != last) {
out[cursor] = want;
}
} else {
out[cursor] = cur;
}
last = cur;
cursor++;
cur = in[cursor];
}
} else {
return;
}
efree(*str);
*str = erealloc(out, cursor);
*len = cursor;
in = NULL;
}

46
sapi/phpdbg/phpdbg_eol.h Normal file
View File

@@ -0,0 +1,46 @@
/*
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2014 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Anatol Belski <ab@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef PHPDBG_EOL_H
#define PHPDBG_EOL_H
#include "phpdbg.h"
struct phpdbg_eol_rep {
char *name;
char *rep;
int id;
};
enum {
PHPDBG_EOL_CRLF, /* DOS */
/*PHPDBG_EOL_LFCR,*/ /* for Risc OS? */
PHPDBG_EOL_LF, /* UNIX */
PHPDBG_EOL_CR /* MAC */
};
int phpdbg_eol_global_update(char *name TSRMLS_DC);
char *phpdbg_eol_name(int id);
char *phpdbg_eol_rep(int id);
void phpdbg_eol_convert(char **str, int *len TSRMLS_DC);
#endif /* PHPDBG_EOL_H */

View File

@@ -52,22 +52,27 @@ void phpdbg_switch_frame(int frame TSRMLS_DC) /* {{{ */
int i = 0;
if (PHPDBG_FRAME(num) == frame) {
phpdbg_notice("Already in frame #%d", frame);
phpdbg_notice("frame", "id=\"%d\"", "Already in frame #%d", frame);
return;
}
while (execute_data) {
if (i++ == frame) {
break;
}
phpdbg_try_access {
while (execute_data) {
if (i++ == frame) {
break;
}
do {
execute_data = execute_data->prev_execute_data;
} while (execute_data && execute_data->opline == NULL);
}
do {
execute_data = execute_data->prev_execute_data;
} while (execute_data && execute_data->opline == NULL);
}
} phpdbg_catch_access {
phpdbg_error("signalsegv", "", "Couldn't switch frames, invalid data source");
return;
} phpdbg_end_try_access();
if (execute_data == NULL) {
phpdbg_error("No frame #%d", frame);
phpdbg_error("frame", "type=\"maxnum\" id=\"%d\"", "No frame #%d", frame);
return;
}
@@ -90,7 +95,7 @@ void phpdbg_switch_frame(int frame TSRMLS_DC) /* {{{ */
EG(called_scope) = PHPDBG_EX(current_called_scope);
}
phpdbg_notice("Switched to frame #%d", frame);
phpdbg_notice("frame", "id=\"%d\"", "Switched to frame #%d", frame);
phpdbg_list_file(
zend_get_executed_filename(TSRMLS_C),
3,
@@ -104,61 +109,84 @@ static void phpdbg_dump_prototype(zval **tmp TSRMLS_DC) /* {{{ */
{
zval **funcname, **class, **type, **args, **argstmp;
char is_class;
int has_args = FAILURE;
zend_hash_find(Z_ARRVAL_PP(tmp), "function", sizeof("function"),
(void **)&funcname);
zend_hash_find(Z_ARRVAL_PP(tmp), "function", sizeof("function"), (void **) &funcname);
if ((is_class = zend_hash_find(Z_ARRVAL_PP(tmp),
"object", sizeof("object"), (void **)&class)) == FAILURE) {
is_class = zend_hash_find(Z_ARRVAL_PP(tmp), "class", sizeof("class"),
(void **)&class);
if ((is_class = zend_hash_find(Z_ARRVAL_PP(tmp), "object", sizeof("object"), (void **) &class)) == FAILURE) {
is_class = zend_hash_find(Z_ARRVAL_PP(tmp), "class", sizeof("class"), (void **)&class);
} else {
zend_get_object_classname(*class, (const char **)&Z_STRVAL_PP(class),
(zend_uint *)&Z_STRLEN_PP(class) TSRMLS_CC);
zend_get_object_classname(*class, (const char **) &Z_STRVAL_PP(class), (zend_uint *) &Z_STRLEN_PP(class) TSRMLS_CC);
}
if (is_class == SUCCESS) {
zend_hash_find(Z_ARRVAL_PP(tmp), "type", sizeof("type"), (void **)&type);
}
phpdbg_write("%s%s%s(",
has_args = zend_hash_find(Z_ARRVAL_PP(tmp), "args", sizeof("args"), (void **)&args) == SUCCESS;
phpdbg_xml(" symbol=\"%s%s%s\"",
is_class == FAILURE?"":Z_STRVAL_PP(class),
is_class == FAILURE?"":Z_STRVAL_PP(type),
Z_STRVAL_PP(funcname)
);
if (has_args) {
phpdbg_xml(">");
} else {
phpdbg_xml(" />");
}
phpdbg_out("%s%s%s(",
is_class == FAILURE?"":Z_STRVAL_PP(class),
is_class == FAILURE?"":Z_STRVAL_PP(type),
Z_STRVAL_PP(funcname)
);
if (zend_hash_find(Z_ARRVAL_PP(tmp), "args", sizeof("args"),
(void **)&args) == SUCCESS) {
if (has_args) {
HashPosition iterator;
const zend_function *func = phpdbg_get_function(
Z_STRVAL_PP(funcname), is_class == FAILURE ? NULL : Z_STRVAL_PP(class) TSRMLS_CC);
const zend_arg_info *arginfo = func ? func->common.arg_info : NULL;
int j = 0, m = func ? func->common.num_args : 0;
const zend_function *func = NULL;
const zend_arg_info *arginfo = NULL;
int j = 0, m;
zend_bool is_variadic = 0;
zend_hash_internal_pointer_reset_ex(Z_ARRVAL_PP(args), &iterator);
while (zend_hash_get_current_data_ex(Z_ARRVAL_PP(args),
(void **) &argstmp, &iterator) == SUCCESS) {
if (j) {
phpdbg_write(", ");
phpdbg_try_access {
/* assuming no autoloader call is necessary, class should have been loaded if it's in backtrace ... */
if ((func = phpdbg_get_function(Z_STRVAL_PP(funcname), is_class == FAILURE ? NULL : Z_STRVAL_PP(class) TSRMLS_CC))) {
arginfo = func->common.arg_info;
}
} phpdbg_end_try_access();
m = func ? func->common.num_args : 0;
zend_hash_internal_pointer_reset_ex(Z_ARRVAL_PP(args), &iterator);
while (zend_hash_get_current_data_ex(Z_ARRVAL_PP(args), (void **) &argstmp, &iterator) == SUCCESS) {
if (j) {
phpdbg_out(", ");
}
phpdbg_xml("<arg %r");
if (m && j < m) {
#if PHP_VERSION_ID >= 50600
is_variadic = arginfo[j].is_variadic;
is_variadic = arginfo ? arginfo[j].is_variadic : 0;
#endif
phpdbg_write("%s=%s",
arginfo[j].name, is_variadic ? "[": "");
phpdbg_xml(" variadic=\"%s\" name=\"%s\">", is_variadic ? "variadic" : "", arginfo ? arginfo[j].name : "");
phpdbg_out("%s=%s", arginfo ? arginfo[j].name : "?", is_variadic ? "[": "");
} else {
phpdbg_xml(">");
}
++j;
zend_print_flat_zval_r(*argstmp TSRMLS_CC);
zend_hash_move_forward_ex(Z_ARRVAL_PP(args), &iterator);
phpdbg_xml("</arg>");
}
if (is_variadic) {
phpdbg_write("]");
phpdbg_out("]");
}
phpdbg_xml("</frame>");
}
phpdbg_write(")");
phpdbg_out(")");
}
void phpdbg_dump_backtrace(size_t num TSRMLS_DC) /* {{{ */
@@ -170,37 +198,54 @@ void phpdbg_dump_backtrace(size_t num TSRMLS_DC) /* {{{ */
int i = 0, limit = num;
int user_defined;
PHPDBG_OUTPUT_BACKUP();
if (limit < 0) {
phpdbg_error("Invalid backtrace size %d", limit);
phpdbg_error("backtrace", "type=\"minnum\"", "Invalid backtrace size %d", limit);
PHPDBG_OUTPUT_BACKUP_RESTORE();
return;
}
zend_fetch_debug_backtrace(
&zbacktrace, 0, 0, limit TSRMLS_CC);
phpdbg_try_access {
zend_fetch_debug_backtrace(&zbacktrace, 0, 0, limit TSRMLS_CC);
} phpdbg_catch_access {
phpdbg_error("signalsegv", "", "Couldn't fetch backtrace, invalid data source");
return;
} phpdbg_end_try_access();
phpdbg_xml("<backtrace %r>");
zend_hash_internal_pointer_reset_ex(Z_ARRVAL(zbacktrace), &position);
zend_hash_get_current_data_ex(Z_ARRVAL(zbacktrace), (void**)&tmp, &position);
zend_hash_get_current_data_ex(Z_ARRVAL(zbacktrace), (void **) &tmp, &position);
while (1) {
user_defined = zend_hash_find(Z_ARRVAL_PP(tmp), "file", sizeof("file"), (void **)&file);
zend_hash_find(Z_ARRVAL_PP(tmp), "line", sizeof("line"), (void **)&line);
user_defined = zend_hash_find(Z_ARRVAL_PP(tmp), "file", sizeof("file"), (void **) &file);
zend_hash_find(Z_ARRVAL_PP(tmp), "line", sizeof("line"), (void **) &line);
zend_hash_move_forward_ex(Z_ARRVAL(zbacktrace), &position);
if (zend_hash_get_current_data_ex(Z_ARRVAL(zbacktrace),
(void**)&tmp, &position) == FAILURE) {
phpdbg_write("frame #%d: {main} at %s:%ld", i, Z_STRVAL_PP(file), Z_LVAL_PP(line));
if (zend_hash_get_current_data_ex(Z_ARRVAL(zbacktrace), (void **) &tmp, &position) == FAILURE) {
phpdbg_write("frame", "id=\"%d\" symbol=\"{main}\" file=\"%s\" line=\"%d\"", "frame #%d: {main} at %s:%ld", i, Z_STRVAL_PP(file), Z_LVAL_PP(line));
break;
}
if (user_defined == SUCCESS) {
phpdbg_write("frame #%d: ", i++);
phpdbg_out("frame #%d: ", i);
phpdbg_xml("<frame %r id=\"%d\" file=\"%s\" line=\"%d\"", i, Z_STRVAL_PP(file), Z_LVAL_PP(line));
phpdbg_dump_prototype(tmp TSRMLS_CC);
phpdbg_writeln(" at %s:%ld", Z_STRVAL_PP(file), Z_LVAL_PP(line));
phpdbg_out(" at %s:%ld\n", Z_STRVAL_PP(file), Z_LVAL_PP(line));
i++;
} else {
phpdbg_write(" => ");
phpdbg_out(" => ");
phpdbg_xml("<frame %r id=\"%d\" internal=\"internal\"", i);
phpdbg_dump_prototype(tmp TSRMLS_CC);
phpdbg_writeln(" (internal function)");
phpdbg_out(" (internal function)\n");
}
}
phpdbg_writeln(EMPTY);
phpdbg_out("\n");
phpdbg_xml("</backtrace>");
zval_dtor(&zbacktrace);
PHPDBG_OUTPUT_BACKUP_RESTORE();
} /* }}} */

View File

@@ -22,6 +22,7 @@
#include "phpdbg.h"
#include "phpdbg_help.h"
#include "phpdbg_prompt.h"
#include "phpdbg_eol.h"
#include "zend.h"
ZEND_EXTERN_MODULE_GLOBALS(phpdbg);
@@ -61,6 +62,11 @@ void pretty_print(char *text TSRMLS_DC)
unsigned int last_blank_count = 0; /* printable char offset of last blank char */
unsigned int line_count = 0; /* number printable chars on current line */
if (PHPDBG_G(flags) & PHPDBG_WRITE_XML) {
phpdbg_xml("<help %r msg=\"%s\" />", text);
return;
}
/* First pass calculates a safe size for the pretty print version */
for (p = text; *p; p++) {
if (UNEXPECTED(p[0] == '*') && p[1] == '*') {
@@ -128,10 +134,10 @@ void pretty_print(char *text TSRMLS_DC)
*q++ = '\0';
if ((q-new)>size) {
phpdbg_error("Output overrun of %lu bytes", ((q-new) - size));
phpdbg_error("help", "overrun=\"%lu\"", "Output overrun of %lu bytes", ((q - new) - size));
}
phpdbg_write("%s\n", new);
phpdbg_out("%s\n", new);
efree(new);
} /* }}} */
@@ -201,7 +207,7 @@ static int get_command(
return num_matches;
} /* }}} */
} /* }}} */
PHPDBG_COMMAND(help) /* {{{ */
{
@@ -231,7 +237,7 @@ PHPDBG_COMMAND(help) /* {{{ */
pretty_print(get_help("duplicate!" TSRMLS_CC) TSRMLS_CC);
return SUCCESS;
} else {
phpdbg_error("Internal help error, non-unique alias \"%c\"", param->str[0]);
phpdbg_error("help", "type=\"ambiguousalias\" alias=\"%s\"", "Internal help error, non-unique alias \"%c\"", param->str[0]);
return FAILURE;
}
@@ -259,34 +265,41 @@ PHPDBG_HELP(aliases) /* {{{ */
int len;
/* Print out aliases for all commands except help as this one comes last */
phpdbg_writeln("Below are the aliased, short versions of all supported commands");
phpdbg_writeln("help", "", "Below are the aliased, short versions of all supported commands");
phpdbg_xml("<helpcommands %r>");
for(c = phpdbg_prompt_commands; c->name; c++) {
if (c->alias && c->alias != 'h') {
phpdbg_writeln(" %c %-20s %s", c->alias, c->name, c->tip);
phpdbg_writeln("command", "alias=\"%c\" name=\"%s\" tip=\"%s\"", " %c %-20s %s", c->alias, c->name, c->tip);
if (c->subs) {
len = 20 - 1 - c->name_len;
for(c_sub = c->subs; c_sub->alias; c_sub++) {
if (c_sub->alias) {
phpdbg_writeln(" %c %c %s %-*s %s",
c->alias, c_sub->alias, (char *)c->name, len, c_sub->name, c_sub->tip);
phpdbg_writeln("subcommand", "parent_alias=\"%c\" alias=\"%c\" parent=\"%s\" name=\"%-*s\" tip=\"%s\"", " %c %c %s %-*s %s",
c->alias, c_sub->alias, c->name, len, c_sub->name, c_sub->tip);
}
}
}
}
}
phpdbg_xml("</helpcommands>");
/* Print out aliases for help as this one comes last, with the added text on how aliases are used */
get_command("h", 1, &c, phpdbg_prompt_commands TSRMLS_CC);
phpdbg_writeln(" %c %-20s %s\n", c->alias, c->name, c->tip);
phpdbg_writeln("aliasinfo", "alias=\"%c\" name=\"%s\" tip=\"%s\"", " %c %-20s %s\n", c->alias, c->name, c->tip);
phpdbg_xml("<helpaliases>");
len = 20 - 1 - c->name_len;
for(c_sub = c->subs; c_sub->alias; c_sub++) {
if (c_sub->alias) {
phpdbg_writeln(" %c %c %s %-*s %s",
phpdbg_writeln("alias", "parent_alias=\"%c\" alias=\"%c\" parent=\"%s\" name=\"%-*s\" tip=\"%s\"", " %c %c %s %-*s %s",
c->alias, c_sub->alias, c->name, len, c_sub->name, c_sub->tip);
}
}
phpdbg_xml("</helpaliases>");
pretty_print(get_help("aliases!" TSRMLS_CC) TSRMLS_CC);
return SUCCESS;
} /* }}} */
@@ -307,7 +320,7 @@ PHPDBG_HELP(aliases) /* {{{ */
* Also note the convention that help text not directly referenceable as a help param
* has a key ending in !
*/
#define CR "\n"
#define CR "\n"
phpdbg_help_text_t phpdbg_help_text[] = {
/******************************** General Help Topics ********************************/
@@ -362,7 +375,7 @@ phpdbg_help_text_t phpdbg_help_text[] = {
" **-c** **-c**/my/php.ini Set php.ini file to load" CR
" **-d** **-d**memory_limit=4G Set a php.ini directive" CR
" **-n** Disable default php.ini" CR
" **-q** Supress welcome banner" CR
" **-q** Suppress welcome banner" CR
" **-v** Enable oplog output" CR
" **-s** Enable stepping" CR
" **-b** Disable colour" CR
@@ -375,6 +388,9 @@ phpdbg_help_text_t phpdbg_help_text[] = {
" **-S** **-S**cli Override SAPI name, careful!" CR
" **-l** **-l**4000 Setup remote console ports" CR
" **-a** **-a**192.168.0.3 Setup remote console bind address" CR
#if PHPDBG_IN_DEV
" **-x** Enable xml output (instead of normal text output)" CR
#endif
" **-V** Print version number" CR
" **--** **--** arg1 arg2 Use to delimit phpdbg arguments and php $argv; append any $argv "
"argument after it" CR CR
@@ -386,9 +402,7 @@ phpdbg_help_text_t phpdbg_help_text[] = {
"bind address using the **-a** option. If **-a** is specied without an argument, then phpdbg "
"will bind to all available interfaces. You should be aware of the security implications of "
"doing this, so measures should be taken to secure this service if bound to a publicly accessible "
"interface/port." CR CR
"Specify both stdin and stdout with -lstdin/stdout; by default stdout is stdin * 2."
"interface/port."
},
{"phpdbginit", CR
@@ -545,7 +559,7 @@ phpdbg_help_text_t phpdbg_help_text[] = {
" $P break ZEND_ADD" CR
" $P b ZEND_ADD" CR
" Break on any occurence of the opcode ZEND_ADD" CR CR
" Break on any occurrence of the opcode ZEND_ADD" CR CR
" $P break del 2" CR
" $P b ~ 2" CR
@@ -642,14 +656,16 @@ phpdbg_help_text_t phpdbg_help_text[] = {
"Specific info commands are show below:" CR CR
" **Target** **Alias** **Purpose**" CR
" **break** **b** show current breakpoints" CR
" **files** **F** show included files" CR
" **classes** **c** show loaded classes" CR
" **funcs** **f** show loaded classes" CR
" **error** **e** show last error" CR
" **vars** **v** show active variables" CR
" **literal** **l** show active literal constants" CR
" **memory** **m** show memory manager stats"
" **break** **b** show current breakpoints" CR
" **files** **F** show included files" CR
" **classes** **c** show loaded classes" CR
" **funcs** **f** show loaded functions" CR
" **error** **e** show last error" CR
" **constants** **d** show user-defined constants" CR
" **vars** **v** show active variables" CR
" **globals** **g** show superglobal variables" CR
" **literal** **l** show active literal constants" CR
" **memory** **m** show memory manager stats"
},
// ******** same issue about breakpoints in called frames

View File

@@ -35,9 +35,9 @@ PHPDBG_HELP(aliases);
extern const phpdbg_command_t phpdbg_help_commands[];
#define phpdbg_help_header() \
phpdbg_notice("Welcome to phpdbg, the interactive PHP debugger, v%s", PHPDBG_VERSION);
phpdbg_notice("version", "version=\"%s\"", "Welcome to phpdbg, the interactive PHP debugger, v%s", PHPDBG_VERSION);
#define phpdbg_help_footer() \
phpdbg_notice("Please report bugs to <%s>", PHPDBG_ISSUES);
phpdbg_notice("issues", "url=\"%s\"", "Please report bugs to <%s>", PHPDBG_ISSUES);
typedef struct _phpdbg_help_text_t {
char *key;

View File

@@ -27,18 +27,20 @@
ZEND_EXTERN_MODULE_GLOBALS(phpdbg);
#define PHPDBG_INFO_COMMAND_D(f, h, a, m, l, s) \
PHPDBG_COMMAND_D_EXP(f, h, a, m, l, s, &phpdbg_prompt_commands[14])
#define PHPDBG_INFO_COMMAND_D(f, h, a, m, l, s, flags) \
PHPDBG_COMMAND_D_EXP(f, h, a, m, l, s, &phpdbg_prompt_commands[14], flags)
const phpdbg_command_t phpdbg_info_commands[] = {
PHPDBG_INFO_COMMAND_D(break, "show breakpoints", 'b', info_break, NULL, 0),
PHPDBG_INFO_COMMAND_D(files, "show included files", 'F', info_files, NULL, 0),
PHPDBG_INFO_COMMAND_D(classes, "show loaded classes", 'c', info_classes, NULL, 0),
PHPDBG_INFO_COMMAND_D(funcs, "show loaded classes", 'f', info_funcs, NULL, 0),
PHPDBG_INFO_COMMAND_D(error, "show last error", 'e', info_error, NULL, 0),
PHPDBG_INFO_COMMAND_D(vars, "show active variables", 'v', info_vars, NULL, 0),
PHPDBG_INFO_COMMAND_D(literal, "show active literal constants", 'l', info_literal, NULL, 0),
PHPDBG_INFO_COMMAND_D(memory, "show memory manager stats", 'm', info_memory, NULL, 0),
PHPDBG_INFO_COMMAND_D(break, "show breakpoints", 'b', info_break, NULL, 0, PHPDBG_ASYNC_SAFE),
PHPDBG_INFO_COMMAND_D(files, "show included files", 'F', info_files, NULL, 0, PHPDBG_ASYNC_SAFE),
PHPDBG_INFO_COMMAND_D(classes, "show loaded classes", 'c', info_classes, NULL, 0, PHPDBG_ASYNC_SAFE),
PHPDBG_INFO_COMMAND_D(funcs, "show loaded classes", 'f', info_funcs, NULL, 0, PHPDBG_ASYNC_SAFE),
PHPDBG_INFO_COMMAND_D(error, "show last error", 'e', info_error, NULL, 0, PHPDBG_ASYNC_SAFE),
PHPDBG_INFO_COMMAND_D(constants, "show user defined constants", 'd', info_constants, NULL, 0, PHPDBG_ASYNC_SAFE),
PHPDBG_INFO_COMMAND_D(vars, "show active variables", 'v', info_vars, NULL, 0, PHPDBG_ASYNC_SAFE),
PHPDBG_INFO_COMMAND_D(globals, "show superglobals", 'g', info_globals, NULL, 0, PHPDBG_ASYNC_SAFE),
PHPDBG_INFO_COMMAND_D(literal, "show active literal constants", 'l', info_literal, NULL, 0, PHPDBG_ASYNC_SAFE),
PHPDBG_INFO_COMMAND_D(memory, "show memory manager stats", 'm', info_memory, NULL, 0, PHPDBG_ASYNC_SAFE),
PHPDBG_END_COMMAND
};
@@ -62,15 +64,21 @@ PHPDBG_INFO(files) /* {{{ */
HashPosition pos;
char *fname;
phpdbg_notice("Included files: %d",
zend_hash_num_elements(&EG(included_files)));
phpdbg_try_access {
phpdbg_notice("includedfilecount", "num=\"%d\"", "Included files: %d", zend_hash_num_elements(&EG(included_files)));
} phpdbg_catch_access {
phpdbg_error("signalsegv", "", "Could not fetch included file count, invalid data source");
} phpdbg_end_try_access();
zend_hash_internal_pointer_reset_ex(&EG(included_files), &pos);
while (zend_hash_get_current_key_ex(&EG(included_files), &fname,
NULL, NULL, 0, &pos) == HASH_KEY_IS_STRING) {
phpdbg_writeln("File: %s", fname);
zend_hash_move_forward_ex(&EG(included_files), &pos);
}
phpdbg_try_access {
zend_hash_internal_pointer_reset_ex(&EG(included_files), &pos);
while (zend_hash_get_current_key_ex(&EG(included_files), &fname, NULL, NULL, 0, &pos) == HASH_KEY_IS_STRING) {
phpdbg_writeln("includedfile", "name=\"%s\"", "File: %s", fname);
zend_hash_move_forward_ex(&EG(included_files), &pos);
}
} phpdbg_catch_access {
phpdbg_error("signalsegv", "", "Could not fetch file name, invalid data source, aborting included file listing");
} phpdbg_end_try_access();
return SUCCESS;
} /* }}} */
@@ -78,23 +86,98 @@ PHPDBG_INFO(files) /* {{{ */
PHPDBG_INFO(error) /* {{{ */
{
if (PG(last_error_message)) {
phpdbg_writeln("Last error: %s at %s line %d",
PG(last_error_message), PG(last_error_file), PG(last_error_lineno));
phpdbg_try_access {
phpdbg_writeln("lasterror", "error=\"%s\" file=\"%s\" line=\"%d\"", "Last error: %s at %s line %d", PG(last_error_message), PG(last_error_file), PG(last_error_lineno));
} phpdbg_catch_access {
phpdbg_notice("lasterror", "error=\"\"", "No error found!");
} phpdbg_end_try_access();
} else {
phpdbg_notice("No error found!");
phpdbg_notice("lasterror", "error=\"\"", "No error found!");
}
return SUCCESS;
} /* }}} */
PHPDBG_INFO(vars) /* {{{ */
PHPDBG_INFO(constants) /* {{{ */
{
HashTable vars;
HashPosition pos;
HashTable consts;
zend_constant *data;
zend_hash_init(&consts, 8, NULL, NULL, 0);
if (EG(zend_constants)) {
phpdbg_try_access {
zend_hash_internal_pointer_reset_ex(EG(zend_constants), &pos);
while (zend_hash_get_current_data_ex(EG(zend_constants), (void **) &data, &pos) == SUCCESS) {
if (data->module_number == PHP_USER_CONSTANT) {
zend_hash_update(&consts, data->name, data->name_len, (void **) &data, sizeof(zend_constant *), NULL);
}
zend_hash_move_forward_ex(EG(zend_constants), &pos);
}
} phpdbg_catch_access {
phpdbg_error("signalsegv", "", "Cannot fetch all the constants, invalid data source");
} phpdbg_end_try_access();
}
phpdbg_notice("constantinfo", "num=\"%d\"", "User-defined constants (%d)", zend_hash_num_elements(&consts));
if (zend_hash_num_elements(&consts)) {
phpdbg_out("Address Refs Type Constant\n");
for (zend_hash_internal_pointer_reset_ex(&consts, &pos);
zend_hash_get_current_data_ex(&consts, (void **) &data, &pos) == SUCCESS;
zend_hash_move_forward_ex(&consts, &pos)) {
data = *(zend_constant **) data;
#define VARIABLEINFO(attrs, msg, ...) phpdbg_writeln("constant", "address=\"%p\" refcount=\"%d\" type=\"%s\" name=\"%.*s\" " attrs, "%-18p %-7d %-9s %.*s" msg, &data->value, Z_REFCOUNT(data->value), zend_zval_type_name(&data->value), data->name_len - 1, data->name, ##__VA_ARGS__)
switch (Z_TYPE(data->value)) {
case IS_STRING:
phpdbg_try_access {
VARIABLEINFO("length=\"%d\" value=\"%.*s\"", "\nstring (%d) \"%.*s%s\"", Z_STRLEN(data->value), Z_STRLEN(data->value) < 255 ? Z_STRLEN(data->value) : 255, Z_STRVAL(data->value), Z_STRLEN(data->value) > 255 ? "..." : "");
} phpdbg_catch_access {
VARIABLEINFO("", "");
} phpdbg_end_try_access();
break;
case IS_BOOL:
VARIABLEINFO("value=\"%s\"", "\nbool (%s)", Z_LVAL(data->value) ? "true" : "false");
break;
case IS_LONG:
VARIABLEINFO("value=\"%ld\"", "\nint (%ld)", Z_LVAL(data->value));
break;
case IS_DOUBLE:
VARIABLEINFO("value=\"%lf\"", "\ndouble (%lf)", Z_DVAL(data->value));
break;
default:
VARIABLEINFO("", "");
#undef VARIABLEINFO
}
}
}
return SUCCESS;
} /* }}} */
static int phpdbg_arm_auto_global(zend_auto_global *auto_global TSRMLS_DC) {
if (auto_global->armed) {
if (PHPDBG_G(flags) & PHPDBG_IN_SIGNAL_HANDLER) {
phpdbg_notice("variableinfo", "unreachable=\"%.*s\"", "Cannot show information about superglobal variable %.*s", auto_global->name_len, auto_global->name);
} else {
auto_global->armed = auto_global->auto_global_callback(auto_global->name, auto_global->name_len TSRMLS_CC);
}
}
return 0;
}
static int phpdbg_print_symbols(zend_bool show_globals TSRMLS_DC) {
HashTable vars, *symtable;
HashPosition pos;
char *var;
zval **data;
if (!EG(active_op_array)) {
phpdbg_error("No active op array!");
phpdbg_error("inactive", "type=\"op_array\"", "No active op array!");
return SUCCESS;
}
@@ -102,100 +185,112 @@ PHPDBG_INFO(vars) /* {{{ */
zend_rebuild_symbol_table(TSRMLS_C);
if (!EG(active_symbol_table)) {
phpdbg_error("No active symbol table!");
phpdbg_error("inactive", "type=\"symbol_table\"", "No active symbol table!");
return SUCCESS;
}
}
zend_hash_init(&vars, 8, NULL, NULL, 0);
zend_hash_internal_pointer_reset_ex(EG(active_symbol_table), &pos);
while (zend_hash_get_current_key_ex(EG(active_symbol_table), &var,
NULL, NULL, 0, &pos) == HASH_KEY_IS_STRING) {
zend_hash_get_current_data_ex(EG(active_symbol_table), (void **)&data, &pos);
if (*var != '_') {
zend_hash_update(
&vars, var, strlen(var)+1, (void**)data, sizeof(zval*), NULL);
}
zend_hash_move_forward_ex(EG(active_symbol_table), &pos);
if (show_globals) {
/* that array should only be manipulated during init, so safe for async access during execution */
zend_hash_apply(CG(auto_globals), (apply_func_t) phpdbg_arm_auto_global TSRMLS_CC);
symtable = &EG(symbol_table);
} else {
symtable = EG(active_symbol_table);
}
{
zend_hash_init(&vars, 8, NULL, NULL, 0);
phpdbg_try_access {
zend_hash_internal_pointer_reset_ex(symtable, &pos);
while (zend_hash_get_current_key_ex(symtable, &var, NULL, NULL, 0, &pos) == HASH_KEY_IS_STRING) {
zend_hash_get_current_data_ex(symtable, (void **)&data, &pos);
if (zend_is_auto_global(var, strlen(var) TSRMLS_CC) ^ !show_globals) {
zend_hash_update(&vars, var, strlen(var)+1, (void**)data, sizeof(zval*), NULL);
}
zend_hash_move_forward_ex(symtable, &pos);
}
} phpdbg_catch_access {
phpdbg_error("signalsegv", "", "Cannot fetch all data from the symbol table, invalid data source");
} phpdbg_end_try_access();
if (show_globals) {
phpdbg_notice("variableinfo", "num=\"%d\"", "Superglobal variables (%d)", zend_hash_num_elements(&vars));
} else {
zend_op_array *ops = EG(active_op_array);
if (ops->function_name) {
if (ops->scope) {
phpdbg_notice(
"Variables in %s::%s() (%d)", ops->scope->name, ops->function_name, zend_hash_num_elements(&vars));
phpdbg_notice("variableinfo", "method=\"%s::%s\" num=\"%d\"", "Variables in %s::%s() (%d)", ops->scope->name, ops->function_name, zend_hash_num_elements(&vars));
} else {
phpdbg_notice(
"Variables in %s() (%d)", ops->function_name, zend_hash_num_elements(&vars));
phpdbg_notice("variableinfo", "function=\"%s\" num=\"%d\"", "Variables in %s() (%d)", ops->function_name, zend_hash_num_elements(&vars));
}
} else {
if (ops->filename) {
phpdbg_notice(
"Variables in %s (%d)", ops->filename, zend_hash_num_elements(&vars));
phpdbg_notice("variableinfo", "file=\"%s\" num=\"%d\"", "Variables in %s (%d)", ops->filename, zend_hash_num_elements(&vars));
} else {
phpdbg_notice(
"Variables @ %p (%d)", ops, zend_hash_num_elements(&vars));
phpdbg_notice("variableinfo", "opline=\"%p\" num=\"%d\"", "Variables @ %p (%d)", ops, zend_hash_num_elements(&vars));
}
}
}
if (zend_hash_num_elements(&vars)) {
phpdbg_writeln("Address\t\tRefs\tType\t\tVariable");
phpdbg_out("Address Refs Type Variable\n");
for (zend_hash_internal_pointer_reset_ex(&vars, &pos);
zend_hash_get_current_data_ex(&vars, (void**) &data, &pos) == SUCCESS;
zend_hash_move_forward_ex(&vars, &pos)) {
zend_hash_get_current_data_ex(&vars, (void**) &data, &pos) == SUCCESS;
zend_hash_move_forward_ex(&vars, &pos)) {
char *var;
zend_bool invalid_data = 1;
zend_hash_get_current_key_ex(&vars, &var, NULL, NULL, 0, &pos);
if (*data) {
phpdbg_write(
"%p\t%d\t",
*data,
Z_REFCOUNT_PP(data));
phpdbg_try_access {
if (!(invalid_data = !*data)) {
#define VARIABLEINFO(attrs, msg, ...) phpdbg_writeln("variable", "address=\"%p\" refcount=\"%d\" type=\"%s\" refstatus=\"%s\" name=\"%s\" " attrs, "%-18p %-7d %-9s %s$%s" msg, *data, Z_REFCOUNT_PP(data), zend_zval_type_name(*data), Z_ISREF_PP(data) ? "&": "", var, ##__VA_ARGS__)
switch (Z_TYPE_PP(data)) {
case IS_STRING: phpdbg_write("(string)\t"); break;
case IS_LONG: phpdbg_write("(integer)\t"); break;
case IS_DOUBLE: phpdbg_write("(float)\t"); break;
case IS_RESOURCE: phpdbg_write("(resource)\t"); break;
case IS_ARRAY: phpdbg_write("(array)\t"); break;
case IS_OBJECT: phpdbg_write("(object)\t"); break;
case IS_NULL: phpdbg_write("(null)\t"); break;
}
if (Z_TYPE_PP(data) == IS_RESOURCE) {
int type;
phpdbg_writeln(
"%s$%s", Z_ISREF_PP(data) ? "&": "", var);
if (zend_list_find(Z_RESVAL_PP(data), &type)) {
phpdbg_write(
"|-------(typeof)------> (%s)",
zend_rsrc_list_get_rsrc_type(type TSRMLS_CC));
} else {
phpdbg_write(
"|-------(typeof)------> (unknown)");
switch (Z_TYPE_PP(data)) {
case IS_RESOURCE:
phpdbg_try_access {
int type;
VARIABLEINFO("type=\"%s\"", "\n|-------(typeof)------> (%s)\n", zend_list_find(Z_RESVAL_PP(data), &type) ? zend_rsrc_list_get_rsrc_type(type TSRMLS_CC) : "unknown");
} phpdbg_catch_access {
VARIABLEINFO("type=\"unknown\"", "\n|-------(typeof)------> (unknown)\n");
} phpdbg_end_try_access();
break;
case IS_OBJECT:
phpdbg_try_access {
VARIABLEINFO("instanceof=\"%s\"", "\n|-----(instanceof)----> (%s)\n", Z_OBJCE_PP(data)->name);
} phpdbg_catch_access {
VARIABLEINFO("instanceof=\"%s\"", "\n|-----(instanceof)----> (unknown)\n");
} phpdbg_end_try_access();
break;
case IS_STRING:
phpdbg_try_access {
VARIABLEINFO("length=\"%d\" value=\"%.*s\"", "\nstring (%d) \"%.*s%s\"", Z_STRLEN_PP(data), Z_STRLEN_PP(data) < 255 ? Z_STRLEN_PP(data) : 255, Z_STRVAL_PP(data), Z_STRLEN_PP(data) > 255 ? "..." : "");
} phpdbg_catch_access {
VARIABLEINFO("", "");
} phpdbg_end_try_access();
break;
case IS_BOOL:
VARIABLEINFO("value=\"%s\"", "\nbool (%s)", Z_LVAL_PP(data) ? "true" : "false");
break;
case IS_LONG:
VARIABLEINFO("value=\"%ld\"", "\nint (%ld)", Z_LVAL_PP(data));
break;
case IS_DOUBLE:
VARIABLEINFO("value=\"%lf\"", "\ndouble (%lf)", Z_DVAL_PP(data));
break;
default:
VARIABLEINFO("", "");
}
phpdbg_writeln(EMPTY);
} else if (Z_TYPE_PP(data) == IS_OBJECT) {
phpdbg_writeln(
"%s$%s", Z_ISREF_PP(data) ? "&": "", var);
phpdbg_write(
"|-----(instanceof)----> (%s)", Z_OBJCE_PP(data)->name);
phpdbg_writeln(EMPTY);
} else {
phpdbg_write(
"%s$%s", Z_ISREF_PP(data) ? "&": "", var);
}
} else {
phpdbg_write(
"n/a\tn/a\tn/a\t$%s", var);
#undef VARIABLEINFO
} phpdbg_end_try_access();
if (invalid_data) {
phpdbg_writeln("variable", "name=\"%s\"", "n/a\tn/a\tn/a\t$%s", var);
}
phpdbg_writeln(EMPTY);
}
}
@@ -204,42 +299,47 @@ PHPDBG_INFO(vars) /* {{{ */
return SUCCESS;
} /* }}} */
PHPDBG_INFO(vars) /* {{{ */
{
return phpdbg_print_symbols(0 TSRMLS_CC);
}
PHPDBG_INFO(globals) /* {{{ */
{
return phpdbg_print_symbols(1 TSRMLS_CC);
}
PHPDBG_INFO(literal) /* {{{ */
{
/* literals are assumed to not be manipulated during executing of their op_array and as such async safe */
if ((EG(in_execution) && EG(active_op_array)) || PHPDBG_G(ops)) {
zend_op_array *ops = EG(active_op_array) ? EG(active_op_array) : PHPDBG_G(ops);
int literal = 0, count = ops->last_literal-1;
if (ops->function_name) {
if (ops->scope) {
phpdbg_notice(
"Literal Constants in %s::%s() (%d)", ops->scope->name, ops->function_name, count);
phpdbg_notice("literalinfo", "method=\"%s::%s\" num=\"%d\"", "Literal Constants in %s::%s() (%d)", ops->scope->name, ops->function_name, count);
} else {
phpdbg_notice(
"Literal Constants in %s() (%d)", ops->function_name, count);
phpdbg_notice("literalinfo", "function=\"%s\" num=\"%d\"", "Literal Constants in %s() (%d)", ops->function_name, count);
}
} else {
if (ops->filename) {
phpdbg_notice(
"Literal Constants in %s (%d)", ops->filename, count);
phpdbg_notice("literalinfo", "file=\"%s\" num=\"%d\"", "Literal Constants in %s (%d)", ops->filename, count);
} else {
phpdbg_notice(
"Literal Constants @ %p (%d)", ops, count);
phpdbg_notice("literalinfo", "opline=\"%p\" num=\"%d\"", "Literal Constants @ %p (%d)", ops, count);
}
}
while (literal < ops->last_literal) {
if (Z_TYPE(ops->literals[literal].constant) != IS_NULL) {
phpdbg_write("|-------- C%u -------> [", literal);
zend_print_zval(
&ops->literals[literal].constant, 0);
phpdbg_write("]");
phpdbg_writeln(EMPTY);
phpdbg_write("literal", "id=\"%u\"", "|-------- C%u -------> [", literal);
zend_print_zval(&ops->literals[literal].constant, 0);
phpdbg_out("]\n");
}
literal++;
}
} else {
phpdbg_error("Not executing!");
phpdbg_error("inactive", "type=\"execution\"", "Not executing!");
}
return SUCCESS;
@@ -247,28 +347,40 @@ PHPDBG_INFO(literal) /* {{{ */
PHPDBG_INFO(memory) /* {{{ */
{
if (is_zend_mm(TSRMLS_C)) {
phpdbg_notice("Memory Manager Information");
phpdbg_notice("Current");
phpdbg_writeln("|-------> Used:\t%.3f kB",
(float) (zend_memory_usage(0 TSRMLS_CC)/1024));
phpdbg_writeln("|-------> Real:\t%.3f kB",
(float) (zend_memory_usage(1 TSRMLS_CC)/1024));
phpdbg_notice("Peak");
phpdbg_writeln("|-------> Used:\t%.3f kB",
(float) (zend_memory_peak_usage(0 TSRMLS_CC)/1024));
phpdbg_writeln("|-------> Real:\t%.3f kB",
(float) (zend_memory_peak_usage(1 TSRMLS_CC)/1024));
size_t used, real, peak_used, peak_real;
zend_mm_heap *heap;
zend_bool is_mm;
if (PHPDBG_G(flags) & PHPDBG_IN_SIGNAL_HANDLER) {
heap = zend_mm_set_heap(phpdbg_original_heap_sigsafe_mem(TSRMLS_C) TSRMLS_CC);
}
if ((is_mm = is_zend_mm(TSRMLS_C))) {
used = zend_memory_usage(0 TSRMLS_CC);
real = zend_memory_usage(1 TSRMLS_CC);
peak_used = zend_memory_peak_usage(0 TSRMLS_CC);
peak_real = zend_memory_peak_usage(1 TSRMLS_CC);
}
if (PHPDBG_G(flags) & PHPDBG_IN_SIGNAL_HANDLER) {
zend_mm_set_heap(heap TSRMLS_CC);
}
if (is_mm) {
phpdbg_notice("meminfo", "", "Memory Manager Information");
phpdbg_notice("current", "", "Current");
phpdbg_writeln("used", "mem=\"%.3f\"", "|-------> Used:\t%.3f kB", (float) (used / 1024));
phpdbg_writeln("real", "mem=\"%.3f\"", "|-------> Real:\t%.3f kB", (float) (real / 1024));
phpdbg_notice("peak", "", "Peak");
phpdbg_writeln("used", "mem=\"%.3f\"", "|-------> Used:\t%.3f kB", (float) (peak_used / 1024));
phpdbg_writeln("real", "mem=\"%.3f\"", "|-------> Real:\t%.3f kB", (float) (peak_real / 1024));
} else {
phpdbg_error("Memory Manager Disabled!");
phpdbg_error("inactive", "type=\"memory_manager\"", "Memory Manager Disabled!");
}
return SUCCESS;
} /* }}} */
static inline void phpdbg_print_class_name(zend_class_entry **ce TSRMLS_DC) /* {{{ */
{
phpdbg_write(
"%s %s %s (%d)",
phpdbg_writeln("class", "type=\"%s\" flags=\"%s\" name=\"%s\" methodcount=\"%d\"", "%s %s %s (%d)",
((*ce)->type == ZEND_USER_CLASS) ?
"User" : "Internal",
((*ce)->ce_flags & ZEND_ACC_INTERFACE) ?
@@ -287,44 +399,44 @@ PHPDBG_INFO(classes) /* {{{ */
zend_hash_init(&classes, 8, NULL, NULL, 0);
for (zend_hash_internal_pointer_reset_ex(EG(class_table), &position);
zend_hash_get_current_data_ex(EG(class_table), (void**)&ce, &position) == SUCCESS;
zend_hash_move_forward_ex(EG(class_table), &position)) {
if ((*ce)->type == ZEND_USER_CLASS) {
zend_hash_next_index_insert(
&classes, ce, sizeof(ce), NULL);
phpdbg_try_access {
for (zend_hash_internal_pointer_reset_ex(EG(class_table), &position);
zend_hash_get_current_data_ex(EG(class_table), (void**)&ce, &position) == SUCCESS;
zend_hash_move_forward_ex(EG(class_table), &position)) {
if ((*ce)->type == ZEND_USER_CLASS) {
zend_hash_next_index_insert(&classes, ce, sizeof(ce), NULL);
}
}
}
} phpdbg_catch_access {
phpdbg_notice("signalsegv", "", "Not all classes could be fetched, possibly invalid data source");
} phpdbg_end_try_access();
phpdbg_notice("User Classes (%d)",
zend_hash_num_elements(&classes));
phpdbg_notice("classinfo", "num=\"%d\"", "User Classes (%d)", zend_hash_num_elements(&classes));
/* once added, assume that classes are stable... until shutdown. */
for (zend_hash_internal_pointer_reset_ex(&classes, &position);
zend_hash_get_current_data_ex(&classes, (void**)&ce, &position) == SUCCESS;
zend_hash_move_forward_ex(&classes, &position)) {
zend_hash_get_current_data_ex(&classes, (void**)&ce, &position) == SUCCESS;
zend_hash_move_forward_ex(&classes, &position)) {
phpdbg_print_class_name(ce TSRMLS_CC);
phpdbg_writeln(EMPTY);
if ((*ce)->parent) {
zend_class_entry *pce = (*ce)->parent;
zend_class_entry *pce;
phpdbg_xml("<parents %r>");
pce = (*ce)->parent;
do {
phpdbg_write("|-------- ");
phpdbg_out("|-------- ");
phpdbg_print_class_name(&pce TSRMLS_CC);
phpdbg_writeln(EMPTY);
} while ((pce = pce->parent));
phpdbg_xml("</parents>");
}
if ((*ce)->info.user.filename) {
phpdbg_writeln(
"|---- in %s on line %u",
(*ce)->info.user.filename,
(*ce)->info.user.line_start);
phpdbg_writeln("classsource", "file=\"%s\" line=\"%u\"", "|---- in %s on line %u", (*ce)->info.user.filename, (*ce)->info.user.line_start);
} else {
phpdbg_writeln("|---- no source code");
phpdbg_writeln("classsource", "", "|---- no source code");
}
phpdbg_writeln(EMPTY);
}
zend_hash_destroy(&classes);
@@ -340,29 +452,34 @@ PHPDBG_INFO(funcs) /* {{{ */
zend_hash_init(&functions, 8, NULL, NULL, 0);
for (zend_hash_internal_pointer_reset_ex(EG(function_table), &position);
zend_hash_get_current_data_ex(EG(function_table), (void**)&zf, &position) == SUCCESS;
zend_hash_move_forward_ex(EG(function_table), &position)) {
if (zf->type == ZEND_USER_FUNCTION) {
zend_hash_next_index_insert(
&functions, (void**) &zf, sizeof(zend_function), NULL);
phpdbg_try_access {
for (zend_hash_internal_pointer_reset_ex(EG(function_table), &position);
zend_hash_get_current_data_ex(EG(function_table), (void**)&zf, &position) == SUCCESS;
zend_hash_move_forward_ex(EG(function_table), &position)) {
if (zf->type == ZEND_USER_FUNCTION) {
zend_hash_next_index_insert(&functions, (void**) &zf, sizeof(zend_function), NULL);
}
}
}
} phpdbg_catch_access {
phpdbg_notice("signalsegv", "", "Not all functions could be fetched, possibly invalid data source");
} phpdbg_end_try_access();
phpdbg_notice("User Functions (%d)",
zend_hash_num_elements(&functions));
phpdbg_notice("functioninfo", "num=\"%d\"", "User Functions (%d)", zend_hash_num_elements(&functions));
for (zend_hash_internal_pointer_reset_ex(&functions, &position);
zend_hash_get_current_data_ex(&functions, (void**)&pzf, &position) == SUCCESS;
zend_hash_move_forward_ex(&functions, &position)) {
zend_op_array *op_array = &((*pzf)->op_array);
phpdbg_writeln(
"|-------- %s in %s on line %d",
op_array->function_name ? op_array->function_name : "{main}",
op_array->filename ? op_array->filename : "(no source code)",
op_array->line_start);
phpdbg_write("function", "name=\"%s\"", "|-------- %s", op_array->function_name ? op_array->function_name : "{main}");
if (op_array->filename) {
phpdbg_writeln("functionsource", "file=\"%s\" line=\"%d\"", " in %s on line %d",
op_array->filename,
op_array->line_start);
} else {
phpdbg_writeln("functionsource", "", " (no source code)");
}
}
zend_hash_destroy(&functions);

View File

@@ -30,7 +30,9 @@ PHPDBG_INFO(break);
PHPDBG_INFO(classes);
PHPDBG_INFO(funcs);
PHPDBG_INFO(error);
PHPDBG_INFO(constants);
PHPDBG_INFO(vars);
PHPDBG_INFO(globals);
PHPDBG_INFO(literal);
PHPDBG_INFO(memory);

321
sapi/phpdbg/phpdbg_io.c Normal file
View File

@@ -0,0 +1,321 @@
/*
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2014 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Anatol Belski <ab@php.net> |
+----------------------------------------------------------------------+
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "phpdbg_io.h"
#ifdef PHP_WIN32
#undef UNICODE
#include "win32/inet.h"
#include <winsock2.h>
#include <windows.h>
#include <Ws2tcpip.h>
#include "win32/sockets.h"
#else
#if HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#include <sys/socket.h>
#include <netinet/in.h>
#if HAVE_ARPA_INET_H
#include <arpa/inet.h>
#endif
#include <netdb.h>
#include <fcntl.h>
#include <poll.h>
#endif
ZEND_EXTERN_MODULE_GLOBALS(phpdbg);
/* is easy to generalize ... but not needed for now */
PHPDBG_API int phpdbg_consume_stdin_line(char *buf TSRMLS_DC) {
int bytes = PHPDBG_G(input_buflen), len = 0;
if (PHPDBG_G(input_buflen)) {
memcpy(buf, PHPDBG_G(input_buffer), bytes);
}
PHPDBG_G(last_was_newline) = 1;
do {
int i;
if (bytes <= 0) {
continue;
}
for (i = len; i < len + bytes; i++) {
if (buf[i] == '\x03') {
if (i != len + bytes - 1) {
memmove(buf + i, buf + i + 1, len + bytes - i - 1);
}
len--;
i--;
continue;
}
if (buf[i] == '\n') {
PHPDBG_G(input_buflen) = len + bytes - 1 - i;
if (PHPDBG_G(input_buflen)) {
memcpy(PHPDBG_G(input_buffer), buf + i + 1, PHPDBG_G(input_buflen));
}
if (i != PHPDBG_MAX_CMD - 1) {
buf[i + 1] = 0;
}
return i;
}
}
len += bytes;
} while ((bytes = phpdbg_mixed_read(PHPDBG_G(io)[PHPDBG_STDIN].fd, buf + len, PHPDBG_MAX_CMD - len, -1 TSRMLS_CC)) > 0);
if (bytes <= 0) {
PHPDBG_G(flags) |= PHPDBG_IS_QUITTING | PHPDBG_IS_DISCONNECTED;
zend_bailout();
return 0;
}
return bytes;
}
PHPDBG_API int phpdbg_consume_bytes(int sock, char *ptr, int len, int tmo TSRMLS_DC) {
int got_now, i = len, j;
char *p = ptr;
#ifndef PHP_WIN32
struct pollfd pfd;
if (tmo < 0) goto recv_once;
pfd.fd = sock;
pfd.events = POLLIN;
j = poll(&pfd, 1, tmo);
if (j == 0) {
#else
struct fd_set readfds;
struct timeval ttmo;
if (tmo < 0) goto recv_once;
FD_ZERO(&readfds);
FD_SET(sock, &readfds);
ttmo.tv_sec = 0;
ttmo.tv_usec = tmo*1000;
j = select(0, &readfds, NULL, NULL, &ttmo);
if (j <= 0) {
#endif
return -1;
}
recv_once:
while(i > 0) {
if (tmo < 0) {
/* There's something to read. Read what's available and proceed
disregarding whether len could be exhausted or not.*/
int can_read = recv(sock, p, i, MSG_PEEK);
#ifndef _WIN32
if (can_read == -1 && errno == EINTR) {
continue;
}
#endif
i = can_read;
}
#ifdef _WIN32
got_now = recv(sock, p, i, 0);
#else
do {
got_now = recv(sock, p, i, 0);
} while (got_now == -1 && errno == EINTR);
#endif
if (got_now == -1) {
write(PHPDBG_G(io)[PHPDBG_STDERR].fd, ZEND_STRL("Read operation timed out!\n"));
return -1;
}
i -= got_now;
p += got_now;
}
return p - ptr;
}
PHPDBG_API int phpdbg_send_bytes(int sock, const char *ptr, int len) {
int sent, i = len;
const char *p = ptr;
/* XXX poll/select needed here? */
while(i > 0) {
sent = send(sock, p, i, 0);
if (sent == -1) {
return -1;
}
i -= sent;
p += sent;
}
return len;
}
PHPDBG_API int phpdbg_mixed_read(int sock, char *ptr, int len, int tmo TSRMLS_DC) {
if (PHPDBG_G(flags) & PHPDBG_IS_REMOTE) {
return phpdbg_consume_bytes(sock, ptr, len, tmo TSRMLS_CC);
}
return read(sock, ptr, len);
}
PHPDBG_API int phpdbg_mixed_write(int sock, const char *ptr, int len TSRMLS_DC) {
if (PHPDBG_G(flags) & PHPDBG_IS_REMOTE) {
return phpdbg_send_bytes(sock, ptr, len);
}
return write(sock, ptr, len);
}
PHPDBG_API int phpdbg_open_socket(const char *interface, unsigned short port TSRMLS_DC) {
struct addrinfo res;
int fd = phpdbg_create_listenable_socket(interface, port, &res TSRMLS_CC);
if (fd == -1) {
return -1;
}
if (bind(fd, res.ai_addr, res.ai_addrlen) == -1) {
phpdbg_close_socket(fd);
return -4;
}
listen(fd, 5);
return fd;
}
PHPDBG_API int phpdbg_create_listenable_socket(const char *addr, unsigned short port, struct addrinfo *addr_res TSRMLS_DC) {
int sock = -1, rc;
int reuse = 1;
struct in6_addr serveraddr;
struct addrinfo hints, *res = NULL;
char port_buf[8];
int8_t any_addr = *addr == '*';
do {
memset(&hints, 0, sizeof hints);
if (any_addr) {
hints.ai_flags = AI_PASSIVE;
} else {
hints.ai_flags = AI_NUMERICSERV;
}
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
rc = inet_pton(AF_INET, addr, &serveraddr);
if (1 == rc) {
hints.ai_family = AF_INET;
if (!any_addr) {
hints.ai_flags |= AI_NUMERICHOST;
}
} else {
rc = inet_pton(AF_INET6, addr, &serveraddr);
if (1 == rc) {
hints.ai_family = AF_INET6;
if (!any_addr) {
hints.ai_flags |= AI_NUMERICHOST;
}
} else {
/* XXX get host by name ??? */
}
}
snprintf(port_buf, 7, "%u", port);
if (!any_addr) {
rc = getaddrinfo(addr, port_buf, &hints, &res);
} else {
rc = getaddrinfo(NULL, port_buf, &hints, &res);
}
if (0 != rc) {
#ifndef PHP_WIN32
if (rc == EAI_SYSTEM) {
char buf[128];
int wrote;
wrote = snprintf(buf, 128, "Could not translate address '%s'", addr);
buf[wrote] = '\0';
write(PHPDBG_G(io)[PHPDBG_STDERR].fd, buf, strlen(buf));
return sock;
} else {
#endif
char buf[256];
int wrote;
wrote = snprintf(buf, 256, "Host '%s' not found. %s", addr, estrdup(gai_strerror(rc)));
buf[wrote] = '\0';
write(PHPDBG_G(io)[PHPDBG_STDERR].fd, buf, strlen(buf));
return sock;
#ifndef PHP_WIN32
}
#endif
return sock;
}
if((sock = socket(res->ai_family, res->ai_socktype, res->ai_protocol)) == -1) {
char buf[128];
int wrote;
wrote = sprintf(buf, "Unable to create socket");
buf[wrote] = '\0';
write(PHPDBG_G(io)[PHPDBG_STDERR].fd, buf, strlen(buf));
return sock;
}
if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (char*) &reuse, sizeof(reuse)) == -1) {
phpdbg_close_socket(sock);
return sock;
}
} while (0);
*addr_res = *res;
return sock;
}
PHPDBG_API void phpdbg_close_socket(int sock) {
if (socket >= 0) {
#ifdef _WIN32
closesocket(sock);
#else
shutdown(sock, SHUT_RDWR);
close(sock);
#endif
}
}

36
sapi/phpdbg/phpdbg_io.h Normal file
View File

@@ -0,0 +1,36 @@
/*
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2014 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Anatol Belski <ab@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef PHPDBG_IO_H
#define PHPDBG_IO_H
#include "phpdbg.h"
PHPDBG_API int phpdbg_consume_stdin_line(char *buf TSRMLS_DC);
PHPDBG_API int phpdbg_consume_bytes(int sock, char *ptr, int len, int tmo TSRMLS_DC);
PHPDBG_API int phpdbg_send_bytes(int sock, const char *ptr, int len);
PHPDBG_API int phpdbg_mixed_read(int sock, char *ptr, int len, int tmo TSRMLS_DC);
PHPDBG_API int phpdbg_mixed_write(int sock, const char *ptr, int len TSRMLS_DC);
PHPDBG_API int phpdbg_create_listenable_socket(const char *addr, unsigned short port, struct addrinfo *res TSRMLS_DC);
PHPDBG_API int phpdbg_open_socket(const char *interface, unsigned short port TSRMLS_DC);
PHPDBG_API void phpdbg_close_socket(int sock);
#endif /* PHPDBG_IO_H */

File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More