diff options
Diffstat (limited to 'ext/standard')
253 files changed, 9005 insertions, 2166 deletions
diff --git a/ext/standard/array.c b/ext/standard/array.c index 843327dc2..9e435103a 100644 --- a/ext/standard/array.c +++ b/ext/standard/array.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -21,7 +21,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: array.c,v 1.308.2.21.2.14 2006/10/03 17:41:47 iliaa Exp $ */ +/* $Id: array.c,v 1.308.2.21.2.27 2007/04/19 23:21:21 iliaa Exp $ */ #include "php.h" #include "php_ini.h" @@ -596,7 +596,7 @@ static int array_user_compare(const void *a, const void *b TSRMLS_DC) convert_to_long_ex(&retval_ptr); retval = Z_LVAL_P(retval_ptr); zval_ptr_dtor(&retval_ptr); - return retval; + return retval < 0 ? -1 : retval > 0 ? 1 : 0;; } else { return 0; } @@ -703,40 +703,40 @@ static int array_user_key_compare(const void *a, const void *b TSRMLS_DC) { Bucket *f; Bucket *s; - zval key1, key2; + zval *key1, *key2; zval *args[2]; zval retval; int status; - args[0] = &key1; - args[1] = &key2; - INIT_PZVAL(&key1); - INIT_PZVAL(&key2); + ALLOC_INIT_ZVAL(key1); + ALLOC_INIT_ZVAL(key2); + args[0] = key1; + args[1] = key2; f = *((Bucket **) a); s = *((Bucket **) b); if (f->nKeyLength) { - Z_STRVAL(key1) = estrndup(f->arKey, f->nKeyLength-1); - Z_STRLEN(key1) = f->nKeyLength-1; - Z_TYPE(key1) = IS_STRING; + Z_STRVAL_P(key1) = estrndup(f->arKey, f->nKeyLength-1); + Z_STRLEN_P(key1) = f->nKeyLength-1; + Z_TYPE_P(key1) = IS_STRING; } else { - Z_LVAL(key1) = f->h; - Z_TYPE(key1) = IS_LONG; + Z_LVAL_P(key1) = f->h; + Z_TYPE_P(key1) = IS_LONG; } if (s->nKeyLength) { - Z_STRVAL(key2) = estrndup(s->arKey, s->nKeyLength-1); - Z_STRLEN(key2) = s->nKeyLength-1; - Z_TYPE(key2) = IS_STRING; + Z_STRVAL_P(key2) = estrndup(s->arKey, s->nKeyLength-1); + Z_STRLEN_P(key2) = s->nKeyLength-1; + Z_TYPE_P(key2) = IS_STRING; } else { - Z_LVAL(key2) = s->h; - Z_TYPE(key2) = IS_LONG; + Z_LVAL_P(key2) = s->h; + Z_TYPE_P(key2) = IS_LONG; } status = call_user_function(EG(function_table), NULL, *BG(user_compare_func_name), &retval, 2, args TSRMLS_CC); - zval_dtor(&key1); - zval_dtor(&key2); + zval_ptr_dtor(&key1); + zval_ptr_dtor(&key2); if (status == SUCCESS) { convert_to_long(&retval); @@ -1138,7 +1138,7 @@ PHP_FUNCTION(array_walk) HashTable *target_hash; old_walk_func_name = BG(array_walk_func_name); - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz|z", &array, &tmp, &userdata) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz/|z/", &array, &tmp, &userdata) == FAILURE) { return; } target_hash = HASH_OF(array); @@ -1169,7 +1169,7 @@ PHP_FUNCTION(array_walk_recursive) HashTable *target_hash; old_walk_func_name = BG(array_walk_func_name); - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz|z", &array, &tmp, &userdata) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz/|z/", &array, &tmp, &userdata) == FAILURE) { return; } target_hash = HASH_OF(array); @@ -1270,15 +1270,13 @@ PHP_FUNCTION(array_search) /* }}} */ -static int php_valid_var_name(char *var_name) +static int php_valid_var_name(char *var_name, int len) { - int len, i; + int i; if (!var_name) return 0; - len = strlen(var_name); - if (!isalpha((int)((unsigned char *)var_name)[0]) && var_name[0] != '_') return 0; @@ -1409,7 +1407,7 @@ PHP_FUNCTION(extract) case EXTR_PREFIX_INVALID: if (final_name.len == 0) { - if (!php_valid_var_name(var_name)) { + if (!php_valid_var_name(var_name, var_name_len)) { smart_str_appendl(&final_name, Z_STRVAL_PP(prefix), Z_STRLEN_PP(prefix)); smart_str_appendc(&final_name, '_'); smart_str_appendl(&final_name, var_name, var_name_len); @@ -1426,7 +1424,7 @@ PHP_FUNCTION(extract) if (final_name.len) { smart_str_0(&final_name); - if (php_valid_var_name(final_name.c)) { + if (php_valid_var_name(final_name.c, final_name.len)) { if (extract_refs) { zval **orig_var; @@ -1438,7 +1436,7 @@ PHP_FUNCTION(extract) *orig_var = *entry; } else { - if ((*var_array)->refcount > 1) { + if ((*var_array)->refcount > 1 || *entry == EG(uninitialized_zval_ptr)) { SEPARATE_ZVAL_TO_MAKE_IS_REF(entry); } else { (*entry)->is_ref = 1; @@ -1720,13 +1718,13 @@ double_str: add_next_index_double(return_value, low); } } else { - int low, high; + double low, high; long lstep; long_str: - convert_to_long(zlow); - convert_to_long(zhigh); - low = Z_LVAL_P(zlow); - high = Z_LVAL_P(zhigh); + convert_to_double(zlow); + convert_to_double(zhigh); + low = Z_DVAL_P(zlow); + high = Z_DVAL_P(zhigh); lstep = (long) step; if (low > high) { /* Negative steps */ @@ -1735,18 +1733,18 @@ long_str: goto err; } for (; low >= high; low -= lstep) { - add_next_index_long(return_value, low); + add_next_index_long(return_value, (long)low); } - } else if (high > low) { /* Positive steps */ + } else if (high > low) { /* Positive steps */ if (high - low < lstep || lstep <= 0) { err = 1; goto err; } for (; low <= high; low += lstep) { - add_next_index_long(return_value, low); + add_next_index_long(return_value, (long)low); } } else { - add_next_index_long(return_value, low); + add_next_index_long(return_value, (long)low); } } err: @@ -1874,7 +1872,7 @@ HashTable* php_splice(HashTable *in_hash, int offset, int length, /* Update output hash depending on key type */ if (p->nKeyLength) - zend_hash_update(out_hash, p->arKey, p->nKeyLength, &entry, sizeof(zval *), NULL); + zend_hash_quick_update(out_hash, p->arKey, p->nKeyLength, p->h, &entry, sizeof(zval *), NULL); else zend_hash_next_index_insert(out_hash, &entry, sizeof(zval *), NULL); } @@ -1885,7 +1883,7 @@ HashTable* php_splice(HashTable *in_hash, int offset, int length, entry = *((zval **)p->pData); entry->refcount++; if (p->nKeyLength) - zend_hash_update(*removed, p->arKey, p->nKeyLength, &entry, sizeof(zval *), NULL); + zend_hash_quick_update(*removed, p->arKey, p->nKeyLength, p->h, &entry, sizeof(zval *), NULL); else zend_hash_next_index_insert(*removed, &entry, sizeof(zval *), NULL); } @@ -1897,17 +1895,7 @@ HashTable* php_splice(HashTable *in_hash, int offset, int length, /* ..for each one, create a new zval, copy entry into it and copy it into the output hash */ for (i=0; i<list_count; i++) { entry = *list[i]; - if (entry->refcount>=1000) { - zval *tmp = (zval *) emalloc(sizeof(zval)); - - *tmp = *entry; - zval_copy_ctor(tmp); - tmp->refcount = 1; - tmp->is_ref = 0; - entry = tmp; - } else { - entry->refcount++; - } + entry->refcount++; zend_hash_next_index_insert(out_hash, &entry, sizeof(zval *), NULL); } } @@ -1917,7 +1905,7 @@ HashTable* php_splice(HashTable *in_hash, int offset, int length, entry = *((zval **)p->pData); entry->refcount++; if (p->nKeyLength) - zend_hash_update(out_hash, p->arKey, p->nKeyLength, &entry, sizeof(zval *), NULL); + zend_hash_quick_update(out_hash, p->arKey, p->nKeyLength, p->h, &entry, sizeof(zval *), NULL); else zend_hash_next_index_insert(out_hash, &entry, sizeof(zval *), NULL); } @@ -2033,7 +2021,7 @@ static void _phpi_pop(INTERNAL_FUNCTION_PARAMETERS, int off_the_end) if (should_rehash) { zend_hash_rehash(Z_ARRVAL_PP(stack)); } - } else if (!key_len) { + } else if (!key_len && index >= Z_ARRVAL_PP(stack)->nNextFreeElement-1) { Z_ARRVAL_PP(stack)->nNextFreeElement = Z_ARRVAL_PP(stack)->nNextFreeElement - 1; } @@ -2666,6 +2654,7 @@ PHP_FUNCTION(array_pad) num_pads = pad_size_abs - input_size; if(num_pads > 1048576) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "You may only pad up to 1048576 elements at a time"); + zval_dtor(return_value); RETURN_FALSE; } pads = (zval ***)safe_emalloc(num_pads, sizeof(zval **), 0); @@ -2803,7 +2792,7 @@ PHP_FUNCTION(array_change_key_case) Removes duplicate values from array */ PHP_FUNCTION(array_unique) { - zval **array; + zval **array, *tmp; HashTable *target_hash; Bucket *p; struct bucketindex { @@ -2822,8 +2811,8 @@ PHP_FUNCTION(array_unique) RETURN_FALSE; } - /* copy the argument array */ - RETVAL_ZVAL(*array, 1, 0); + array_init(return_value); + zend_hash_copy(Z_ARRVAL_P(return_value), target_hash, (copy_ctor_func_t) zval_add_ref, (void *)&tmp, sizeof(zval*)); if (target_hash->nNumOfElements <= 1) { /* nothing to do */ return; @@ -4088,10 +4077,8 @@ PHP_FUNCTION(array_reduce) while (zend_hash_get_current_data_ex(htbl, (void **)&operand, &pos) == SUCCESS) { if (result) { zend_fcall_info fci; - args[0] = &result; args[1] = operand; - fci.size = sizeof(fci); fci.function_table = EG(function_table); fci.function_name = *callback; @@ -4117,7 +4104,7 @@ PHP_FUNCTION(array_reduce) zend_hash_move_forward_ex(htbl, &pos); } - RETVAL_ZVAL(result, 0, 1); + RETVAL_ZVAL(result, 1, 1); } /* }}} */ diff --git a/ext/standard/assert.c b/ext/standard/assert.c index 06089f89c..220ffad51 100644 --- a/ext/standard/assert.c +++ b/ext/standard/assert.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: assert.c,v 1.60.2.3.2.2 2006/07/01 12:21:07 nlopess Exp $ */ +/* $Id: assert.c,v 1.60.2.3.2.6 2007/02/16 16:35:04 dmitry Exp $ */ /* {{{ includes/startup/misc */ @@ -30,6 +30,7 @@ ZEND_BEGIN_MODULE_GLOBALS(assert) long warning; long quiet_eval; zval *callback; + char *cb; ZEND_END_MODULE_GLOBALS(assert) ZEND_DECLARE_MODULE_GLOBALS(assert) @@ -52,15 +53,26 @@ enum { static PHP_INI_MH(OnChangeCallback) { - if (ASSERTG(callback)) { - zval_ptr_dtor(&ASSERTG(callback)); - } - - if (new_value && (ASSERTG(callback) || new_value_length)) { - MAKE_STD_ZVAL(ASSERTG(callback)); - ZVAL_STRINGL(ASSERTG(callback), new_value, new_value_length, 1); + if (EG(in_execution)) { + if (ASSERTG(callback)) { + zval_ptr_dtor(&ASSERTG(callback)); + } + if (new_value && (ASSERTG(callback) || new_value_length)) { + MAKE_STD_ZVAL(ASSERTG(callback)); + ZVAL_STRINGL(ASSERTG(callback), new_value, new_value_length, 1); + } + } else { + if (ASSERTG(cb)) { + pefree(ASSERTG(cb), 1); + } + if (new_value && new_value_length) { + ASSERTG(cb) = pemalloc(new_value_length + 1, 1); + memcpy(ASSERTG(cb), new_value, new_value_length); + ASSERTG(cb)[new_value_length] = '\0'; + } else { + ASSERTG(cb) = NULL; + } } - return SUCCESS; } @@ -75,6 +87,7 @@ PHP_INI_END() static void php_assert_init_globals(zend_assert_globals *assert_globals_p TSRMLS_DC) { assert_globals_p->callback = NULL; + assert_globals_p->cb = NULL; } PHP_MINIT_FUNCTION(assert) @@ -94,9 +107,9 @@ PHP_MINIT_FUNCTION(assert) PHP_MSHUTDOWN_FUNCTION(assert) { - if (ASSERTG(callback)) { - zval_ptr_dtor(&ASSERTG(callback)); - ASSERTG(callback) = NULL; + if (ASSERTG(cb)) { + pefree(ASSERTG(cb), 1); + ASSERTG(cb) = NULL; } return SUCCESS; } @@ -174,6 +187,11 @@ PHP_FUNCTION(assert) RETURN_TRUE; } + if (!ASSERTG(callback) && ASSERTG(cb)) { + MAKE_STD_ZVAL(ASSERTG(callback)); + ZVAL_STRING(ASSERTG(callback), ASSERTG(cb), 1); + } + if (ASSERTG(callback)) { zval *args[3]; zval *retval; @@ -268,6 +286,13 @@ PHP_FUNCTION(assert_options) break; case ASSERT_CALLBACK: + if (ASSERTG(callback) != NULL) { + RETVAL_ZVAL(ASSERTG(callback), 1, 0); + } else if (ASSERTG(cb)) { + RETVAL_STRING(ASSERTG(cb), 1); + } else { + RETVAL_NULL(); + } if (ac == 2) { if (ASSERTG(callback)) { zval_ptr_dtor(&ASSERTG(callback)); @@ -275,7 +300,7 @@ PHP_FUNCTION(assert_options) ASSERTG(callback) = *value; zval_add_ref(value); } - RETURN_TRUE; + return; break; default: diff --git a/ext/standard/base64.c b/ext/standard/base64.c index 4aed7bc4e..407aba947 100644 --- a/ext/standard/base64.c +++ b/ext/standard/base64.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -15,7 +15,7 @@ | Author: Jim Winstead <jimw@php.net> | +----------------------------------------------------------------------+ */ -/* $Id: base64.c,v 1.43.2.2.2.1 2006/05/06 22:47:14 iliaa Exp $ */ +/* $Id: base64.c,v 1.43.2.2.2.2 2007/01/01 09:36:08 sebastian Exp $ */ #include <string.h> diff --git a/ext/standard/base64.h b/ext/standard/base64.h index a18c5e2f4..20c3f3dbe 100644 --- a/ext/standard/base64.h +++ b/ext/standard/base64.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: base64.h,v 1.14.2.1.2.1 2006/05/06 22:47:14 iliaa Exp $ */ +/* $Id: base64.h,v 1.14.2.1.2.2 2007/01/01 09:36:08 sebastian Exp $ */ #ifndef BASE64_H #define BASE64_H diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index 653119660..085ef0364 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: basic_functions.c,v 1.725.2.31.2.28 2006/10/13 01:42:19 iliaa Exp $ */ +/* $Id: basic_functions.c,v 1.725.2.31.2.49 2007/04/17 20:34:14 tony2001 Exp $ */ #include "php.h" #include "php_streams.h" @@ -1399,6 +1399,9 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_fnmatch, 0, 0, 2) ZEND_ARG_INFO(0, flags) ZEND_END_ARG_INFO() #endif +static +ZEND_BEGIN_ARG_INFO(arginfo_sys_get_temp_dir, 0) +ZEND_END_ARG_INFO() /* }}} */ /* {{{ filestat.c */ static @@ -2440,6 +2443,14 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_stream_socket_enable_crypto, 0, 0, 2) ZEND_ARG_INFO(0, cryptokind) ZEND_ARG_INFO(0, sessionstream) ZEND_END_ARG_INFO() + +#ifdef HAVE_SHUTDOWN +static +ZEND_BEGIN_ARG_INFO(arginfo_stream_socket_shutdown, 0) + ZEND_ARG_INFO(0, stream) + ZEND_ARG_INFO(0, how) +ZEND_END_ARG_INFO() +#endif /* }}} */ /* {{{ string.c */ static @@ -3056,7 +3067,6 @@ ZEND_BEGIN_ARG_INFO(arginfo_unserialize, 0) ZEND_ARG_INFO(0, variable_representation) ZEND_END_ARG_INFO() -#if MEMORY_LIMIT static ZEND_BEGIN_ARG_INFO_EX(arginfo_memory_get_usage, 0, 0, 0) ZEND_ARG_INFO(0, real_usage) @@ -3066,7 +3076,6 @@ static ZEND_BEGIN_ARG_INFO_EX(arginfo_memory_get_peak_usage, 0, 0, 0) ZEND_ARG_INFO(0, real_usage) ZEND_END_ARG_INFO() -#endif /* }}} */ /* {{{ versioning.c */ static @@ -3323,10 +3332,10 @@ zend_function_entry basic_functions[] = { PHP_FE(number_format, arginfo_number_format) PHP_FE(fmod, arginfo_fmod) #ifdef HAVE_INET_NTOP - PHP_NAMED_FE(inet_ntop, php_inet_ntop, arginfo_inet_ntop) + PHP_RAW_NAMED_FE(inet_ntop, php_inet_ntop, arginfo_inet_ntop) #endif #ifdef HAVE_INET_PTON - PHP_NAMED_FE(inet_pton, php_inet_pton, arginfo_inet_pton) + PHP_RAW_NAMED_FE(inet_pton, php_inet_pton, arginfo_inet_pton) #endif PHP_FE(ip2long, arginfo_ip2long) PHP_FE(long2ip, arginfo_long2ip) @@ -3379,10 +3388,8 @@ zend_function_entry basic_functions[] = { PHP_FE(var_export, arginfo_var_export) PHP_FE(debug_zval_dump, arginfo_debug_zval_dump) PHP_FE(print_r, arginfo_print_r) -#if MEMORY_LIMIT PHP_FE(memory_get_usage, arginfo_memory_get_usage) PHP_FE(memory_get_peak_usage, arginfo_memory_get_peak_usage) -#endif PHP_FE(register_shutdown_function, arginfo_register_shutdown_function) PHP_FE(register_tick_function, arginfo_register_tick_function) @@ -3514,6 +3521,9 @@ zend_function_entry basic_functions[] = { PHP_FE(stream_socket_recvfrom, arginfo_stream_socket_recvfrom) PHP_FE(stream_socket_sendto, arginfo_stream_socket_sendto) PHP_FE(stream_socket_enable_crypto, arginfo_stream_socket_enable_crypto) +#ifdef HAVE_SHUTDOWN + PHP_FE(stream_socket_shutdown, arginfo_stream_socket_shutdown) +#endif #if HAVE_SOCKETPAIR PHP_FE(stream_socket_pair, arginfo_stream_socket_pair) #endif @@ -3762,6 +3772,7 @@ zend_function_entry basic_functions[] = { PHP_FE(output_add_rewrite_var, arginfo_output_add_rewrite_var) PHP_FE(output_reset_rewrite_vars, arginfo_output_reset_rewrite_vars) + PHP_FE(sys_get_temp_dir, arginfo_sys_get_temp_dir) {NULL, NULL, NULL} }; @@ -3833,10 +3844,17 @@ static void php_putenv_destructor(putenv_entry *pe) SetEnvironmentVariable(pe->key, "bugbug"); #endif putenv(pe->previous_value); +# if defined(PHP_WIN32) + efree(pe->previous_value); +# endif } else { # if HAVE_UNSETENV unsetenv(pe->key); # elif defined(PHP_WIN32) + char *del_string = emalloc(pe->key_len+2); + snprintf(del_string, pe->key_len+2, "%s=", pe->key); + putenv(del_string); + efree(del_string); SetEnvironmentVariable(pe->key, NULL); # else char **env; @@ -3940,7 +3958,7 @@ PHP_MINIT_FUNCTION(basic) #ifdef ZTS ts_allocate_id(&basic_globals_id, sizeof(php_basic_globals), (ts_allocate_ctor) basic_globals_ctor, (ts_allocate_dtor) basic_globals_dtor); #ifdef PHP_WIN32 - ts_allocate_id(&php_win32_core_globals_id, sizeof(php_win32_core_globals), (ts_allocate_ctor)php_win32_core_globals_ctor, NULL); + ts_allocate_id(&php_win32_core_globals_id, sizeof(php_win32_core_globals), (ts_allocate_ctor)php_win32_core_globals_ctor, (ts_allocate_dtor)php_win32_core_globals_dtor ); #endif #else basic_globals_ctor(&basic_globals TSRMLS_CC); @@ -4065,6 +4083,9 @@ PHP_MSHUTDOWN_FUNCTION(basic) #endif #else basic_globals_dtor(&basic_globals TSRMLS_CC); +#ifdef PHP_WIN32 + php_win32_core_globals_dtor(&the_php_win32_core_globals TSRMLS_CC); +#endif #endif php_unregister_url_stream_wrapper("php" TSRMLS_CC); @@ -4154,6 +4175,7 @@ PHP_RSHUTDOWN_FUNCTION(basic) if (BG(locale_string) != NULL) { setlocale(LC_ALL, "C"); setlocale(LC_CTYPE, ""); + zend_update_current_locale(); } STR_FREE(BG(locale_string)); BG(locale_string) = NULL; @@ -4395,7 +4417,8 @@ PHP_FUNCTION(putenv) /* Check the allowed list */ if (BG(sm_allowed_env_vars) && *BG(sm_allowed_env_vars)) { char *allowed_env_vars = estrdup(BG(sm_allowed_env_vars)); - char *allowed_prefix = strtok(allowed_env_vars, ", "); + char *strtok_buf = NULL; + char *allowed_prefix = php_strtok_r(allowed_env_vars, ", ", &strtok_buf); zend_bool allowed = 0; while (allowed_prefix) { @@ -4403,7 +4426,7 @@ PHP_FUNCTION(putenv) allowed = 1; break; } - allowed_prefix = strtok(NULL, ", "); + allowed_prefix = php_strtok_r(NULL, ", ", &strtok_buf); } efree(allowed_env_vars); if (!allowed) { @@ -4421,7 +4444,12 @@ PHP_FUNCTION(putenv) pe.previous_value = NULL; for (env = environ; env != NULL && *env != NULL; env++) { if (!strncmp(*env, pe.key, pe.key_len) && (*env)[pe.key_len] == '=') { /* found it */ +#if defined(PHP_WIN32) + /* must copy previous value because MSVCRT's putenv can free the string without notice */ + pe.previous_value = estrdup(*env); +#else pe.previous_value = *env; +#endif break; } } @@ -4433,8 +4461,15 @@ PHP_FUNCTION(putenv) * We try to avoid this by setting our own value first */ SetEnvironmentVariable(pe.key, "bugbug"); #endif - + +#if HAVE_UNSETENV + if (!p) { /* no '=' means we want to unset it */ + unsetenv(pe.putenv_string); + } + if (!p || putenv(pe.putenv_string) == 0) { /* success */ +#else if (putenv(pe.putenv_string) == 0) { /* success */ +#endif zend_hash_add(&BG(putenv_ht), pe.key, pe.key_len+1, (void **) &pe, sizeof(putenv_entry), NULL); #ifdef HAVE_TZSET if (!strncmp(pe.key, "TZ", pe.key_len)) { @@ -4648,13 +4683,13 @@ PHP_FUNCTION(getopt) } } else { /* other strings */ - if(zend_hash_find(HASH_OF(return_value), optname, strlen(optname)+1, (void **)&args) != FAILURE) { + if(zend_hash_find(HASH_OF(return_value), optname, optname_len + 1, (void **)&args) != FAILURE) { if(Z_TYPE_PP(args) != IS_ARRAY) { convert_to_array_ex(args); } zend_hash_next_index_insert(HASH_OF(*args), (void *)&val, sizeof(zval *), NULL); } else { - zend_hash_add(HASH_OF(return_value), optname, strlen(optname)+1, (void *)&val, sizeof(zval *), NULL); + zend_hash_add(HASH_OF(return_value), optname, optname_len + 1, (void *)&val, sizeof(zval *), NULL); } } } @@ -4725,7 +4760,7 @@ PHP_FUNCTION(time_nanosleep) struct timespec php_req, php_rem; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &tv_sec, &tv_nsec)) { - WRONG_PARAM_COUNT; + return; } php_req.tv_sec = (time_t) tv_sec; @@ -4754,7 +4789,7 @@ PHP_FUNCTION(time_sleep_until) struct timespec php_req, php_rem; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &d_ts)) { - WRONG_PARAM_COUNT; + return; } if (gettimeofday((struct timeval *) &tm, NULL) != 0) { @@ -5289,17 +5324,24 @@ static int user_tick_function_compare(user_tick_function_entry * tick_fe1, user_ { zval *func1 = tick_fe1->arguments[0]; zval *func2 = tick_fe2->arguments[0]; + int ret; TSRMLS_FETCH(); if (Z_TYPE_P(func1) == IS_STRING && Z_TYPE_P(func2) == IS_STRING) { - return (zend_binary_zval_strcmp(func1, func2) == 0); + ret = (zend_binary_zval_strcmp(func1, func2) == 0); } else if (Z_TYPE_P(func1) == IS_ARRAY && Z_TYPE_P(func2) == IS_ARRAY) { zval result; zend_compare_arrays(&result, func1, func2 TSRMLS_CC); - return (Z_LVAL(result) == 0); + ret = (Z_LVAL(result) == 0); } else { + ret = 0; + } + + if (ret && tick_fe1->calling) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to delete tick function executed at the moment"); return 0; } + return ret; } void php_call_shutdown_functions(TSRMLS_D) @@ -6102,6 +6144,12 @@ static void php_simple_ini_parser_cb(zval *arg1, zval *arg2, int callback_type, } } + if (Z_TYPE_P(hash) != IS_ARRAY) { + zval_dtor(hash); + INIT_PZVAL(hash); + array_init(hash); + } + ALLOC_ZVAL(element); *element = *arg2; zval_copy_ctor(element); @@ -6211,6 +6259,33 @@ static int copy_request_variable(void *pDest, int num_args, va_list args, zend_h } else if (!strcmp(hash_key->arKey, "GLOBALS")) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Attempted GLOBALS variable overwrite."); return 0; + } else if (*hash_key->arKey == '_' && + ( + !strcmp(hash_key->arKey, "_GET") || + !strcmp(hash_key->arKey, "_POST") || + !strcmp(hash_key->arKey, "_COOKIE") || + !strcmp(hash_key->arKey, "_ENV") || + !strcmp(hash_key->arKey, "_SERVER") || + !strcmp(hash_key->arKey, "_SESSION") || + !strcmp(hash_key->arKey, "_FILES") || + !strcmp(hash_key->arKey, "_REQUEST") + ) + ) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Attempted super-global (%s) variable overwrite.", hash_key->arKey); + return 0; + } else if (*hash_key->arKey == 'H' && + ( + !strcmp(hash_key->arKey, "HTTP_POST_VARS") || + !strcmp(hash_key->arKey, "HTTP_GET_VARS") || + !strcmp(hash_key->arKey, "HTTP_COOKIE_VARS") || + !strcmp(hash_key->arKey, "HTTP_ENV_VARS") || + !strcmp(hash_key->arKey, "HTTP_SERVER_VARS") || + !strcmp(hash_key->arKey, "HTTP_RAW_POST_DATA") || + !strcmp(hash_key->arKey, "HTTP_POST_FILES") + ) + ) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Attempted long input array (%s) overwrite.", hash_key->arKey); + return 0; } } diff --git a/ext/standard/basic_functions.h b/ext/standard/basic_functions.h index df1401ae9..e6e392d4e 100644 --- a/ext/standard/basic_functions.h +++ b/ext/standard/basic_functions.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: basic_functions.h,v 1.139.2.4.2.2 2006/07/19 12:25:46 mike Exp $ */ +/* $Id: basic_functions.h,v 1.139.2.4.2.4 2007/01/01 09:36:08 sebastian Exp $ */ #ifndef BASIC_FUNCTIONS_H #define BASIC_FUNCTIONS_H @@ -146,7 +146,7 @@ typedef signed int php_int32; #elif SIZEOF_LONG == 4 /* 16-bit systems? */ typedef unsigned long php_uint32; -typedef signed int php_int32; +typedef signed long php_int32; #else #error Need type which holds 32 bits #endif diff --git a/ext/standard/browscap.c b/ext/standard/browscap.c index c185a888d..bd9cafa57 100644 --- a/ext/standard/browscap.c +++ b/ext/standard/browscap.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: browscap.c,v 1.85.2.2 2006/01/01 12:50:14 sniper Exp $ */ +/* $Id: browscap.c,v 1.85.2.2.2.3 2007/03/07 00:52:40 iliaa Exp $ */ #include "php.h" #include "php_regex.h" @@ -55,7 +55,7 @@ static void convert_browscap_pattern(zval *pattern) php_strtolower(Z_STRVAL_P(pattern), Z_STRLEN_P(pattern)); - t = (char *) malloc(Z_STRLEN_P(pattern)*2 + 3); + t = (char *) safe_pemalloc(Z_STRLEN_P(pattern), 2, 3, 1); t[0] = '^'; @@ -100,7 +100,7 @@ static void php_browscap_parser_cb(zval *arg1, zval *arg2, int callback_type, vo zval *new_property; char *new_key; - new_property = (zval *) malloc(sizeof(zval)); + new_property = (zval *) pemalloc(sizeof(zval), 1); INIT_PZVAL(new_property); Z_STRVAL_P(new_property) = zend_strndup(Z_STRVAL_P(arg2), Z_STRLEN_P(arg2)); Z_STRLEN_P(new_property) = Z_STRLEN_P(arg2); @@ -118,14 +118,14 @@ static void php_browscap_parser_cb(zval *arg1, zval *arg2, int callback_type, vo HashTable *section_properties; /*printf("'%s' (%d)\n",$1.value.str.val,$1.value.str.len+1);*/ - current_section = (zval *) malloc(sizeof(zval)); + current_section = (zval *) pemalloc(sizeof(zval), 1); INIT_PZVAL(current_section); - processed = (zval *) malloc(sizeof(zval)); + processed = (zval *) pemalloc(sizeof(zval), 1); INIT_PZVAL(processed); - unprocessed = (zval *) malloc(sizeof(zval)); + unprocessed = (zval *) pemalloc(sizeof(zval), 1); INIT_PZVAL(unprocessed); - section_properties = (HashTable *) malloc(sizeof(HashTable)); + section_properties = (HashTable *) pemalloc(sizeof(HashTable), 1); zend_hash_init(section_properties, 0, NULL, (dtor_func_t) browscap_entry_dtor, 1); current_section->value.ht = section_properties; current_section->type = IS_ARRAY; @@ -350,9 +350,7 @@ PHP_FUNCTION(get_browser) } } - if (lookup_browser_name) { - efree(lookup_browser_name); - } + efree(lookup_browser_name); } /* }}} */ diff --git a/ext/standard/config.w32 b/ext/standard/config.w32 index 969af0dad..3129760b4 100644 --- a/ext/standard/config.w32 +++ b/ext/standard/config.w32 @@ -1,5 +1,5 @@ // vim:ft=javascript -// $Id: config.w32,v 1.4.2.2 2006/01/04 21:31:29 derick Exp $ +// $Id: config.w32,v 1.4.2.2.2.1 2007/04/18 09:38:54 rrichards Exp $ ARG_WITH("config-file-scan-dir", "Dir to check for additional php ini files", ""); AC_DEFINE("PHP_CONFIG_FILE_SCAN_DIR", PHP_CONFIG_FILE_SCAN_DIR); @@ -16,5 +16,5 @@ EXTENSION("standard", "array.c base64.c basic_functions.c browscap.c \ url_scanner_ex.c ftp_fopen_wrapper.c http_fopen_wrapper.c \ php_fopen_wrapper.c credits.c css.c var_unserializer.c ftok.c sha1.c \ user_filters.c uuencode.c filters.c proc_open.c \ - streamsfuncs.c http.c", false /* never shared */); + streamsfuncs.c http.c flock_compat.c", false /* never shared */); diff --git a/ext/standard/crc32.c b/ext/standard/crc32.c index af517f726..7116e468a 100644 --- a/ext/standard/crc32.c +++ b/ext/standard/crc32.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: crc32.c,v 1.16.2.4 2006/02/09 15:48:46 pajoye Exp $ */ +/* $Id: crc32.c,v 1.16.2.4.2.1 2007/01/01 09:36:08 sebastian Exp $ */ #include "php.h" #include "basic_functions.h" diff --git a/ext/standard/crc32.h b/ext/standard/crc32.h index 8323f9f33..3fa98d45a 100644 --- a/ext/standard/crc32.h +++ b/ext/standard/crc32.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: crc32.h,v 1.6.2.1 2006/01/01 12:50:14 sniper Exp $ */ +/* $Id: crc32.h,v 1.6.2.1.2.1 2007/01/01 09:36:08 sebastian Exp $ */ /* * This code implements the AUTODIN II polynomial diff --git a/ext/standard/credits.c b/ext/standard/credits.c index 0d689ac4b..d1a9d6716 100644 --- a/ext/standard/credits.c +++ b/ext/standard/credits.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: credits.c,v 1.36.2.4.2.1 2006/09/03 11:27:50 johannes Exp $ */ +/* $Id: credits.c,v 1.36.2.4.2.3 2007/01/01 09:36:08 sebastian Exp $ */ #include "php.h" #include "info.h" @@ -97,7 +97,6 @@ PHPAPI void php_print_credits(int flag TSRMLS_DC) php_info_print_table_start(); php_info_print_table_colspan_header(2, "PHP Documentation"); CREDIT_LINE("Authors", "Mehdi Achour, Friedhelm Betz, Antony Dovgal, Nuno Lopes, Philip Olson, Georg Richter, Damien Seguy, Jakub Vrana"); - CREDIT_LINE("Editor", "Gabor Hojtsy"); CREDIT_LINE("User Note Maintainers", "Mehdi Achour, Friedhelm Betz, Vincent Gevers, Aidan Lister, Nuno Lopes, Tom Sommer"); CREDIT_LINE("Other Contributors", "Previously active authors, editors and other contributors are listed in the manual."); php_info_print_table_end(); @@ -114,7 +113,7 @@ PHPAPI void php_print_credits(int flag TSRMLS_DC) /* Website Team */ php_info_print_table_start(); php_info_print_table_header(1, "PHP Website Team"); - php_info_print_table_row(1, "Gabor Hojtsy, Colin Viebrock, Jim Winstead"); + php_info_print_table_row(1, "Hannes Magnusson, Colin Viebrock, Jim Winstead"); php_info_print_table_end(); } diff --git a/ext/standard/credits.h b/ext/standard/credits.h index f43756748..27ad4dd41 100644 --- a/ext/standard/credits.h +++ b/ext/standard/credits.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: credits.h,v 1.11.2.1 2006/01/01 12:50:14 sniper Exp $ */ +/* $Id: credits.h,v 1.11.2.1.2.1 2007/01/01 09:36:08 sebastian Exp $ */ #ifndef CREDITS_H #define CREDITS_H diff --git a/ext/standard/credits_ext.h b/ext/standard/credits_ext.h index 889d10d4a..b468545c6 100644 --- a/ext/standard/credits_ext.h +++ b/ext/standard/credits_ext.h @@ -32,7 +32,6 @@ CREDIT_LINE("GetText", "Alex Plotnick"); CREDIT_LINE("GNU GMP support", "Stanislav Malyshev"); CREDIT_LINE("Iconv", "Rui Hirokawa, Stig Bakken, Moriyoshi Koizumi "); CREDIT_LINE("IMAP", "Rex Logan, Mark Musone, Brian Wang, Kaj-Michael Lang, Antoni Pamies Olive, Rasmus Lerdorf, Andrew Skalski, Chuck Hagenbuch, Daniel R Kalowsky"); -CREDIT_LINE("Informix", "Danny Heijl, Christian Cartus, Corne' Cornelius"); CREDIT_LINE("Input Filter", "Rasmus Lerdorf, Derick Rethans, Pierre-Alain Joye, Ilia Alshanetsky"); CREDIT_LINE("InterBase", "Jouni Ahto, Andrew Avdeev, Ard Biesheuvel"); CREDIT_LINE("JSON", "Omar Kilani"); @@ -46,7 +45,7 @@ CREDIT_LINE("mSQL", "Zeev Suraski"); CREDIT_LINE("MS SQL", "Frank M. Kromann"); CREDIT_LINE("Multibyte String Functions", "Tsukada Takuya, Rui Hirokawa"); CREDIT_LINE("mySQL driver for PDO", "George Schlossnagle, Wez Furlong, Ilia Alshanetsky"); -CREDIT_LINE("MySQLi", "Zak Greant, Georg Richter"); +CREDIT_LINE("MySQLi", "Zak Greant, Georg Richter, Andrey Hristov, Ulf Wendel"); CREDIT_LINE("MySQL", "Zeev Suraski, Zak Greant, Georg Richter"); CREDIT_LINE("ncurses", "Ilia Alshanetsky, Wez Furlong, Hartmut Holzgraefe, Georg Richter"); CREDIT_LINE("OCI8", "Stig Bakken, Thies C. Arntzen, Andy Sautins, David Benson, Maxim Maletsky, Harald Radi, Antony Dovgal, Andi Gutmans, Wez Furlong"); diff --git a/ext/standard/credits_sapi.h b/ext/standard/credits_sapi.h index cc15c006f..1c549f777 100644 --- a/ext/standard/credits_sapi.h +++ b/ext/standard/credits_sapi.h @@ -16,7 +16,7 @@ CREDIT_LINE("Apache 1.3", "Rasmus Lerdorf, Zeev Suraski, Stig Bakken, David Skla CREDIT_LINE("Apache 2.0 Filter", "Sascha Schumann, Aaron Bannert"); CREDIT_LINE("Apache 2.0 Handler", "Ian Holsman, Justin Erenkrantz (based on Apache 2.0 Filter code)"); CREDIT_LINE("Caudium / Roxen", "David Hedbor"); -CREDIT_LINE("CGI / FastCGI", "Rasmus Lerdorf, Stig Bakken, Shane Caraveo"); +CREDIT_LINE("CGI / FastCGI", "Rasmus Lerdorf, Stig Bakken, Shane Caraveo, Dmitry Stogov"); CREDIT_LINE("CLI", "Edin Kadribasic, Marcus Boerger, Johannes Schlueter"); CREDIT_LINE("Continuity", "Alex Leigh (based on nsapi code)"); CREDIT_LINE("Embed", "Edin Kadribasic"); diff --git a/ext/standard/crypt.c b/ext/standard/crypt.c index 629a54487..2a74d1bd0 100644 --- a/ext/standard/crypt.c +++ b/ext/standard/crypt.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -17,7 +17,7 @@ | Rasmus Lerdorf <rasmus@php.net> | +----------------------------------------------------------------------+ */ -/* $Id: crypt.c,v 1.62.2.1 2006/01/01 12:50:14 sniper Exp $ */ +/* $Id: crypt.c,v 1.62.2.1.2.6 2007/01/01 09:36:08 sebastian Exp $ */ #include <stdlib.h> #include "php.h" @@ -28,6 +28,9 @@ #include <unistd.h> #endif #if HAVE_CRYPT_H +#if defined(CRYPT_R_GNU_SOURCE) && !defined(_GNU_SOURCE) +#define _GNU_SOURCE +#endif #include <crypt.h> #endif #if TM_IN_SYS_TIME @@ -145,8 +148,22 @@ PHP_FUNCTION(crypt) salt[2] = '\0'; #endif } +#if defined(HAVE_CRYPT_R) && (defined(_REENTRANT) || defined(_THREAD_SAFE)) + { +#if defined(CRYPT_R_STRUCT_CRYPT_DATA) + struct crypt_data buffer; + memset(&buffer, 0, sizeof(buffer)); +#elif defined(CRYPT_R_CRYPTD) + CRYPTD buffer; +#else +#error Data struct used by crypt_r() is unknown. Please report. +#endif - RETVAL_STRING(crypt(str, salt), 1); + RETURN_STRING(crypt_r(str, salt, &buffer), 1); + } +#else + RETURN_STRING(crypt(str, salt), 1); +#endif } /* }}} */ #endif diff --git a/ext/standard/css.c b/ext/standard/css.c index e6fdb2569..8595e0d3d 100644 --- a/ext/standard/css.c +++ b/ext/standard/css.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: css.c,v 1.13.2.1 2006/01/01 12:50:14 sniper Exp $ */ +/* $Id: css.c,v 1.13.2.1.2.1 2007/01/01 09:36:08 sebastian Exp $ */ #include "php.h" #include "info.h" diff --git a/ext/standard/css.h b/ext/standard/css.h index fc38da8ad..fdced8f61 100644 --- a/ext/standard/css.h +++ b/ext/standard/css.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: css.h,v 1.6.2.1 2006/01/01 12:50:14 sniper Exp $ */ +/* $Id: css.h,v 1.6.2.1.2.1 2007/01/01 09:36:08 sebastian Exp $ */ #ifndef CSS_H #define CSS_H diff --git a/ext/standard/cyr_convert.c b/ext/standard/cyr_convert.c index 501f9a61a..ac2eef59b 100644 --- a/ext/standard/cyr_convert.c +++ b/ext/standard/cyr_convert.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: cyr_convert.c,v 1.27.2.3 2006/01/18 23:55:47 tony2001 Exp $ */ +/* $Id: cyr_convert.c,v 1.27.2.3.2.1 2007/01/01 09:36:08 sebastian Exp $ */ #include <stdlib.h> diff --git a/ext/standard/cyr_convert.h b/ext/standard/cyr_convert.h index 1c320c56d..fba4877ba 100644 --- a/ext/standard/cyr_convert.h +++ b/ext/standard/cyr_convert.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: cyr_convert.h,v 1.11.2.1 2006/01/01 12:50:14 sniper Exp $ */ +/* $Id: cyr_convert.h,v 1.11.2.1.2.1 2007/01/01 09:36:08 sebastian Exp $ */ #ifndef CYR_CONVERT_H #define CYR_CONVERT_H diff --git a/ext/standard/datetime.c b/ext/standard/datetime.c index bb4e402b5..dd1ae7cbe 100644 --- a/ext/standard/datetime.c +++ b/ext/standard/datetime.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: datetime.c,v 1.134.2.2.2.2 2006/08/24 11:06:02 tony2001 Exp $ */ +/* $Id: datetime.c,v 1.134.2.2.2.3 2007/01/01 09:36:08 sebastian Exp $ */ #include "php.h" #include "zend_operators.h" diff --git a/ext/standard/datetime.h b/ext/standard/datetime.h index 26a1b2b43..1f8bcc99f 100644 --- a/ext/standard/datetime.h +++ b/ext/standard/datetime.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: datetime.h,v 1.23.2.2 2006/01/01 12:50:14 sniper Exp $ */ +/* $Id: datetime.h,v 1.23.2.2.2.1 2007/01/01 09:36:08 sebastian Exp $ */ #ifndef DATETIME_H #define DATETIME_H diff --git a/ext/standard/dir.c b/ext/standard/dir.c index 435f099c5..751fd404c 100644 --- a/ext/standard/dir.c +++ b/ext/standard/dir.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: dir.c,v 1.147.2.3.2.1 2006/10/04 23:19:25 iliaa Exp $ */ +/* $Id: dir.c,v 1.147.2.3.2.4 2007/02/24 17:16:23 iliaa Exp $ */ /* {{{ includes/startup/misc */ @@ -257,12 +257,13 @@ PHP_FUNCTION(chroot) } ret = chroot(str); - if (ret != 0) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s (errno %d)", strerror(errno), errno); RETURN_FALSE; } + realpath_cache_clean(TSRMLS_C); + ret = chdir("/"); if (ret != 0) { @@ -421,7 +422,7 @@ PHP_FUNCTION(glob) /* we assume that any glob pattern will match files from one directory only so checking the dirname of the first match should be sufficient */ - strncpy(cwd, globbuf.gl_pathv[0], MAXPATHLEN); + strlcpy(cwd, globbuf.gl_pathv[0], MAXPATHLEN); if (PG(safe_mode) && (!php_checkuid(cwd, NULL, CHECKUID_CHECK_FILE_AND_DIR))) { RETURN_FALSE; } diff --git a/ext/standard/dl.c b/ext/standard/dl.c index 543086be3..75d8e2e89 100644 --- a/ext/standard/dl.c +++ b/ext/standard/dl.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: dl.c,v 1.106.2.1 2006/01/01 12:50:14 sniper Exp $ */ +/* $Id: dl.c,v 1.106.2.1.2.2 2007/02/23 00:37:35 iliaa Exp $ */ #include "php.h" #include "dl.h" @@ -125,12 +125,10 @@ void php_dl(zval *file, int type, zval *return_value, int start_now TSRMLS_DC) if (extension_dir && extension_dir[0]){ int extension_dir_len = strlen(extension_dir); - libpath = emalloc(extension_dir_len+Z_STRLEN_P(file)+2); - if (IS_SLASH(extension_dir[extension_dir_len-1])) { - sprintf(libpath, "%s%s", extension_dir, Z_STRVAL_P(file)); /* SAFE */ + spprintf(&libpath, 0, "%s%s", extension_dir, Z_STRVAL_P(file)); } else { - sprintf(libpath, "%s%c%s", extension_dir, DEFAULT_SLASH, Z_STRVAL_P(file)); /* SAFE */ + spprintf(&libpath, 0, "%s%c%s", extension_dir, DEFAULT_SLASH, Z_STRVAL_P(file)); } } else { libpath = estrndup(Z_STRVAL_P(file), Z_STRLEN_P(file)); diff --git a/ext/standard/dl.h b/ext/standard/dl.h index ad0ff0ae9..114680770 100644 --- a/ext/standard/dl.h +++ b/ext/standard/dl.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: dl.h,v 1.23.2.1 2006/01/01 12:50:14 sniper Exp $ */ +/* $Id: dl.h,v 1.23.2.1.2.1 2007/01/01 09:36:08 sebastian Exp $ */ #ifndef DL_H #define DL_H diff --git a/ext/standard/dns.c b/ext/standard/dns.c index 946803a56..7cb16bc0a 100644 --- a/ext/standard/dns.c +++ b/ext/standard/dns.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: dns.c,v 1.70.2.7 2006/01/01 12:50:14 sniper Exp $ */ +/* $Id: dns.c,v 1.70.2.7.2.2 2007/02/24 02:17:27 helly Exp $ */ /* {{{ includes */ #include "php.h" @@ -422,7 +422,7 @@ static u_char *php_parserr(u_char *cp, querybuf *answer, int type_to_fetch, int switch (type) { case DNS_T_A: add_assoc_string(*subarray, "type", "A", 1); - sprintf(name, "%d.%d.%d.%d", cp[0], cp[1], cp[2], cp[3]); + snprintf(name, sizeof(name), "%d.%d.%d.%d", cp[0], cp[1], cp[2], cp[3]); add_assoc_string(*subarray, "ip", name, 1); cp += dlen; break; diff --git a/ext/standard/dns.h b/ext/standard/dns.h index 4f130a882..cc4772aab 100644 --- a/ext/standard/dns.h +++ b/ext/standard/dns.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: dns.h,v 1.19.2.1 2006/01/01 12:50:14 sniper Exp $ */ +/* $Id: dns.h,v 1.19.2.1.2.1 2007/01/01 09:36:08 sebastian Exp $ */ #ifndef DNS_H #define DNS_H diff --git a/ext/standard/exec.c b/ext/standard/exec.c index 6ff23cc12..eb44b1d72 100644 --- a/ext/standard/exec.c +++ b/ext/standard/exec.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -16,7 +16,7 @@ | Ilia Alshanetsky <iliaa@php.net> | +----------------------------------------------------------------------+ */ -/* $Id: exec.c,v 1.113.2.3 2006/02/26 10:49:50 helly Exp $ */ +/* $Id: exec.c,v 1.113.2.3.2.1 2007/01/01 09:36:08 sebastian Exp $ */ #include <stdio.h> #include "php.h" diff --git a/ext/standard/exec.h b/ext/standard/exec.h index ed4206055..43d798b2b 100644 --- a/ext/standard/exec.h +++ b/ext/standard/exec.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: exec.h,v 1.24.2.3 2006/01/01 12:50:14 sniper Exp $ */ +/* $Id: exec.h,v 1.24.2.3.2.1 2007/01/01 09:36:08 sebastian Exp $ */ #ifndef EXEC_H #define EXEC_H diff --git a/ext/standard/file.c b/ext/standard/file.c index 9927cdfc2..92eb8e1ca 100644 --- a/ext/standard/file.c +++ b/ext/standard/file.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -21,7 +21,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: file.c,v 1.409.2.6.2.7 2006/10/13 01:42:19 iliaa Exp $ */ +/* $Id: file.c,v 1.409.2.6.2.17 2007/02/23 16:22:20 tony2001 Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -228,6 +228,10 @@ PHP_MINIT_FUNCTION(file) REGISTER_LONG_CONSTANT("STREAM_CRYPTO_METHOD_SSLv23_SERVER", STREAM_CRYPTO_METHOD_SSLv23_SERVER, CONST_CS|CONST_PERSISTENT); REGISTER_LONG_CONSTANT("STREAM_CRYPTO_METHOD_TLS_SERVER", STREAM_CRYPTO_METHOD_TLS_SERVER, CONST_CS|CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("STREAM_SHUT_RD", STREAM_SHUT_RD, CONST_CS|CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("STREAM_SHUT_WR", STREAM_SHUT_WR, CONST_CS|CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("STREAM_SHUT_RDWR", STREAM_SHUT_RDWR, CONST_CS|CONST_PERSISTENT); + #ifdef PF_INET REGISTER_LONG_CONSTANT("STREAM_PF_INET", PF_INET, CONST_CS|CONST_PERSISTENT); #elif defined(AF_INET) @@ -399,6 +403,7 @@ PHP_FUNCTION(get_meta_tags) } } else if (tok_last == TOK_EQUAL && looking_for_val) { if (saw_name) { + STR_FREE(name); /* Get the NAME attr (Single word attr, non-quoted) */ temp = name = estrndup(md.token_data, md.token_len); @@ -411,6 +416,7 @@ PHP_FUNCTION(get_meta_tags) have_name = 1; } else if (saw_content) { + STR_FREE(value); /* Get the CONTENT attr (Single word attr, non-quoted) */ if (PG(magic_quotes_runtime)) { value = php_addslashes(md.token_data, 0, &md.token_len, 0 TSRMLS_CC); @@ -437,6 +443,7 @@ PHP_FUNCTION(get_meta_tags) } } else if (tok == TOK_STRING && tok_last == TOK_EQUAL && looking_for_val) { if (saw_name) { + STR_FREE(name); /* Get the NAME attr (Quoted single/double) */ temp = name = estrndup(md.token_data, md.token_len); @@ -449,6 +456,7 @@ PHP_FUNCTION(get_meta_tags) have_name = 1; } else if (saw_content) { + STR_FREE(value); /* Get the CONTENT attr (Single word attr, non-quoted) */ if (PG(magic_quotes_runtime)) { value = php_addslashes(md.token_data, 0, &md.token_len, 0 TSRMLS_CC); @@ -472,12 +480,13 @@ PHP_FUNCTION(get_meta_tags) /* For BC */ php_strtolower(name, strlen(name)); if (have_content) { - add_assoc_string(return_value, name, value, 0); + add_assoc_string(return_value, name, value, 1); } else { add_assoc_string(return_value, name, "", 1); } efree(name); + STR_FREE(value); } else if (have_content) { efree(value); } @@ -499,6 +508,8 @@ PHP_FUNCTION(get_meta_tags) md.token_data = NULL; } + STR_FREE(value); + STR_FREE(name); php_stream_close(md.stream); } @@ -535,7 +546,8 @@ PHP_FUNCTION(file_get_contents) } if (offset > 0 && php_stream_seek(stream, offset, SEEK_SET) < 0) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to seek to position %ld in the stream.", offset); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to seek to position %ld in the stream", offset); + php_stream_close(stream); RETURN_FALSE; } @@ -591,6 +603,7 @@ PHP_FUNCTION(file_put_contents) } if (flags & LOCK_EX && php_stream_lock(stream, LOCK_EX)) { + php_stream_close(stream); RETURN_FALSE; } @@ -645,11 +658,23 @@ PHP_FUNCTION(file_put_contents) } break; + case IS_OBJECT: + if (Z_OBJ_HT_P(data) != NULL) { + zval out; + + if (zend_std_cast_object_tostring(data, &out, IS_STRING TSRMLS_CC) == SUCCESS) { + numbytes = php_stream_write(stream, Z_STRVAL(out), Z_STRLEN(out)); + if (numbytes != Z_STRLEN(out)) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Only %d of %d bytes written, possibly out of free disk space", numbytes, Z_STRLEN(out)); + numbytes = -1; + } + zval_dtor(&out); + break; + } + } default: - php_error_docref(NULL TSRMLS_CC, E_WARNING, "The 2nd parameter should be either a string or an array"); - numbytes = -1; + numbytes = -1; break; - } php_stream_close(stream); @@ -1463,7 +1488,7 @@ PHP_FUNCTION(umask) oldumask = umask(077); - if (BG(umask) != -1) { + if (BG(umask) == -1) { BG(umask) = oldumask; } @@ -2151,9 +2176,11 @@ PHPAPI void php_fgetcsv(php_stream *stream, /* {{{ */ size_t new_len; char *new_temp; - memcpy(tptr, hunk_begin, bptr - hunk_begin); - tptr += (bptr - hunk_begin); - hunk_begin = bptr; + if (hunk_begin != line_end) { + memcpy(tptr, hunk_begin, bptr - hunk_begin); + tptr += (bptr - hunk_begin); + hunk_begin = bptr; + } /* add the embedded line end to the field */ memcpy(tptr, line_end, line_end_len); @@ -2481,6 +2508,14 @@ PHP_FUNCTION(fnmatch) /* }}} */ #endif +/* {{{ proto string sys_get_temp_dir() + Returns directory path used for temporary files */ +PHP_FUNCTION(sys_get_temp_dir) +{ + RETURN_STRING((char *)php_get_temporary_directory(), 1); +} +/* }}} */ + /* * Local variables: * tab-width: 4 diff --git a/ext/standard/file.h b/ext/standard/file.h index 65eaf464f..7a1c7d1b3 100644 --- a/ext/standard/file.h +++ b/ext/standard/file.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: file.h,v 1.94.2.2.2.2 2006/10/13 09:34:34 bjori Exp $ */ +/* $Id: file.h,v 1.94.2.2.2.5 2007/01/10 14:40:06 bjori Exp $ */ /* Synced with php 3.0 revision 1.30 1999-06-16 [ssb] */ @@ -60,12 +60,15 @@ PHP_FUNCTION(get_meta_tags); PHP_FUNCTION(flock); PHP_FUNCTION(fd_set); PHP_FUNCTION(fd_isset); -#if (!defined(__BEOS__) && HAVE_REALPATH) || defined(ZTS) +#if (!defined(__BEOS__) && !defined(NETWARE) && HAVE_REALPATH) || defined(ZTS) PHP_FUNCTION(realpath); +#endif +#ifdef HAVE_FNMATCH PHP_FUNCTION(fnmatch); #endif PHP_NAMED_FUNCTION(php_if_ftruncate); PHP_NAMED_FUNCTION(php_if_fstat); +PHP_FUNCTION(sys_get_temp_dir); PHP_MINIT_FUNCTION(user_streams); diff --git a/ext/standard/filestat.c b/ext/standard/filestat.c index 458fe267c..e6d6886e5 100644 --- a/ext/standard/filestat.c +++ b/ext/standard/filestat.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: filestat.c,v 1.136.2.8.2.3 2006/07/02 13:51:40 iliaa Exp $ */ +/* $Id: filestat.c,v 1.136.2.8.2.12 2007/04/06 22:10:56 tony2001 Exp $ */ #include "php.h" #include "safe_mode.h" @@ -98,14 +98,15 @@ #define S_IXROOT ( S_IXUSR | S_IXGRP | S_IXOTH ) -PHP_RINIT_FUNCTION(filestat) +PHP_RINIT_FUNCTION(filestat) /* {{{ */ { BG(CurrentStatFile)=NULL; BG(CurrentLStatFile)=NULL; return SUCCESS; } +/* }}} */ -PHP_RSHUTDOWN_FUNCTION(filestat) +PHP_RSHUTDOWN_FUNCTION(filestat) /* {{{ */ { if (BG(CurrentStatFile)) { efree (BG(CurrentStatFile)); @@ -117,15 +118,12 @@ PHP_RSHUTDOWN_FUNCTION(filestat) } return SUCCESS; } +/* }}} */ -/* {{{ proto float disk_total_space(string path) - Get total disk space for filesystem that path is on */ -PHP_FUNCTION(disk_total_space) +static int php_disk_total_space(char *path, double *space TSRMLS_DC) /* {{{ */ +#if defined(WINDOWS) /* {{{ */ { - zval **path; -#ifdef WINDOWS - double bytestotal; - + double bytestotal = 0; HINSTANCE kernel32; FARPROC gdfse; typedef BOOL (WINAPI *gdfse_func)(LPCTSTR, PULARGE_INTEGER, PULARGE_INTEGER, PULARGE_INTEGER); @@ -142,26 +140,6 @@ PHP_FUNCTION(disk_total_space) DWORD NumberOfFreeClusters; DWORD TotalNumberOfClusters; -#else /* not - WINDOWS */ -#if defined(HAVE_SYS_STATVFS_H) && defined(HAVE_STATVFS) - struct statvfs buf; -#elif (defined(HAVE_SYS_STATFS_H) || defined(HAVE_SYS_MOUNT_H)) && defined(HAVE_STATFS) - struct statfs buf; -#endif - double bytestotal = 0; -#endif /* WINDOWS */ - - if (ZEND_NUM_ARGS()!=1 || zend_get_parameters_ex(1, &path)==FAILURE) { - WRONG_PARAM_COUNT; - } - - convert_to_string_ex(path); - - if (php_check_open_basedir(Z_STRVAL_PP(path) TSRMLS_CC)) { - RETURN_FALSE; - } - -#ifdef WINDOWS /* GetDiskFreeSpaceEx is only available in NT and Win95 post-OSR2, so we have to jump through some hoops to see if the function exists. */ @@ -171,48 +149,63 @@ PHP_FUNCTION(disk_total_space) /* It's available, so we can call it. */ if (gdfse) { func = (gdfse_func)gdfse; - if (func(Z_STRVAL_PP(path), - &FreeBytesAvailableToCaller, - &TotalNumberOfBytes, - &TotalNumberOfFreeBytes) == 0) { + if (func(path, + &FreeBytesAvailableToCaller, + &TotalNumberOfBytes, + &TotalNumberOfFreeBytes) == 0) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", php_win_err()); - RETURN_FALSE; + return FAILURE; } /* i know - this is ugly, but i works <thies@thieso.net> */ bytestotal = TotalNumberOfBytes.HighPart * (double) (((unsigned long)1) << 31) * 2.0 + TotalNumberOfBytes.LowPart; - } - /* If it's not available, we just use GetDiskFreeSpace */ - else { - if (GetDiskFreeSpace(Z_STRVAL_PP(path), - &SectorsPerCluster, &BytesPerSector, - &NumberOfFreeClusters, &TotalNumberOfClusters) == 0) { + } else { /* If it's not available, we just use GetDiskFreeSpace */ + if (GetDiskFreeSpace(path, + &SectorsPerCluster, &BytesPerSector, + &NumberOfFreeClusters, &TotalNumberOfClusters) == 0) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", php_win_err()); - RETURN_FALSE; + return FAILURE; } bytestotal = (double)TotalNumberOfClusters * (double)SectorsPerCluster * (double)BytesPerSector; } - } - else { + } else { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to load kernel32.dll"); - RETURN_FALSE; + return FAILURE; } + + *space = bytestotal; + return SUCCESS; +} +/* }}} */ +#elif defined(OS2) /* {{{ */ +{ + double bytestotal = 0; + FSALLOCATE fsinfo; + char drive = path[0] & 95; -#elif defined(OS2) - { - FSALLOCATE fsinfo; - char drive = Z_STRVAL_PP(path)[0] & 95; - - if (DosQueryFSInfo( drive ? drive - 64 : 0, FSIL_ALLOC, &fsinfo, sizeof( fsinfo ) ) == 0) - bytestotal = (double)fsinfo.cbSector * fsinfo.cSectorUnit * fsinfo.cUnit; + if (DosQueryFSInfo( drive ? drive - 64 : 0, FSIL_ALLOC, &fsinfo, sizeof( fsinfo ) ) == 0) { + bytestotal = (double)fsinfo.cbSector * fsinfo.cSectorUnit * fsinfo.cUnit; + *space = bytestotal; + return SUCCESS; } -#else /* WINDOWS, OS/2 */ + return FAILURE; +} +/* }}} */ +#else /* {{{ if !defined(OS2) && !defined(WINDOWS) */ +{ + double bytestotal = 0; +#if defined(HAVE_SYS_STATVFS_H) && defined(HAVE_STATVFS) + struct statvfs buf; +#elif (defined(HAVE_SYS_STATFS_H) || defined(HAVE_SYS_MOUNT_H)) && defined(HAVE_STATFS) + struct statfs buf; +#endif + #if defined(HAVE_SYS_STATVFS_H) && defined(HAVE_STATVFS) - if (statvfs(Z_STRVAL_PP(path), &buf)) { + if (statvfs(path, &buf)) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", strerror(errno)); - RETURN_FALSE; + return FAILURE; } if (buf.f_frsize) { bytestotal = (((double)buf.f_blocks) * ((double)buf.f_frsize)); @@ -221,25 +214,47 @@ PHP_FUNCTION(disk_total_space) } #elif (defined(HAVE_SYS_STATFS_H) || defined(HAVE_SYS_MOUNT_H)) && defined(HAVE_STATFS) - if (statfs(Z_STRVAL_PP(path), &buf)) { + if (statfs(path, &buf)) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", strerror(errno)); - RETURN_FALSE; + return FAILURE; } bytestotal = (((double)buf.f_bsize) * ((double)buf.f_blocks)); #endif -#endif /* WINDOWS */ - RETURN_DOUBLE(bytestotal); + *space = bytestotal; + return SUCCESS; } +#endif +/* }}} */ /* }}} */ -/* {{{ proto float disk_free_space(string path) - Get free disk space for filesystem that path is on */ -PHP_FUNCTION(disk_free_space) +/* {{{ proto float disk_total_space(string path) + Get total disk space for filesystem that path is on */ +PHP_FUNCTION(disk_total_space) { - zval **path; -#ifdef WINDOWS - double bytesfree; + double bytestotal; + char *path; + int path_len; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &path, &path_len) == FAILURE) { + return; + } + + if (php_check_open_basedir(path TSRMLS_CC)) { + RETURN_FALSE; + } + + if (php_disk_total_space(path, &bytestotal TSRMLS_CC) == SUCCESS) { + RETURN_DOUBLE(bytestotal); + } + RETURN_FALSE; +} +/* }}} */ + +static int php_disk_free_space(char *path, double *space TSRMLS_DC) /* {{{ */ +#if defined(WINDOWS) /* {{{ */ +{ + double bytesfree = 0; HINSTANCE kernel32; FARPROC gdfse; @@ -257,26 +272,6 @@ PHP_FUNCTION(disk_free_space) DWORD NumberOfFreeClusters; DWORD TotalNumberOfClusters; -#else /* not - WINDOWS */ -#if defined(HAVE_SYS_STATVFS_H) && defined(HAVE_STATVFS) - struct statvfs buf; -#elif (defined(HAVE_SYS_STATFS_H) || defined(HAVE_SYS_MOUNT_H)) && defined(HAVE_STATFS) - struct statfs buf; -#endif - double bytesfree = 0; -#endif /* WINDOWS */ - - if (ZEND_NUM_ARGS()!=1 || zend_get_parameters_ex(1, &path)==FAILURE) { - WRONG_PARAM_COUNT; - } - - convert_to_string_ex(path); - - if (php_check_open_basedir(Z_STRVAL_PP(path) TSRMLS_CC)) { - RETURN_FALSE; - } - -#ifdef WINDOWS /* GetDiskFreeSpaceEx is only available in NT and Win95 post-OSR2, so we have to jump through some hoops to see if the function exists. */ @@ -286,48 +281,63 @@ PHP_FUNCTION(disk_free_space) /* It's available, so we can call it. */ if (gdfse) { func = (gdfse_func)gdfse; - if (func(Z_STRVAL_PP(path), + if (func(path, &FreeBytesAvailableToCaller, &TotalNumberOfBytes, &TotalNumberOfFreeBytes) == 0) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", php_win_err()); - RETURN_FALSE; + return FAILURE; } /* i know - this is ugly, but i works <thies@thieso.net> */ bytesfree = FreeBytesAvailableToCaller.HighPart * (double) (((unsigned long)1) << 31) * 2.0 + FreeBytesAvailableToCaller.LowPart; - } - /* If it's not available, we just use GetDiskFreeSpace */ - else { - if (GetDiskFreeSpace(Z_STRVAL_PP(path), + } else { /* If it's not available, we just use GetDiskFreeSpace */ + if (GetDiskFreeSpace(path, &SectorsPerCluster, &BytesPerSector, &NumberOfFreeClusters, &TotalNumberOfClusters) == 0) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", php_win_err()); - RETURN_FALSE; + return FAILURE; } bytesfree = (double)NumberOfFreeClusters * (double)SectorsPerCluster * (double)BytesPerSector; } - } - else { + } else { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to load kernel32.dll"); - RETURN_FALSE; + return FAILURE; } -#elif defined(OS2) - { - FSALLOCATE fsinfo; - char drive = Z_STRVAL_PP(path)[0] & 95; + *space = bytesfree; + return SUCCESS; +} +/* }}} */ +#elif defined(OS2) /* {{{ */ +{ + double bytesfree = 0; + FSALLOCATE fsinfo; + char drive = path[0] & 95; + + if (DosQueryFSInfo( drive ? drive - 64 : 0, FSIL_ALLOC, &fsinfo, sizeof( fsinfo ) ) == 0) { + bytesfree = (double)fsinfo.cbSector * fsinfo.cSectorUnit * fsinfo.cUnitAvail; + *space = bytesfree; + return SUCCESS; + } + return FAILURE; +} +/* }}} */ +#else /* {{{ if !defined(OS2) && !defined(WINDOWS) */ +{ + double bytesfree = 0; +#if defined(HAVE_SYS_STATVFS_H) && defined(HAVE_STATVFS) + struct statvfs buf; +#elif (defined(HAVE_SYS_STATFS_H) || defined(HAVE_SYS_MOUNT_H)) && defined(HAVE_STATFS) + struct statfs buf; +#endif - if (DosQueryFSInfo( drive ? drive - 64 : 0, FSIL_ALLOC, &fsinfo, sizeof( fsinfo ) ) == 0) - bytesfree = (double)fsinfo.cbSector * fsinfo.cSectorUnit * fsinfo.cUnitAvail; - } -#else /* WINDOWS, OS/2 */ #if defined(HAVE_SYS_STATVFS_H) && defined(HAVE_STATVFS) - if (statvfs(Z_STRVAL_PP(path), &buf)) { + if (statvfs(path, &buf)) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", strerror(errno)); - RETURN_FALSE; + return FAILURE; } if (buf.f_frsize) { bytesfree = (((double)buf.f_bavail) * ((double)buf.f_frsize)); @@ -335,9 +345,9 @@ PHP_FUNCTION(disk_free_space) bytesfree = (((double)buf.f_bavail) * ((double)buf.f_bsize)); } #elif (defined(HAVE_SYS_STATFS_H) || defined(HAVE_SYS_MOUNT_H)) && defined(HAVE_STATFS) - if (statfs(Z_STRVAL_PP(path), &buf)) { + if (statfs(path, &buf)) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", strerror(errno)); - RETURN_FALSE; + return FAILURE; } #ifdef NETWARE bytesfree = (((double)buf.f_bsize) * ((double)buf.f_bfree)); @@ -345,18 +355,42 @@ PHP_FUNCTION(disk_free_space) bytesfree = (((double)buf.f_bsize) * ((double)buf.f_bavail)); #endif #endif -#endif /* WINDOWS */ + + *space = bytesfree; + return SUCCESS; +} +#endif +/* }}} */ +/* }}} */ + +/* {{{ proto float disk_free_space(string path) + Get free disk space for filesystem that path is on */ +PHP_FUNCTION(disk_free_space) +{ + double bytesfree; + char *path; + int path_len; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &path, &path_len) == FAILURE) { + return; + } + + if (php_check_open_basedir(path TSRMLS_CC)) { + RETURN_FALSE; + } - RETURN_DOUBLE(bytesfree); + if (php_disk_free_space(path, &bytesfree TSRMLS_CC) == SUCCESS) { + RETURN_DOUBLE(bytesfree); + } + RETURN_FALSE; } /* }}} */ #if !defined(WINDOWS) -static void php_do_chgrp(INTERNAL_FUNCTION_PARAMETERS, int do_lchgrp) +static void php_do_chgrp(INTERNAL_FUNCTION_PARAMETERS, int do_lchgrp) /* {{{ */ { zval **filename, **group; gid_t gid; - struct group *gr=NULL; int ret; if (ZEND_NUM_ARGS()!=2 || zend_get_parameters_ex(2, &filename, &group)==FAILURE) { @@ -364,13 +398,33 @@ static void php_do_chgrp(INTERNAL_FUNCTION_PARAMETERS, int do_lchgrp) } convert_to_string_ex(filename); if (Z_TYPE_PP(group) == IS_STRING) { - gr = getgrnam(Z_STRVAL_PP(group)); +#if defined(ZTS) && defined(HAVE_GETGRNAM_R) && defined(_SC_GETGR_R_SIZE_MAX) + struct group gr; + struct group *retgrptr; + long grbuflen = sysconf(_SC_GETGR_R_SIZE_MAX); + char *grbuf; + + if (grbuflen < 1) { + RETURN_FALSE; + } + + grbuf = emalloc(grbuflen); + if (getgrnam_r(Z_STRVAL_PP(group), &gr, grbuf, grbuflen, &retgrptr) != 0 || retgrptr == NULL) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find gid for %s", Z_STRVAL_PP(group)); + efree(grbuf); + RETURN_FALSE; + } + efree(grbuf); + gid = gr.gr_gid; +#else + struct group *gr = getgrnam(Z_STRVAL_PP(group)); + if (!gr) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find gid for %s", - Z_STRVAL_PP(group)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find gid for %s", Z_STRVAL_PP(group)); RETURN_FALSE; } gid = gr->gr_gid; +#endif } else { convert_to_long_ex(group); gid = Z_LVAL_PP(group); @@ -398,6 +452,7 @@ static void php_do_chgrp(INTERNAL_FUNCTION_PARAMETERS, int do_lchgrp) } RETURN_TRUE; } +/* }}} */ #endif #ifndef NETWARE @@ -428,25 +483,45 @@ PHP_FUNCTION(lchgrp) /* }}} */ #endif -static void php_do_chown(INTERNAL_FUNCTION_PARAMETERS, int do_lchown) +#if !defined(WINDOWS) +static void php_do_chown(INTERNAL_FUNCTION_PARAMETERS, int do_lchown) /* {{{ */ { zval **filename, **user; int ret; uid_t uid; - struct passwd *pw = NULL; if (ZEND_NUM_ARGS()!=2 || zend_get_parameters_ex(2, &filename, &user)==FAILURE) { WRONG_PARAM_COUNT; } convert_to_string_ex(filename); if (Z_TYPE_PP(user) == IS_STRING) { - pw = getpwnam(Z_STRVAL_PP(user)); +#if defined(ZTS) && defined(_SC_GETPW_R_SIZE_MAX) && defined(HAVE_GETPWNAM_R) + struct passwd pw; + struct passwd *retpwptr = NULL; + long pwbuflen = sysconf(_SC_GETPW_R_SIZE_MAX); + char *pwbuf; + + if (pwbuflen < 1) { + RETURN_FALSE; + } + + pwbuf = emalloc(pwbuflen); + if (getpwnam_r(Z_STRVAL_PP(user), &pw, pwbuf, pwbuflen, &retpwptr) != 0 || retpwptr == NULL) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find uid for %s", Z_STRVAL_PP(user)); + efree(pwbuf); + RETURN_FALSE; + } + efree(pwbuf); + uid = pw.pw_uid; +#else + struct passwd *pw = getpwnam(Z_STRVAL_PP(user)); + if (!pw) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find uid for %s", - Z_STRVAL_PP(user)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find uid for %s", Z_STRVAL_PP(user)); RETURN_FALSE; } uid = pw->pw_uid; +#endif } else { convert_to_long_ex(user); uid = Z_LVAL_PP(user); @@ -473,6 +548,8 @@ static void php_do_chown(INTERNAL_FUNCTION_PARAMETERS, int do_lchown) RETURN_FALSE; } } +/* }}} */ +#endif #ifndef NETWARE /* {{{ proto bool chown (string filename, mixed user) @@ -633,6 +710,7 @@ PHP_FUNCTION(clearstatcache) efree(BG(CurrentLStatFile)); BG(CurrentLStatFile) = NULL; } + realpath_cache_clean(TSRMLS_C); } /* }}} */ @@ -654,14 +732,27 @@ PHPAPI void php_stat(const char *filename, php_stat_len filename_length, int typ "size", "atime", "mtime", "ctime", "blksize", "blocks"}; char *local; php_stream_wrapper *wrapper; + char safe_mode_buf[MAXPATHLEN]; if (!filename_length) { RETURN_FALSE; } if ((wrapper = php_stream_locate_url_wrapper(filename, &local, 0 TSRMLS_CC)) == &php_plain_files_wrapper) { - if (php_check_open_basedir(local TSRMLS_CC) || (PG(safe_mode) && !php_checkuid_ex(filename, NULL, CHECKUID_ALLOW_FILE_NOT_EXISTS, CHECKUID_NO_ERRORS))) { + if (php_check_open_basedir(local TSRMLS_CC)) { RETURN_FALSE; + } else if (PG(safe_mode)) { + if (type == FS_IS_X) { + if (strstr(local, "..")) { + RETURN_FALSE; + } else { + char *b = strrchr(local, PHP_DIR_SEPARATOR); + snprintf(safe_mode_buf, MAXPATHLEN, "%s%s%s", PG(safe_mode_exec_dir), (b ? "" : "/"), (b ? b : local)); + local = (char *)&safe_mode_buf; + } + } else if (!php_checkuid_ex(local, NULL, CHECKUID_ALLOW_FILE_NOT_EXISTS, CHECKUID_NO_ERRORS)) { + RETURN_FALSE; + } } } diff --git a/ext/standard/filters.c b/ext/standard/filters.c index 2c87e88ec..c287bd551 100644 --- a/ext/standard/filters.c +++ b/ext/standard/filters.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -20,7 +20,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: filters.c,v 1.44.2.6.2.3 2006/09/04 19:14:59 nlopess Exp $ */ +/* $Id: filters.c,v 1.44.2.6.2.4 2007/01/01 09:36:08 sebastian Exp $ */ #include "php.h" #include "php_globals.h" diff --git a/ext/standard/flock_compat.c b/ext/standard/flock_compat.c index c709c9b36..c153c3457 100644 --- a/ext/standard/flock_compat.c +++ b/ext/standard/flock_compat.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: flock_compat.c,v 1.29.2.1 2006/01/01 12:50:14 sniper Exp $ */ +/* $Id: flock_compat.c,v 1.29.2.1.2.1 2007/01/01 09:36:08 sebastian Exp $ */ #include "php.h" #include <errno.h> diff --git a/ext/standard/flock_compat.h b/ext/standard/flock_compat.h index 011264ad3..51ae7ac4e 100644 --- a/ext/standard/flock_compat.h +++ b/ext/standard/flock_compat.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: flock_compat.h,v 1.20.2.1 2006/01/01 12:50:14 sniper Exp $ */ +/* $Id: flock_compat.h,v 1.20.2.1.2.1 2007/01/01 09:36:08 sebastian Exp $ */ #ifndef FLOCK_COMPAT_H #define FLOCK_COMPAT_H diff --git a/ext/standard/formatted_print.c b/ext/standard/formatted_print.c index dce8c936b..98d50426a 100644 --- a/ext/standard/formatted_print.c +++ b/ext/standard/formatted_print.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: formatted_print.c,v 1.82.2.1.2.1 2006/06/26 18:48:56 bjori Exp $ */ +/* $Id: formatted_print.c,v 1.82.2.1.2.15 2007/04/09 21:19:38 tony2001 Exp $ */ #include <math.h> /* modf() */ #include "php.h" @@ -27,6 +27,9 @@ #ifdef HAVE_LOCALE_H #include <locale.h> +#define LCONV_DECIMAL_POINT (*lconv->decimal_point) +#else +#define LCONV_DECIMAL_POINT '.' #endif #define ALIGN_LEFT 0 @@ -50,111 +53,7 @@ static char hexchars[] = "0123456789abcdef"; static char HEXCHARS[] = "0123456789ABCDEF"; - -/* - * cvt.c - IEEE floating point formatting routines for FreeBSD - * from GNU libc-4.6.27 - */ - -/* - * php_convert_to_decimal converts to decimal - * the number of digits is specified by ndigit - * decpt is set to the position of the decimal point - * sign is set to 0 for positive, 1 for negative - */ -static char *php_convert_to_decimal(double arg, int ndigits, int *decpt, int *sign, int eflag) -{ - register int r2; - int mvl; - double fi, fj; - register char *p, *p1; - /*THREADX*/ -#ifndef THREAD_SAFE - static char cvt_buf[NDIG]; -#endif - - if (ndigits >= NDIG - 1) - ndigits = NDIG - 2; - r2 = 0; - *sign = 0; - p = &cvt_buf[0]; - if (arg < 0) { - *sign = 1; - arg = -arg; - } - arg = modf(arg, &fi); - p1 = &cvt_buf[NDIG]; - /* - * Do integer part - */ - if (fi != 0) { - p1 = &cvt_buf[NDIG]; - while (fi != 0) { - fj = modf(fi / 10, &fi); - if (p1 <= &cvt_buf[0]) { - mvl = NDIG - ndigits; - memmove(&cvt_buf[mvl], &cvt_buf[0], NDIG-mvl-1); - p1 += mvl; - } - *--p1 = (int) ((fj + .03) * 10) + '0'; - r2++; - } - while (p1 < &cvt_buf[NDIG]) - *p++ = *p1++; - } else if (arg > 0) { - while ((fj = arg * 10) < 1) { - if (!eflag && (r2 * -1) < ndigits) { - break; - } - arg = fj; - r2--; - } - } - p1 = &cvt_buf[ndigits]; - if (eflag == 0) - p1 += r2; - *decpt = r2; - if (p1 < &cvt_buf[0]) { - cvt_buf[0] = '\0'; - return (cvt_buf); - } - if (p <= p1 && p < &cvt_buf[NDIG]) { - arg = modf(arg * 10, &fj); - if ((int)fj==10) { - *p++ = '1'; - fj = 0; - *decpt = ++r2; - } - while (p <= p1 && p < &cvt_buf[NDIG]) { - *p++ = (int) fj + '0'; - arg = modf(arg * 10, &fj); - } - } - if (p1 >= &cvt_buf[NDIG]) { - cvt_buf[NDIG - 1] = '\0'; - return (cvt_buf); - } - p = p1; - *p1 += 5; - while (*p1 > '9') { - *p1 = '0'; - if (p1 > cvt_buf) - ++ * --p1; - else { - *p1 = '1'; - (*decpt)++; - if (eflag == 0) { - if (p > cvt_buf) - *p = '0'; - p++; - } - } - } - *p = '\0'; - return (cvt_buf); -} - - +/* php_spintf_appendchar() {{{ */ inline static void php_sprintf_appendchar(char **buffer, int *pos, int *size, char add TSRMLS_DC) { @@ -166,8 +65,9 @@ php_sprintf_appendchar(char **buffer, int *pos, int *size, char add TSRMLS_DC) PRINTF_DEBUG(("sprintf: appending '%c', pos=\n", add, *pos)); (*buffer)[(*pos)++] = add; } +/* }}} */ - +/* php_spintf_appendstring() {{{ */ inline static void php_sprintf_appendstring(char **buffer, int *pos, int *size, char *add, int min_width, int max_width, char padding, @@ -216,8 +116,9 @@ php_sprintf_appendstring(char **buffer, int *pos, int *size, char *add, } } } +/* }}} */ - +/* php_spintf_appendint() {{{ */ inline static void php_sprintf_appendint(char **buffer, int *pos, int *size, long number, int width, char padding, int alignment, @@ -259,7 +160,9 @@ php_sprintf_appendint(char **buffer, int *pos, int *size, long number, padding, alignment, (NUM_BUF_SIZE - 1) - i, neg, 0, always_sign); } +/* }}} */ +/* php_spintf_appenduint() {{{ */ inline static void php_sprintf_appenduint(char **buffer, int *pos, int *size, unsigned long number, @@ -289,7 +192,9 @@ php_sprintf_appenduint(char **buffer, int *pos, int *size, php_sprintf_appendstring(buffer, pos, size, &numbuf[i], width, 0, padding, alignment, (NUM_BUF_SIZE - 1) - i, 0, 0, 0); } +/* }}} */ +/* php_spintf_appenddouble() {{{ */ inline static void php_sprintf_appenddouble(char **buffer, int *pos, int *size, double number, @@ -299,18 +204,11 @@ php_sprintf_appenddouble(char **buffer, int *pos, int always_sign TSRMLS_DC) { - char numbuf[NUM_BUF_SIZE]; - char *cvt; - register int i = 0, j = 0; - int sign, decpt, cvt_len; - char decimal_point = '.'; + char num_buf[NUM_BUF_SIZE]; + char *s = NULL; + int s_len = 0, is_negative = 0; #ifdef HAVE_LOCALE_H - struct lconv lc; - char locale_decimal_point; - localeconv_r(&lc); - locale_decimal_point = (lc.decimal_point)[0]; -#else - char locale_decimal_point = '.'; + struct lconv *lconv; #endif PRINTF_DEBUG(("sprintf: appenddouble(%x, %x, %x, %f, %d, '%c', %d, %c)\n", @@ -322,95 +220,71 @@ php_sprintf_appenddouble(char **buffer, int *pos, } if (zend_isnan(number)) { - sign = (number<0); + is_negative = (number<0); php_sprintf_appendstring(buffer, pos, size, "NaN", 3, 0, padding, - alignment, precision, sign, 0, always_sign); + alignment, precision, is_negative, 0, always_sign); return; } if (zend_isinf(number)) { - sign = (number<0); + is_negative = (number<0); php_sprintf_appendstring(buffer, pos, size, "INF", 3, 0, padding, - alignment, precision, sign, 0, always_sign); + alignment, precision, is_negative, 0, always_sign); return; } - cvt = php_convert_to_decimal(number, precision, &decpt, &sign, (fmt == 'e')); - cvt_len = strlen(cvt); - - if (sign) { - numbuf[i++] = '-'; - } else if (always_sign) { - numbuf[i++] = '+'; - } - - if (fmt == 'f' || fmt == 'F') { - if (decpt <= 0) { - numbuf[i++] = '0'; - if (precision > 0) { - int k = precision; - numbuf[i++] = fmt == 'F' ? decimal_point : locale_decimal_point; - while ((decpt++ < 0) && k--) { - numbuf[i++] = '0'; - } - } - } else { - while (decpt-- > 0) { - numbuf[i++] = j < cvt_len ? cvt[j++] : '0'; - } - if (precision > 0) { - numbuf[i++] = fmt == 'F' ? decimal_point : locale_decimal_point; - while (precision-- > 0) { - numbuf[i++] = j < cvt_len ? cvt[j++] : '0'; - } - } - } - } else if (fmt == 'e' || fmt == 'E') { - char *exp_p; - int dec2; - - decpt--; - - numbuf[i++] = cvt[j++]; - numbuf[i++] = decimal_point; - - if (precision > 0) { - int k = precision; - - while (k-- && cvt[j]) { - numbuf[i++] = cvt[j++]; + switch (fmt) { + case 'e': + case 'E': + case 'f': + case 'F': +#ifdef HAVE_LOCALE_H + lconv = localeconv(); +#endif + s = php_conv_fp((fmt == 'f')?'F':fmt, number, 0, precision, + (fmt == 'f')?LCONV_DECIMAL_POINT:'.', + &is_negative, &num_buf[1], &s_len); + if (is_negative) { + num_buf[0] = '-'; + s = num_buf; + s_len++; + } else if (always_sign) { + num_buf[0] = '+'; + s = num_buf; + s_len++; } - } else { - numbuf[i++] = '0'; - } - - numbuf[i++] = fmt; - exp_p = php_convert_to_decimal(decpt, 0, &dec2, &sign, 0); - numbuf[i++] = sign ? '-' : '+'; - if (*exp_p) { - while (*exp_p) { - numbuf[i++] = *(exp_p++); + break; + + case 'g': + case 'G': + if (precision == 0) + precision = 1; + /* + * * We use &num_buf[ 1 ], so that we have room for the sign + */ +#ifdef HAVE_LOCALE_H + lconv = localeconv(); +#endif + s = php_gcvt(number, precision, LCONV_DECIMAL_POINT, (fmt == 'G')?'E':'e', &num_buf[1]); + is_negative = 0; + if (*s == '-') { + is_negative = 1; + s = &num_buf[1]; + } else if (always_sign) { + num_buf[0] = '+'; + s = num_buf; } - } else { - numbuf[i++] = '0'; - } - } else { - numbuf[i++] = cvt[j++]; - if (precision > 0) - numbuf[i++] = decimal_point; - } - while (cvt[j]) { - numbuf[i++] = cvt[j++]; + s_len = strlen(s); + break; } - numbuf[i] = '\0'; - - php_sprintf_appendstring(buffer, pos, size, numbuf, width, 0, padding, - alignment, i, sign, 0, always_sign); + php_sprintf_appendstring(buffer, pos, size, s, width, 0, padding, + alignment, s_len, is_negative, 0, always_sign); } +/* }}} */ - +/* php_spintf_appendd2n() {{{ */ inline static void php_sprintf_append2n(char **buffer, int *pos, int *size, long number, int width, char padding, int alignment, int n, @@ -439,9 +313,10 @@ php_sprintf_append2n(char **buffer, int *pos, int *size, long number, padding, alignment, (NUM_BUF_SIZE - 1) - i, 0, expprec, 0); } +/* }}} */ - -inline static long +/* php_spintf_getnumber() {{{ */ +inline static int php_sprintf_getnumber(char *buffer, int *pos) { char *endptr; @@ -453,10 +328,16 @@ php_sprintf_getnumber(char *buffer, int *pos) } PRINTF_DEBUG(("sprintf_getnumber: number was %d bytes long\n", i)); *pos += i; - return num; + + if (num >= INT_MAX || num < 0) { + return -1; + } else { + return (int) num; + } } +/* }}} */ -/* {{{ php_formatted_print +/* php_formatted_print() {{{ * New sprintf implementation for PHP. * * Modifiers: @@ -485,7 +366,7 @@ php_formatted_print(int ht, int *len, int use_array, int format_offset TSRMLS_DC { zval ***args, **z_format; int argc, size = 240, inpos = 0, outpos = 0, temppos; - int alignment, width, precision, currarg, adjusting, argnum; + int alignment, currarg, adjusting, argnum, width, precision; char *format, *result, padding; int always_sign; @@ -561,10 +442,10 @@ php_formatted_print(int ht, int *len, int use_array, int format_offset TSRMLS_DC if (format[temppos] == '$') { argnum = php_sprintf_getnumber(format, &inpos); - if (argnum == 0) { + if (argnum <= 0) { efree(result); efree(args); - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Zero is not a valid argument number"); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Argument number must be greater than zero."); return NULL; } @@ -603,7 +484,12 @@ php_formatted_print(int ht, int *len, int use_array, int format_offset TSRMLS_DC /* after modifiers comes width */ if (isdigit((int)format[inpos])) { PRINTF_DEBUG(("sprintf: getting width\n")); - width = php_sprintf_getnumber(format, &inpos); + if ((width = php_sprintf_getnumber(format, &inpos)) < 0) { + efree(result); + efree(args); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Width must be greater than zero and less than %d.", INT_MAX); + return NULL; + } adjusting |= ADJ_WIDTH; } else { width = 0; @@ -615,7 +501,12 @@ php_formatted_print(int ht, int *len, int use_array, int format_offset TSRMLS_DC inpos++; PRINTF_DEBUG(("sprintf: getting precision\n")); if (isdigit((int)format[inpos])) { - precision = php_sprintf_getnumber(format, &inpos); + if ((precision = php_sprintf_getnumber(format, &inpos)) < 0) { + efree(result); + efree(args); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Precision must be greater than zero and less than %d.", INT_MAX); + return NULL; + } adjusting |= ADJ_PRECISION; expprec = 1; } else { @@ -690,10 +581,12 @@ php_formatted_print(int ht, int *len, int use_array, int format_offset TSRMLS_DC width, padding, alignment); break; + case 'g': + case 'G': case 'e': + case 'E': case 'f': case 'F': - /* XXX not done */ convert_to_double(tmp); php_sprintf_appenddouble(&result, &outpos, &size, Z_DVAL_P(tmp), @@ -886,7 +779,6 @@ PHP_FUNCTION(vfprintf) } /* }}} */ - /* * Local variables: * tab-width: 4 diff --git a/ext/standard/fsock.c b/ext/standard/fsock.c index 25e102f28..5dedcc841 100644 --- a/ext/standard/fsock.c +++ b/ext/standard/fsock.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: fsock.c,v 1.121.2.1 2006/01/01 12:50:14 sniper Exp $ */ +/* $Id: fsock.c,v 1.121.2.1.2.1 2007/01/01 09:36:08 sebastian Exp $ */ #include "php.h" #include "php_globals.h" diff --git a/ext/standard/fsock.h b/ext/standard/fsock.h index 02404200a..6ae55d19a 100644 --- a/ext/standard/fsock.h +++ b/ext/standard/fsock.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: fsock.h,v 1.50.2.1 2006/01/01 12:50:14 sniper Exp $ */ +/* $Id: fsock.h,v 1.50.2.1.2.1 2007/01/01 09:36:08 sebastian Exp $ */ /* Synced with php 3.0 revision 1.24 1999-06-18 [ssb] */ diff --git a/ext/standard/ftok.c b/ext/standard/ftok.c index 839511ed3..a63708177 100644 --- a/ext/standard/ftok.c +++ b/ext/standard/ftok.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: ftok.c,v 1.16.2.1 2006/01/01 12:50:14 sniper Exp $ */ +/* $Id: ftok.c,v 1.16.2.1.2.1 2007/01/01 09:36:08 sebastian Exp $ */ #include "php.h" diff --git a/ext/standard/ftp_fopen_wrapper.c b/ext/standard/ftp_fopen_wrapper.c index b6237d008..46b24fd72 100644 --- a/ext/standard/ftp_fopen_wrapper.c +++ b/ext/standard/ftp_fopen_wrapper.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -18,7 +18,7 @@ | Sara Golemon <pollita@php.net> | +----------------------------------------------------------------------+ */ -/* $Id: ftp_fopen_wrapper.c,v 1.85.2.4 2006/03/20 14:10:35 tony2001 Exp $ */ +/* $Id: ftp_fopen_wrapper.c,v 1.85.2.4.2.1 2007/01/01 09:36:08 sebastian Exp $ */ #include "php.h" #include "php_globals.h" diff --git a/ext/standard/head.c b/ext/standard/head.c index c1b0c263c..868015f9e 100644 --- a/ext/standard/head.c +++ b/ext/standard/head.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -15,7 +15,7 @@ | Author: Rasmus Lerdorf <rasmus@lerdorf.on.ca> | +----------------------------------------------------------------------+ */ -/* $Id: head.c,v 1.84.2.1.2.2 2006/10/16 19:27:57 tony2001 Exp $ */ +/* $Id: head.c,v 1.84.2.1.2.7 2007/02/26 02:12:36 iliaa Exp $ */ #include <stdio.h> #include "php.h" @@ -94,6 +94,7 @@ PHPAPI int php_setcookie(char *name, int name_len, char *value, int value_len, t if (domain) { len += domain_len; } + cookie = emalloc(len + 100); if (value && value_len == 0) { @@ -104,14 +105,14 @@ PHPAPI int php_setcookie(char *name, int name_len, char *value, int value_len, t */ time_t t = time(NULL) - 31536001; dt = php_format_date("D, d-M-Y H:i:s T", sizeof("D, d-M-Y H:i:s T")-1, t, 0 TSRMLS_CC); - sprintf(cookie, "Set-Cookie: %s=deleted; expires=%s", name, dt); + snprintf(cookie, len + 100, "Set-Cookie: %s=deleted; expires=%s", name, dt); efree(dt); } else { - sprintf(cookie, "Set-Cookie: %s=%s", name, value ? encoded_value : ""); + snprintf(cookie, len + 100, "Set-Cookie: %s=%s", name, value ? encoded_value : ""); if (expires > 0) { - strcat(cookie, "; expires="); + strlcat(cookie, "; expires=", len + 100); dt = php_format_date("D, d-M-Y H:i:s T", sizeof("D, d-M-Y H:i:s T")-1, expires, 0 TSRMLS_CC); - strcat(cookie, dt); + strlcat(cookie, dt, len + 100); efree(dt); } } @@ -121,18 +122,18 @@ PHPAPI int php_setcookie(char *name, int name_len, char *value, int value_len, t } if (path && path_len > 0) { - strcat(cookie, "; path="); - strcat(cookie, path); + strlcat(cookie, "; path=", len + 100); + strlcat(cookie, path, len + 100); } if (domain && domain_len > 0) { - strcat(cookie, "; domain="); - strcat(cookie, domain); + strlcat(cookie, "; domain=", len + 100); + strlcat(cookie, domain, len + 100); } if (secure) { - strcat(cookie, "; secure"); + strlcat(cookie, "; secure", len + 100); } if (httponly) { - strcat(cookie, "; httponly"); + strlcat(cookie, "; httponly", len + 100); } ctr.line = cookie; diff --git a/ext/standard/head.h b/ext/standard/head.h index d009a8954..1afac8063 100644 --- a/ext/standard/head.h +++ b/ext/standard/head.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: head.h,v 1.28.2.1.2.1 2006/08/10 13:50:56 iliaa Exp $ */ +/* $Id: head.h,v 1.28.2.1.2.2 2007/01/01 09:36:08 sebastian Exp $ */ #ifndef HEAD_H #define HEAD_H diff --git a/ext/standard/html.c b/ext/standard/html.c index d70172c94..ef54f62ca 100644 --- a/ext/standard/html.c +++ b/ext/standard/html.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: html.c,v 1.111.2.2.2.3 2006/11/01 01:55:11 iliaa Exp $ */ +/* $Id: html.c,v 1.111.2.2.2.9 2007/02/27 03:28:16 iliaa Exp $ */ /* * HTML entity resources: @@ -912,12 +912,10 @@ PHPAPI char *php_unescape_html_entities(unsigned char *old, int oldlen, int *new if (entity_map[j].table[k - entity_map[j].basechar] == NULL) continue; - entity[0] = '&'; - entity_length = strlen(entity_map[j].table[k - entity_map[j].basechar]); - strncpy(&entity[1], entity_map[j].table[k - entity_map[j].basechar], sizeof(entity) - 2); - entity[entity_length+1] = ';'; - entity[entity_length+2] = '\0'; - entity_length += 2; + entity_length = slprintf(entity, sizeof(entity), "&%s;", entity_map[j].table[k - entity_map[j].basechar]); + if (entity_length >= sizeof(entity)) { + continue; + } /* When we have MBCS entities in the tables above, this will need to handle it */ replacement_len = 0; @@ -948,7 +946,8 @@ PHPAPI char *php_unescape_html_entities(unsigned char *old, int oldlen, int *new default: php_error_docref(NULL TSRMLS_CC, E_WARNING, "cannot yet handle MBCS!"); - return 0; + efree(ret); + return NULL; } if (php_memnstr(ret, entity, entity_length, ret+retlen)) { @@ -1137,7 +1136,7 @@ PHPAPI char *php_escape_html_entities(unsigned char *old, int oldlen, int *newle } replaced[len++] = '&'; - strcpy(replaced + len, rep); + strlcpy(replaced + len, rep, maxlen); len += l; replaced[len++] = ';'; } @@ -1308,7 +1307,10 @@ PHP_FUNCTION(html_entity_decode) } replaced = php_unescape_html_entities(str, str_len, &len, 1, quote_style, hint_charset TSRMLS_CC); - RETVAL_STRINGL(replaced, len, 0); + if (replaced) { + RETURN_STRINGL(replaced, len, 0); + } + RETURN_FALSE; } /* }}} */ @@ -1350,7 +1352,7 @@ PHP_FUNCTION(get_html_translation_table) continue; /* what about wide chars here ?? */ ind[0] = i + entity_map[j].basechar; - sprintf(buffer, "&%s;", entity_map[j].table[i]); + snprintf(buffer, sizeof(buffer), "&%s;", entity_map[j].table[i]); add_assoc_string(return_value, ind, buffer, 1); } diff --git a/ext/standard/html.h b/ext/standard/html.h index 724082ade..1c113eb7d 100644 --- a/ext/standard/html.h +++ b/ext/standard/html.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: html.h,v 1.20.2.1 2006/01/01 12:50:14 sniper Exp $ */ +/* $Id: html.h,v 1.20.2.1.2.2 2007/01/01 09:36:08 sebastian Exp $ */ #ifndef HTML_H #define HTML_H @@ -38,5 +38,6 @@ PHP_FUNCTION(html_entity_decode); PHP_FUNCTION(get_html_translation_table); PHPAPI char *php_escape_html_entities(unsigned char *old, int oldlen, int *newlen, int all, int quote_style, char *hint_charset TSRMLS_DC); +PHPAPI char *php_unescape_html_entities(unsigned char *old, int oldlen, int *newlen, int all, int quote_style, char *hint_charset TSRMLS_DC); #endif /* HTML_H */ diff --git a/ext/standard/http.c b/ext/standard/http.c index b57f43bf5..92e369855 100644 --- a/ext/standard/http.c +++ b/ext/standard/http.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: http.c,v 1.14.2.4.2.1 2006/07/24 18:03:45 helly Exp $ */ +/* $Id: http.c,v 1.14.2.4.2.3 2007/01/03 23:16:56 iliaa Exp $ */ #include "php_http.h" #include "php_ini.h" @@ -215,7 +215,7 @@ PHP_FUNCTION(http_build_query) } if (!formstr.c) { - RETURN_NULL(); + RETURN_EMPTY_STRING(); } smart_str_0(&formstr); diff --git a/ext/standard/http_fopen_wrapper.c b/ext/standard/http_fopen_wrapper.c index 14f5d0015..5fbce9ea1 100644 --- a/ext/standard/http_fopen_wrapper.c +++ b/ext/standard/http_fopen_wrapper.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -19,7 +19,7 @@ | Sara Golemon <pollita@php.net> | +----------------------------------------------------------------------+ */ -/* $Id: http_fopen_wrapper.c,v 1.99.2.12.2.1 2006/06/29 14:40:49 bjori Exp $ */ +/* $Id: http_fopen_wrapper.c,v 1.99.2.12.2.9 2007/04/23 16:37:28 bjori Exp $ */ #include "php.h" #include "php_globals.h" @@ -104,11 +104,12 @@ php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper, char *path, int transport_len, have_header = 0, request_fulluri = 0; char *protocol_version = NULL; int protocol_version_len = 3; /* Default: "1.0" */ + struct timeval timeout; tmp_line[0] = '\0'; if (redirect_max < 1) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Redirection limit reached, aborting."); + php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "Redirection limit reached, aborting"); return NULL; } @@ -137,6 +138,7 @@ php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper, char *path, if (strpbrk(mode, "awx+")) { php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "HTTP wrapper does not support writeable connections."); + php_url_free(resource); return NULL; } @@ -159,9 +161,23 @@ php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper, char *path, } } + if (context && php_stream_context_get_option(context, wrapper->wops->label, "timeout", &tmpzval) == SUCCESS) { + SEPARATE_ZVAL(tmpzval); + convert_to_double_ex(tmpzval); + timeout.tv_sec = (time_t) Z_DVAL_PP(tmpzval); + timeout.tv_usec = (size_t) ((Z_DVAL_PP(tmpzval) - timeout.tv_sec) * 1000000); + } else { + timeout.tv_sec = FG(default_socket_timeout); + timeout.tv_usec = 0; + } + stream = php_stream_xport_create(transport_string, transport_len, options, STREAM_XPORT_CLIENT | STREAM_XPORT_CONNECT, - NULL, NULL, context, &errstr, NULL); + NULL, &timeout, context, &errstr, NULL); + + if (stream) { + php_stream_set_option(stream, PHP_STREAM_OPTION_READ_TIMEOUT, 0, &timeout); + } if (errstr) { php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "%s", errstr); @@ -180,7 +196,7 @@ php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper, char *path, smart_str_append_unsigned(&header, resource->port); smart_str_appendl(&header, " HTTP/1.0\r\n\r\n", sizeof(" HTTP/1.0\r\n\r\n")-1); if (php_stream_write(stream, header.c, header.len) != header.len) { - php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "Cannot conect to HTTPS server through proxy"); + php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "Cannot connect to HTTPS server through proxy"); php_stream_close(stream); stream = NULL; } @@ -203,7 +219,7 @@ php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper, char *path, if (stream) { if (php_stream_xport_crypto_setup(stream, STREAM_CRYPTO_METHOD_SSLv23_CLIENT, NULL TSRMLS_CC) < 0 || php_stream_xport_crypto_enable(stream, 1 TSRMLS_CC) < 0) { - php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "Cannot conect to HTTPS server through proxy"); + php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "Cannot connect to HTTPS server through proxy"); php_stream_close(stream); stream = NULL; } @@ -232,8 +248,7 @@ php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper, char *path, redirect_max = Z_LVAL_PP(tmpzval); } - if (header_init && context && - php_stream_context_get_option(context, "http", "method", &tmpzval) == SUCCESS) { + if (context && php_stream_context_get_option(context, "http", "method", &tmpzval) == SUCCESS) { if (Z_TYPE_PP(tmpzval) == IS_STRING && Z_STRLEN_PP(tmpzval) > 0) { scratch_len = strlen(path) + 29 + Z_STRLEN_PP(tmpzval); scratch = emalloc(scratch_len); @@ -241,13 +256,11 @@ php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper, char *path, strcat(scratch, " "); } } - - if (context && - php_stream_context_get_option(context, "http", "protocol_version", &tmpzval) == SUCCESS) { + + if (context && php_stream_context_get_option(context, "http", "protocol_version", &tmpzval) == SUCCESS) { SEPARATE_ZVAL(tmpzval); convert_to_double_ex(tmpzval); - protocol_version_len = spprintf(&protocol_version, 0, "%.1f", Z_DVAL_PP(tmpzval)); - zval_ptr_dtor(tmpzval); + protocol_version_len = spprintf(&protocol_version, 0, "%.1F", Z_DVAL_PP(tmpzval)); } if (!scratch) { @@ -426,7 +439,7 @@ php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper, char *path, /* ensure the header is only sent if user_agent is not blank */ if (ua_len > sizeof(_UA_HEADER)) { ua = emalloc(ua_len + 1); - if ((ua_len = snprintf(ua, ua_len, _UA_HEADER, ua_str)) > 0) { + if ((ua_len = slprintf(ua, ua_len, _UA_HEADER, ua_str)) > 0) { ua[ua_len] = 0; php_stream_write(stream, ua, ua_len); } else { @@ -444,7 +457,7 @@ php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper, char *path, php_stream_context_get_option(context, "http", "content", &tmpzval) == SUCCESS && Z_TYPE_PP(tmpzval) == IS_STRING && Z_STRLEN_PP(tmpzval) > 0) { if (!(have_header & HTTP_HEADER_CONTENT_LENGTH)) { - scratch_len = snprintf(scratch, scratch_len, "Content-Length: %d\r\n", Z_STRLEN_PP(tmpzval)); + scratch_len = slprintf(scratch, scratch_len, "Content-Length: %d\r\n", Z_STRLEN_PP(tmpzval)); php_stream_write(stream, scratch, scratch_len); } if (!(have_header & HTTP_HEADER_TYPE)) { @@ -565,7 +578,11 @@ php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper, char *path, } } - if (!reqok || location[0] != '\0') { + if (!reqok || location[0] != '\0') { + if (options & STREAM_ONLY_GET_HEADERS && redirect_max <= 1) { + goto out; + } + if (location[0] != '\0') php_stream_notify_info(context, PHP_STREAM_NOTIFY_REDIRECTED, location, 0); diff --git a/ext/standard/image.c b/ext/standard/image.c index 6fca6a28f..2d4233540 100644 --- a/ext/standard/image.c +++ b/ext/standard/image.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: image.c,v 1.114.2.2.2.2 2006/06/25 21:08:28 bjori Exp $ */ +/* $Id: image.c,v 1.114.2.2.2.4 2007/02/24 02:17:27 helly Exp $ */ #include "php.h" #include <stdio.h> @@ -454,7 +454,7 @@ static int php_read_APP(php_stream * stream, unsigned int marker, zval *info TSR return 0; } - sprintf(markername, "APP%d", marker - M_APP0); + snprintf(markername, sizeof(markername), "APP%d", marker - M_APP0); if (zend_hash_find(Z_ARRVAL_P(info), markername, strlen(markername)+1, (void **) &tmp) == FAILURE) { /* XXX we onyl catch the 1st tag of it's kind! */ diff --git a/ext/standard/incomplete_class.c b/ext/standard/incomplete_class.c index 50511c01f..3f6d85bd1 100644 --- a/ext/standard/incomplete_class.c +++ b/ext/standard/incomplete_class.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -17,7 +17,7 @@ */ -/* $Id: incomplete_class.c,v 1.28.2.2 2006/01/28 06:14:34 fmk Exp $ */ +/* $Id: incomplete_class.c,v 1.28.2.2.2.2 2007/02/01 14:07:43 tony2001 Exp $ */ #include "php.h" #include "basic_functions.h" @@ -39,14 +39,20 @@ static zend_object_handlers php_incomplete_object_handlers; static void incomplete_class_message(zval *object, int error_type TSRMLS_DC) { char *class_name; + zend_bool class_name_alloced = 1; class_name = php_lookup_class_name(object, NULL); if (!class_name) { + class_name_alloced = 0; class_name = "unknown"; } php_error_docref(NULL TSRMLS_CC, error_type, INCOMPLETE_CLASS_MSG, class_name); + + if (class_name_alloced) { + efree(class_name); + } } /* }}} */ diff --git a/ext/standard/info.c b/ext/standard/info.c index eb3389713..12dca3de5 100644 --- a/ext/standard/info.c +++ b/ext/standard/info.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: info.c,v 1.249.2.10.2.6 2006/09/14 08:01:48 dmitry Exp $ */ +/* $Id: info.c,v 1.249.2.10.2.11 2007/04/02 12:41:07 sniper Exp $ */ #include "php.h" #include "php_ini.h" @@ -76,13 +76,9 @@ static int php_info_write_wrapper(const char *str, uint str_length) } -/* {{{ _display_module_info - */ -static int _display_module_info(zend_module_entry *module, void *arg TSRMLS_DC) +PHPAPI void php_info_print_module(zend_module_entry *module TSRMLS_DC) /* {{{ */ { - int show_info_func = *((int *) arg); - - if (show_info_func && module->info_func) { + if (module->info_func) { if (!sapi_module.phpinfo_as_text) { php_printf("<h2><a name=\"module_%s\">%s</a></h2>\n", module->name, module->name); } else { @@ -91,7 +87,7 @@ static int _display_module_info(zend_module_entry *module, void *arg TSRMLS_DC) php_info_print_table_end(); } module->info_func(module TSRMLS_CC); - } else if (!show_info_func && !module->info_func) { + } else { if (!sapi_module.phpinfo_as_text) { php_printf("<tr>"); php_printf("<td>"); @@ -102,7 +98,24 @@ static int _display_module_info(zend_module_entry *module, void *arg TSRMLS_DC) php_printf("\n"); } } - return 0; +} +/* }}} */ + +static int _display_module_info_func(zend_module_entry *module TSRMLS_DC) /* {{{ */ +{ + if (module->info_func) { + php_info_print_module(module TSRMLS_CC); + } + return ZEND_HASH_APPLY_KEEP; +} +/* }}} */ + +static int _display_module_info_def(zend_module_entry *module TSRMLS_DC) /* {{{ */ +{ + if (!module->info_func) { + php_info_print_module(module TSRMLS_CC); + } + return ZEND_HASH_APPLY_KEEP; } /* }}} */ @@ -380,6 +393,7 @@ PHPAPI void php_print_info_htmlhead(TSRMLS_D) PUTS("<head>\n"); php_info_print_style(TSRMLS_C); PUTS("<title>phpinfo()</title>"); + PUTS("<meta name=\"ROBOTS\" content=\"NOINDEX,NOFOLLOW,NOARCHIVE\" />"); /* php_printf("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=%s\" />\n", charset); */ @@ -460,7 +474,8 @@ PHPAPI void php_print_info(int flag TSRMLS_DC) php_info_print_table_row(2, "Virtual Directory Support", "disabled" ); #endif - php_info_print_table_row(2, "Configuration File (php.ini) Path", php_ini_opened_path?php_ini_opened_path:PHP_CONFIG_FILE_PATH); + php_info_print_table_row(2, "Configuration File (php.ini) Path", PHP_CONFIG_FILE_PATH); + php_info_print_table_row(2, "Loaded Configuration File", php_ini_opened_path ? php_ini_opened_path : "(none)"); if (strlen(PHP_CONFIG_FILE_SCAN_DIR)) { php_info_print_table_row(2, "Scan this dir for additional .ini files", PHP_CONFIG_FILE_SCAN_DIR); @@ -508,10 +523,10 @@ PHPAPI void php_print_info(int flag TSRMLS_DC) zend_hash_get_current_key_ex(url_stream_wrappers_hash, &stream_protocol, (uint *)&stream_protocol_len, &num_key, 0, NULL) == HASH_KEY_IS_STRING; zend_hash_move_forward(url_stream_wrappers_hash)) { stream_protocols_buf = erealloc(stream_protocols_buf, stream_protocols_buf_len + stream_protocol_len + 2 + 1); - memcpy(stream_protocols_buf + stream_protocols_buf_len, stream_protocol, stream_protocol_len); - stream_protocols_buf[stream_protocols_buf_len + stream_protocol_len] = ','; - stream_protocols_buf[stream_protocols_buf_len + stream_protocol_len + 1] = ' '; - stream_protocols_buf_len += stream_protocol_len + 2; + memcpy(stream_protocols_buf + stream_protocols_buf_len, stream_protocol, stream_protocol_len - 1); + stream_protocols_buf[stream_protocols_buf_len + stream_protocol_len - 1] = ','; + stream_protocols_buf[stream_protocols_buf_len + stream_protocol_len] = ' '; + stream_protocols_buf_len += stream_protocol_len + 1; } if (stream_protocols_buf) { stream_protocols_buf[stream_protocols_buf_len - 2] = ' '; @@ -538,8 +553,8 @@ PHPAPI void php_print_info(int flag TSRMLS_DC) for(zend_hash_internal_pointer_reset(stream_xport_hash); zend_hash_get_current_key_ex(stream_xport_hash, &xport_name, (uint *)&xport_name_len, &num_key, 0, NULL) == HASH_KEY_IS_STRING; zend_hash_move_forward(stream_xport_hash)) { - if (xport_buf_len + xport_name_len + 3 > xport_buf_size) { - while (xport_buf_len + xport_name_len + 3 > xport_buf_size) { + if (xport_buf_len + xport_name_len + 2 > xport_buf_size) { + while (xport_buf_len + xport_name_len + 2 > xport_buf_size) { xport_buf_size += 256; } if (xport_buf) { @@ -552,8 +567,8 @@ PHPAPI void php_print_info(int flag TSRMLS_DC) xport_buf[xport_buf_len++] = ','; xport_buf[xport_buf_len++] = ' '; } - memcpy(xport_buf + xport_buf_len, xport_name, xport_name_len); - xport_buf_len += xport_name_len; + memcpy(xport_buf + xport_buf_len, xport_name, xport_name_len - 1); + xport_buf_len += xport_name_len - 1; xport_buf[xport_buf_len] = '\0'; } if (xport_buf) { @@ -579,8 +594,8 @@ PHPAPI void php_print_info(int flag TSRMLS_DC) for(zend_hash_internal_pointer_reset(stream_filter_hash); zend_hash_get_current_key_ex(stream_filter_hash, &filter_name, (uint *)&filter_name_len, &num_key, 0, NULL) == HASH_KEY_IS_STRING; zend_hash_move_forward(stream_filter_hash)) { - if (filter_buf_len + filter_name_len + 3 > filter_buf_size) { - while (filter_buf_len + filter_name_len + 3 > filter_buf_size) { + if (filter_buf_len + filter_name_len + 2 > filter_buf_size) { + while (filter_buf_len + filter_name_len + 2 > filter_buf_size) { filter_buf_size += 256; } if (filter_buf) { @@ -593,8 +608,8 @@ PHPAPI void php_print_info(int flag TSRMLS_DC) filter_buf[filter_buf_len++] = ','; filter_buf[filter_buf_len++] = ' '; } - memcpy(filter_buf + filter_buf_len, filter_name, filter_name_len); - filter_buf_len += filter_name_len; + memcpy(filter_buf + filter_buf_len, filter_name, filter_name_len - 1); + filter_buf_len += filter_name_len - 1; filter_buf[filter_buf_len] = '\0'; } if (filter_buf) { @@ -661,22 +676,19 @@ PHPAPI void php_print_info(int flag TSRMLS_DC) } if (flag & PHP_INFO_MODULES) { - int show_info_func; HashTable sorted_registry; zend_module_entry tmp; - zend_hash_init(&sorted_registry, 50, NULL, NULL, 1); + zend_hash_init(&sorted_registry, zend_hash_num_elements(&module_registry), NULL, NULL, 1); zend_hash_copy(&sorted_registry, &module_registry, NULL, &tmp, sizeof(zend_module_entry)); zend_hash_sort(&sorted_registry, zend_qsort, module_name_cmp, 0 TSRMLS_CC); - show_info_func = 1; - zend_hash_apply_with_argument(&sorted_registry, (apply_func_arg_t) _display_module_info, &show_info_func TSRMLS_CC); + zend_hash_apply(&sorted_registry, (apply_func_t) _display_module_info_func TSRMLS_CC); SECTION("Additional Modules"); php_info_print_table_start(); php_info_print_table_header(1, "Module Name"); - show_info_func = 0; - zend_hash_apply_with_argument(&sorted_registry, (apply_func_arg_t) _display_module_info, &show_info_func TSRMLS_CC); + zend_hash_apply(&sorted_registry, (apply_func_t) _display_module_info_def TSRMLS_CC); php_info_print_table_end(); zend_hash_destroy(&sorted_registry); diff --git a/ext/standard/info.h b/ext/standard/info.h index 191623c72..cbfdef2be 100644 --- a/ext/standard/info.h +++ b/ext/standard/info.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: info.h,v 1.38.2.1.2.2 2006/09/29 21:40:16 iliaa Exp $ */ +/* $Id: info.h,v 1.38.2.1.2.4 2007/02/08 16:55:34 helly Exp $ */ #ifndef INFO_H #define INFO_H @@ -81,6 +81,7 @@ PHPAPI void php_info_print_table_end(void); PHPAPI void php_info_print_box_start(int bg); PHPAPI void php_info_print_box_end(void); PHPAPI void php_info_print_hr(void); +PHPAPI void php_info_print_module(zend_module_entry *module TSRMLS_DC); PHPAPI char *php_logo_guid(void); PHPAPI char *php_get_uname(char mode); diff --git a/ext/standard/iptc.c b/ext/standard/iptc.c index fdf33bb81..487e9095c 100644 --- a/ext/standard/iptc.c +++ b/ext/standard/iptc.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: iptc.c,v 1.50.2.2.2.1 2006/08/30 16:30:14 tony2001 Exp $ */ +/* $Id: iptc.c,v 1.50.2.2.2.4 2007/02/12 20:40:11 tony2001 Exp $ */ /* * Functions to parse & compse IPTC data. @@ -177,56 +177,37 @@ static char psheader[] = "\xFF\xED\0\0Photoshop 3.0\08BIM\x04\x04\0\0\0\0"; Embed binary IPTC data into a JPEG image. */ PHP_FUNCTION(iptcembed) { - zval **iptcdata, **jpeg_file, **spool_flag; - FILE *fp; - unsigned int marker; - unsigned int spool = 0, done = 0, inx, len; - unsigned char *spoolbuf=0, *poi=0; + char *iptcdata, *jpeg_file; + int iptcdata_len, jpeg_file_len; + long spool = 0; + FILE *fp; + unsigned int marker, done = 0, inx; + unsigned char *spoolbuf = NULL, *poi = NULL; struct stat sb; + zend_bool written = 0; - switch(ZEND_NUM_ARGS()){ - case 3: - if (zend_get_parameters_ex(3, &iptcdata, &jpeg_file, &spool_flag) == FAILURE) { - WRONG_PARAM_COUNT; - } - convert_to_string_ex(iptcdata); - convert_to_string_ex(jpeg_file); - convert_to_long_ex(spool_flag); - spool = Z_LVAL_PP(spool_flag); - break; - - case 2: - if (zend_get_parameters_ex(2, &iptcdata, &jpeg_file) == FAILURE) { - WRONG_PARAM_COUNT; - } - convert_to_string_ex(iptcdata); - convert_to_string_ex(jpeg_file); - break; - - default: - WRONG_PARAM_COUNT; - break; - } + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|l", &iptcdata, &iptcdata_len, &jpeg_file, &jpeg_file_len, &spool) != SUCCESS) { + return; + } - if (PG(safe_mode) && (!php_checkuid(Z_STRVAL_PP(jpeg_file), NULL, CHECKUID_CHECK_FILE_AND_DIR))) { + if (PG(safe_mode) && (!php_checkuid(jpeg_file, NULL, CHECKUID_CHECK_FILE_AND_DIR))) { RETURN_FALSE; } - if (php_check_open_basedir(Z_STRVAL_PP(jpeg_file) TSRMLS_CC)) { + if (php_check_open_basedir(jpeg_file TSRMLS_CC)) { RETURN_FALSE; } - if ((fp = VCWD_FOPEN(Z_STRVAL_PP(jpeg_file), "rb")) == 0) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to open %s", Z_STRVAL_PP(jpeg_file)); - RETURN_FALSE; - } - - len = Z_STRLEN_PP(iptcdata); + if ((fp = VCWD_FOPEN(jpeg_file, "rb")) == 0) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to open %s", jpeg_file); + RETURN_FALSE; + } if (spool < 2) { fstat(fileno(fp), &sb); - poi = spoolbuf = emalloc(len + sizeof(psheader) + sb.st_size + 1024); + poi = spoolbuf = safe_emalloc(1, iptcdata_len + sizeof(psheader) + sb.st_size + 1024, 1); + memset(poi, 0, iptcdata_len + sizeof(psheader) + sb.st_size + 1024 + 1); } if (php_iptc_get1(fp, spool, poi?&poi:0 TSRMLS_CC) != 0xFF) { @@ -264,21 +245,32 @@ PHP_FUNCTION(iptcembed) case M_APP0: /* APP0 is in each and every JPEG, so when we hit APP0 we insert our new APP13! */ + case M_APP1: + if (written) { + /* don't try to write the data twice */ + break; + } + written = 1; + php_iptc_skip_variable(fp, spool, poi?&poi:0 TSRMLS_CC); - if (len & 1) len++; /* make the length even */ + if (iptcdata_len & 1) { + iptcdata_len++; /* make the length even */ + } - psheader[ 2 ] = (len+28)>>8; - psheader[ 3 ] = (len+28)&0xff; + psheader[ 2 ] = (iptcdata_len+28)>>8; + psheader[ 3 ] = (iptcdata_len+28)&0xff; - for (inx = 0; inx < 28; inx++) + for (inx = 0; inx < 28; inx++) { php_iptc_put1(fp, spool, psheader[inx], poi?&poi:0 TSRMLS_CC); + } - php_iptc_put1(fp, spool, (unsigned char)(len>>8), poi?&poi:0 TSRMLS_CC); - php_iptc_put1(fp, spool, (unsigned char)(len&0xff), poi?&poi:0 TSRMLS_CC); - - for (inx = 0; inx < len; inx++) - php_iptc_put1(fp, spool, Z_STRVAL_PP(iptcdata)[inx], poi?&poi:0 TSRMLS_CC); + php_iptc_put1(fp, spool, (unsigned char)(iptcdata_len>>8), poi?&poi:0 TSRMLS_CC); + php_iptc_put1(fp, spool, (unsigned char)(iptcdata_len&0xff), poi?&poi:0 TSRMLS_CC); + + for (inx = 0; inx < iptcdata_len; inx++) { + php_iptc_put1(fp, spool, iptcdata[inx], poi?&poi:0 TSRMLS_CC); + } break; case M_SOS: @@ -286,7 +278,7 @@ PHP_FUNCTION(iptcembed) php_iptc_read_remaining(fp, spool, poi?&poi:0 TSRMLS_CC); done = 1; break; - + default: php_iptc_skip_variable(fp, spool, poi?&poi:0 TSRMLS_CC); break; @@ -307,24 +299,19 @@ PHP_FUNCTION(iptcembed) Parse binary IPTC-data into associative array */ PHP_FUNCTION(iptcparse) { - unsigned int length, inx, len, tagsfound; - unsigned char *buffer; - unsigned char recnum, dataset; - unsigned char key[ 16 ]; - zval *values, **str, **element; - - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &str) == FAILURE) { - WRONG_PARAM_COUNT; + unsigned int inx = 0, len, tagsfound = 0; + unsigned char *buffer, recnum, dataset, key[ 16 ]; + char *str; + int str_len; + zval *values, **element; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &str, &str_len) != SUCCESS) { + return; } - convert_to_string_ex(str); - - inx = 0; - length = Z_STRLEN_PP(str); - buffer = Z_STRVAL_PP(str); - tagsfound = 0; /* number of tags already found */ + buffer = (unsigned char *)str; - while (inx < length) { /* find 1st tag */ + while (inx < str_len) { /* find 1st tag */ if ((buffer[inx] == 0x1c) && ((buffer[inx+1] == 0x01) || (buffer[inx+1] == 0x02))){ break; } else { @@ -332,12 +319,12 @@ PHP_FUNCTION(iptcparse) } } - while (inx < length) { + while (inx < str_len) { if (buffer[ inx++ ] != 0x1c) { break; /* we ran against some data which does not conform to IPTC - stop parsing! */ } - if ((inx + 4) >= length) + if ((inx + 4) >= str_len) break; dataset = buffer[ inx++ ]; @@ -354,25 +341,23 @@ PHP_FUNCTION(iptcparse) snprintf(key, sizeof(key), "%d#%03d", (unsigned int) dataset, (unsigned int) recnum); - if ((len > length) || (inx + len) > length) + if ((len > str_len) || (inx + len) > str_len) { break; + } if (tagsfound == 0) { /* found the 1st tag - initialize the return array */ array_init(return_value); } if (zend_hash_find(Z_ARRVAL_P(return_value), key, strlen(key) + 1, (void **) &element) == FAILURE) { - ALLOC_ZVAL(values); - INIT_PZVAL(values); + MAKE_STD_ZVAL(values); array_init(values); - zend_hash_update(Z_ARRVAL_P(return_value), key, strlen(key)+1, (void *) &values, sizeof(zval*), (void **) &element); + zend_hash_update(Z_ARRVAL_P(return_value), key, strlen(key) + 1, (void *) &values, sizeof(zval*), (void **) &element); } add_next_index_stringl(*element, buffer+inx, len, 1); - inx += len; - tagsfound++; } diff --git a/ext/standard/lcg.c b/ext/standard/lcg.c index 717626dc6..d0d0121da 100644 --- a/ext/standard/lcg.c +++ b/ext/standard/lcg.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: lcg.c,v 1.41.2.1 2006/01/01 12:50:15 sniper Exp $ */ +/* $Id: lcg.c,v 1.41.2.1.2.1 2007/01/01 09:36:08 sebastian Exp $ */ #include "php.h" #include "php_lcg.h" diff --git a/ext/standard/levenshtein.c b/ext/standard/levenshtein.c index 8caa58e49..1ed2edf84 100644 --- a/ext/standard/levenshtein.c +++ b/ext/standard/levenshtein.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -15,7 +15,7 @@ | Author: Hartmut Holzgraefe <hholzgra@php.net> | +----------------------------------------------------------------------+ */ -/* $Id: levenshtein.c,v 1.34.2.1.2.1 2006/06/26 18:48:56 bjori Exp $ */ +/* $Id: levenshtein.c,v 1.34.2.1.2.3 2007/01/01 09:36:08 sebastian Exp $ */ #include "php.h" #include <stdlib.h> @@ -132,7 +132,7 @@ PHP_FUNCTION(levenshtein) WRONG_PARAM_COUNT; } - if(distance<0) { + if(distance < 0 && /* TODO */ ZEND_NUM_ARGS() != 3) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Argument string(s) too long"); } diff --git a/ext/standard/link.c b/ext/standard/link.c index 8bc554fb6..441d494bd 100644 --- a/ext/standard/link.c +++ b/ext/standard/link.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: link.c,v 1.52.2.1.2.1 2006/09/16 18:30:03 iliaa Exp $ */ +/* $Id: link.c,v 1.52.2.1.2.2 2007/01/01 09:36:08 sebastian Exp $ */ #include "php.h" #include "php_filestat.h" diff --git a/ext/standard/mail.c b/ext/standard/mail.c index 76ae6dfa8..f4d07a5de 100644 --- a/ext/standard/mail.c +++ b/ext/standard/mail.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: mail.c,v 1.87.2.1 2006/01/01 12:50:15 sniper Exp $ */ +/* $Id: mail.c,v 1.87.2.1.2.5 2007/03/30 00:28:58 iliaa Exp $ */ #include <stdlib.h> #include <ctype.h> @@ -48,13 +48,21 @@ #define SKIP_LONG_HEADER_SEP(str, pos) \ if (str[pos] == '\r' && str[pos + 1] == '\n' && (str[pos + 2] == ' ' || str[pos + 2] == '\t')) { \ - pos += 3; \ - while (str[pos] == ' ' || str[pos] == '\t') { \ + pos += 2; \ + while (str[pos + 1] == ' ' || str[pos + 1] == '\t') { \ pos++; \ } \ continue; \ } \ +#define MAIL_ASCIIZ_CHECK(str, len) \ + p = str; \ + e = p + len; \ + while ((p = memchr(p, '\0', (e - p)))) { \ + *p = ' '; \ + } \ + + /* {{{ proto int ezmlm_hash(string addr) Calculate EZMLM list hash value. */ PHP_FUNCTION(ezmlm_hash) @@ -88,6 +96,7 @@ PHP_FUNCTION(mail) int subject_len, extra_cmd_len, i; char *force_extra_parameters = INI_STR("mail.force_extra_parameters"); char *to_r, *subject_r; + char *p, *e; if (PG(safe_mode) && (ZEND_NUM_ARGS() == 5)) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "SAFE MODE Restriction in effect. The fifth parameter is disabled in SAFE MODE."); @@ -104,6 +113,17 @@ PHP_FUNCTION(mail) return; } + /* ASCIIZ check */ + MAIL_ASCIIZ_CHECK(to, to_len); + MAIL_ASCIIZ_CHECK(subject, subject_len); + MAIL_ASCIIZ_CHECK(message, message_len); + if (headers) { + MAIL_ASCIIZ_CHECK(headers, headers_len); + } + if (extra_cmd) { + MAIL_ASCIIZ_CHECK(extra_cmd, extra_cmd_len); + } + if (to_len > 0) { to_r = estrndup(to, to_len); for (; to_len; to_len--) { @@ -150,7 +170,7 @@ PHP_FUNCTION(mail) } else if (extra_cmd) { extra_cmd = php_escape_shell_cmd(extra_cmd); } - + if (php_mail(to_r, subject_r, message, headers, extra_cmd TSRMLS_CC)) { RETVAL_TRUE; } else { @@ -200,10 +220,7 @@ PHPAPI int php_mail(char *to, char *subject, char *message, char *headers, char #endif } if (extra_cmd != NULL) { - sendmail_cmd = emalloc (strlen (sendmail_path) + strlen (extra_cmd) + 2); - strcpy (sendmail_cmd, sendmail_path); - strcat (sendmail_cmd, " "); - strcat (sendmail_cmd, extra_cmd); + spprintf(&sendmail_cmd, 0, "%s %s", sendmail_path, extra_cmd); } else { sendmail_cmd = sendmail_path; } diff --git a/ext/standard/math.c b/ext/standard/math.c index 875f9fc1e..b93600edf 100644 --- a/ext/standard/math.c +++ b/ext/standard/math.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -19,7 +19,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: math.c,v 1.131.2.2.2.2 2006/08/27 19:14:43 bjori Exp $ */ +/* $Id: math.c,v 1.131.2.2.2.5 2007/01/01 09:36:08 sebastian Exp $ */ #include "php.h" #include "php_math.h" @@ -976,14 +976,18 @@ PHPAPI char *_php_math_number_format(double d, int dec, char dec_point, char tho dec = MAX(0, dec); PHP_ROUND_WITH_FUZZ(d, dec); - tmplen = spprintf(&tmpbuf, 0, "%.*f", dec, d); + tmplen = spprintf(&tmpbuf, 0, "%.*F", dec, d); if (tmpbuf == NULL || !isdigit((int)tmpbuf[0])) { return tmpbuf; } /* find decimal point, if expected */ - dp = dec ? strchr(tmpbuf, '.') : NULL; + if (dec) { + dp = strpbrk(tmpbuf, ".,"); + } else { + dp = NULL; + } /* calculate the length of the return buffer */ if (dp) { diff --git a/ext/standard/md5.c b/ext/standard/md5.c index 1b8347c17..2217b264f 100644 --- a/ext/standard/md5.c +++ b/ext/standard/md5.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: md5.c,v 1.39.2.1 2006/01/01 12:50:15 sniper Exp $ */ +/* $Id: md5.c,v 1.39.2.1.2.1 2007/01/01 09:36:08 sebastian Exp $ */ /* * md5.c - Copyright 1997 Lachlan Roche diff --git a/ext/standard/md5.h b/ext/standard/md5.h index aebe4d1fd..f9d273ad2 100644 --- a/ext/standard/md5.h +++ b/ext/standard/md5.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: md5.h,v 1.17.2.1 2006/01/01 12:50:15 sniper Exp $ */ +/* $Id: md5.h,v 1.17.2.1.2.1 2007/01/01 09:36:08 sebastian Exp $ */ #ifndef MD5_H #define MD5_H diff --git a/ext/standard/metaphone.c b/ext/standard/metaphone.c index 206b555ed..f780818a9 100644 --- a/ext/standard/metaphone.c +++ b/ext/standard/metaphone.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: metaphone.c,v 1.28.2.1.2.3 2006/09/27 08:32:24 tony2001 Exp $ */ +/* $Id: metaphone.c,v 1.28.2.1.2.4 2007/01/01 09:36:08 sebastian Exp $ */ /* Based on CPANs "Text-Metaphone-1.96" by Michael G Schwern <schwern@pobox.com> diff --git a/ext/standard/microtime.c b/ext/standard/microtime.c index 4eb23369f..552b1503b 100644 --- a/ext/standard/microtime.c +++ b/ext/standard/microtime.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: microtime.c,v 1.53.2.2 2006/01/01 12:50:15 sniper Exp $ */ +/* $Id: microtime.c,v 1.53.2.2.2.3 2007/01/01 09:36:08 sebastian Exp $ */ #include "php.h" @@ -84,7 +84,7 @@ static void _php_gettimeofday(INTERNAL_FUNCTION_PARAMETERS, int mode) } else { char ret[100]; - snprintf(ret, 100, "%.8f %ld", tp.tv_usec / MICRO_IN_SEC, tp.tv_sec); + snprintf(ret, 100, "%.8F %ld", tp.tv_usec / MICRO_IN_SEC, tp.tv_sec); RETURN_STRING(ret, 1); } } @@ -115,7 +115,11 @@ PHP_FUNCTION(getrusage) long pwho = 0; int who = RUSAGE_SELF; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &pwho) != FAILURE && pwho == 1) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &pwho) == FAILURE) { + return; + } + + if (pwho == 1) { who = RUSAGE_CHILDREN; } diff --git a/ext/standard/microtime.h b/ext/standard/microtime.h index 6784c819a..9cf5806e7 100644 --- a/ext/standard/microtime.h +++ b/ext/standard/microtime.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: microtime.h,v 1.14.2.1 2006/01/01 12:50:15 sniper Exp $ */ +/* $Id: microtime.h,v 1.14.2.1.2.1 2007/01/01 09:36:08 sebastian Exp $ */ #ifndef MICROTIME_H #define MICROTIME_H diff --git a/ext/standard/pack.c b/ext/standard/pack.c index e9757f647..f80cc3388 100644 --- a/ext/standard/pack.c +++ b/ext/standard/pack.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -15,7 +15,7 @@ | Author: Chris Schneider <cschneid@relog.ch> | +----------------------------------------------------------------------+ */ -/* $Id: pack.c,v 1.57.2.5 2006/02/26 10:49:50 helly Exp $ */ +/* $Id: pack.c,v 1.57.2.5.2.4 2007/04/03 19:50:40 shire Exp $ */ #include "php.h" @@ -644,10 +644,10 @@ PHP_FUNCTION(unpack) if (arg != 1 || namelen == 0) { /* Need to add element number to name */ - sprintf(n, "%.*s%d", namelen, name, i + 1); + snprintf(n, sizeof(n), "%.*s%d", namelen, name, i + 1); } else { /* Truncate name to next format code or end of string */ - sprintf(n, "%.*s", namelen, name); + snprintf(n, sizeof(n), "%.*s", namelen, name); } if (size != 0 && size != -1 && INT_MAX - size + 1 < inputpos) { @@ -753,14 +753,16 @@ PHP_FUNCTION(unpack) case 'i': case 'I': { - long v; + long v = 0; int issigned = 0; if (type == 'i') { issigned = input[inputpos + (machine_little_endian ? (sizeof(int) - 1) : 0)] & 0x80; + } else if (sizeof(long) > 4 && (input[inputpos + machine_endian_long_map[3]] & 0x80) == 0x80) { + v = ~INT_MAX; } - v = php_unpack(&input[inputpos], sizeof(int), issigned, int_map); + v |= php_unpack(&input[inputpos], sizeof(int), issigned, int_map); add_assoc_long(return_value, n, v); break; } @@ -771,17 +773,23 @@ PHP_FUNCTION(unpack) case 'V': { int issigned = 0; int *map = machine_endian_long_map; - long v; + long v = 0; - if (type == 'l') { + if (type == 'l' || type == 'L') { issigned = input[inputpos + (machine_little_endian ? 3 : 0)] & 0x80; } else if (type == 'N') { + issigned = input[inputpos] & 0x80; map = big_endian_long_map; } else if (type == 'V') { + issigned = input[inputpos + 3] & 0x80; map = little_endian_long_map; } - v = php_unpack(&input[inputpos], 4, issigned, map); + if (sizeof(long) > 4 && issigned) { + v = ~INT_MAX; + } + + v |= php_unpack(&input[inputpos], 4, issigned, map); add_assoc_long(return_value, n, v); break; } diff --git a/ext/standard/pack.h b/ext/standard/pack.h index 1cb2494c5..d28f0431e 100644 --- a/ext/standard/pack.h +++ b/ext/standard/pack.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: pack.h,v 1.16.2.1 2006/01/01 12:50:15 sniper Exp $ */ +/* $Id: pack.h,v 1.16.2.1.2.1 2007/01/01 09:36:08 sebastian Exp $ */ #ifndef PACK_H #define PACK_H diff --git a/ext/standard/pageinfo.c b/ext/standard/pageinfo.c index ae112a0d3..ea23c5082 100644 --- a/ext/standard/pageinfo.c +++ b/ext/standard/pageinfo.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: pageinfo.c,v 1.40.2.1 2006/01/01 12:50:15 sniper Exp $ */ +/* $Id: pageinfo.c,v 1.40.2.1.2.1 2007/01/01 09:36:08 sebastian Exp $ */ #include "php.h" #include "pageinfo.h" diff --git a/ext/standard/pageinfo.h b/ext/standard/pageinfo.h index b2bac5051..926e88617 100644 --- a/ext/standard/pageinfo.h +++ b/ext/standard/pageinfo.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: pageinfo.h,v 1.14.2.1 2006/01/01 12:50:15 sniper Exp $ */ +/* $Id: pageinfo.h,v 1.14.2.1.2.1 2007/01/01 09:36:08 sebastian Exp $ */ #ifndef PAGEINFO_H #define PAGEINFO_H diff --git a/ext/standard/php_array.h b/ext/standard/php_array.h index 1b48eb998..02190b8df 100644 --- a/ext/standard/php_array.h +++ b/ext/standard/php_array.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -19,7 +19,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_array.h,v 1.50.2.2.2.2 2006/07/15 10:21:09 helly Exp $ */ +/* $Id: php_array.h,v 1.50.2.2.2.3 2007/01/01 09:36:08 sebastian Exp $ */ #ifndef PHP_ARRAY_H #define PHP_ARRAY_H diff --git a/ext/standard/php_assert.h b/ext/standard/php_assert.h index 60be866f0..abc02f962 100644 --- a/ext/standard/php_assert.h +++ b/ext/standard/php_assert.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_assert.h,v 1.15.2.1 2006/01/01 12:50:15 sniper Exp $ */ +/* $Id: php_assert.h,v 1.15.2.1.2.1 2007/01/01 09:36:08 sebastian Exp $ */ #ifndef PHP_ASSERT_H #define PHP_ASSERT_H diff --git a/ext/standard/php_browscap.h b/ext/standard/php_browscap.h index 680e64513..074786bd2 100644 --- a/ext/standard/php_browscap.h +++ b/ext/standard/php_browscap.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_browscap.h,v 1.13.2.1 2006/01/01 12:50:15 sniper Exp $ */ +/* $Id: php_browscap.h,v 1.13.2.1.2.1 2007/01/01 09:36:08 sebastian Exp $ */ #ifndef PHP_BROWSCAP_H #define PHP_BROWSCAP_H diff --git a/ext/standard/php_crypt.h b/ext/standard/php_crypt.h index 737474467..f212c4590 100644 --- a/ext/standard/php_crypt.h +++ b/ext/standard/php_crypt.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_crypt.h,v 1.18.2.1 2006/01/01 12:50:15 sniper Exp $ */ +/* $Id: php_crypt.h,v 1.18.2.1.2.1 2007/01/01 09:36:08 sebastian Exp $ */ #ifndef PHP_CRYPT_H #define PHP_CRYPT_H diff --git a/ext/standard/php_dir.h b/ext/standard/php_dir.h index aaa99c695..d21331f32 100644 --- a/ext/standard/php_dir.h +++ b/ext/standard/php_dir.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_dir.h,v 1.24.2.1 2006/01/01 12:50:15 sniper Exp $ */ +/* $Id: php_dir.h,v 1.24.2.1.2.1 2007/01/01 09:36:08 sebastian Exp $ */ #ifndef PHP_DIR_H #define PHP_DIR_H diff --git a/ext/standard/php_ext_syslog.h b/ext/standard/php_ext_syslog.h index d26b63269..3106a2b07 100644 --- a/ext/standard/php_ext_syslog.h +++ b/ext/standard/php_ext_syslog.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_ext_syslog.h,v 1.12.2.2 2006/03/20 23:03:11 tony2001 Exp $ */ +/* $Id: php_ext_syslog.h,v 1.12.2.2.2.1 2007/01/01 09:36:08 sebastian Exp $ */ #ifndef PHP_EXT_SYSLOG_H #define PHP_EXT_SYSLOG_H diff --git a/ext/standard/php_filestat.h b/ext/standard/php_filestat.h index f029f1f5a..b519b0cae 100644 --- a/ext/standard/php_filestat.h +++ b/ext/standard/php_filestat.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_filestat.h,v 1.24.2.4 2006/03/05 19:01:37 derick Exp $ */ +/* $Id: php_filestat.h,v 1.24.2.4.2.1 2007/01/01 09:36:08 sebastian Exp $ */ #ifndef PHP_FILESTAT_H #define PHP_FILESTAT_H diff --git a/ext/standard/php_fopen_wrapper.c b/ext/standard/php_fopen_wrapper.c index bc792edd3..69fb63c58 100644 --- a/ext/standard/php_fopen_wrapper.c +++ b/ext/standard/php_fopen_wrapper.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -17,7 +17,7 @@ | Hartmut Holzgraefe <hholzgra@php.net> | +----------------------------------------------------------------------+ */ -/* $Id: php_fopen_wrapper.c,v 1.45.2.4.2.2 2006/07/05 17:38:14 iliaa Exp $ */ +/* $Id: php_fopen_wrapper.c,v 1.45.2.4.2.6 2007/01/01 09:36:08 sebastian Exp $ */ #include <stdio.h> #include <stdlib.h> @@ -187,15 +187,57 @@ php_stream * php_stream_url_wrap_php(php_stream_wrapper *wrapper, char *path, ch } if (!strcasecmp(path, "input")) { + if ((options & STREAM_OPEN_FOR_INCLUDE) && !PG(allow_url_include) ) { + if (options & REPORT_ERRORS) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "URL file-access is disabled in the server configuration"); + } + return NULL; + } return php_stream_alloc(&php_stream_input_ops, ecalloc(1, sizeof(off_t)), 0, "rb"); - } + } if (!strcasecmp(path, "stdin")) { - fd = !strcmp(sapi_module.name, "cli") ? STDIN_FILENO : dup(STDIN_FILENO); + if ((options & STREAM_OPEN_FOR_INCLUDE) && !PG(allow_url_include) ) { + if (options & REPORT_ERRORS) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "URL file-access is disabled in the server configuration"); + } + return NULL; + } + if (!strcmp(sapi_module.name, "cli")) { + static int cli_in = 0; + fd = STDIN_FILENO; + if (cli_in) { + fd = dup(fd); + } else { + cli_in = 1; + } + } else { + fd = dup(STDIN_FILENO); + } } else if (!strcasecmp(path, "stdout")) { - fd = !strcmp(sapi_module.name, "cli") ? STDOUT_FILENO : dup(STDOUT_FILENO); + if (!strcmp(sapi_module.name, "cli")) { + static int cli_out = 0; + fd = STDOUT_FILENO; + if (cli_out++) { + fd = dup(fd); + } else { + cli_out = 1; + } + } else { + fd = dup(STDOUT_FILENO); + } } else if (!strcasecmp(path, "stderr")) { - fd = !strcmp(sapi_module.name, "cli") ? STDERR_FILENO : dup(STDERR_FILENO); + if (!strcmp(sapi_module.name, "cli")) { + static int cli_err = 0; + fd = STDERR_FILENO; + if (cli_err++) { + fd = dup(fd); + } else { + cli_err = 1; + } + } else { + fd = dup(STDERR_FILENO); + } } else if (!strncasecmp(path, "filter/", 7)) { /* Save time/memory when chain isn't specified */ if (strchr(mode, 'r') || strchr(mode, '+')) { @@ -234,6 +276,7 @@ php_stream * php_stream_url_wrap_php(php_stream_wrapper *wrapper, char *path, ch return stream; } else { /* invalid php://thingy */ + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid php:// URL specified"); return NULL; } diff --git a/ext/standard/php_fopen_wrappers.h b/ext/standard/php_fopen_wrappers.h index 00ab55b84..c63022b01 100644 --- a/ext/standard/php_fopen_wrappers.h +++ b/ext/standard/php_fopen_wrappers.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_fopen_wrappers.h,v 1.21.2.1 2006/01/01 12:50:15 sniper Exp $ */ +/* $Id: php_fopen_wrappers.h,v 1.21.2.1.2.1 2007/01/01 09:36:08 sebastian Exp $ */ #ifndef PHP_FOPEN_WRAPPERS_H #define PHP_FOPEN_WRAPPERS_H diff --git a/ext/standard/php_ftok.h b/ext/standard/php_ftok.h index ec9a0b507..444761029 100644 --- a/ext/standard/php_ftok.h +++ b/ext/standard/php_ftok.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_ftok.h,v 1.9.2.1 2006/01/01 12:50:15 sniper Exp $ */ +/* $Id: php_ftok.h,v 1.9.2.1.2.1 2007/01/01 09:36:08 sebastian Exp $ */ #ifndef PHP_FTOK_H #define PHP_FTOK_H diff --git a/ext/standard/php_http.h b/ext/standard/php_http.h index 285748f3c..806beaaa8 100644 --- a/ext/standard/php_http.h +++ b/ext/standard/php_http.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_http.h,v 1.5.2.2 2006/01/01 12:50:15 sniper Exp $ */ +/* $Id: php_http.h,v 1.5.2.2.2.1 2007/01/01 09:36:08 sebastian Exp $ */ #ifndef PHP_HTTP_H #define PHP_HTTP_H diff --git a/ext/standard/php_image.h b/ext/standard/php_image.h index 151070c7e..37812fbff 100644 --- a/ext/standard/php_image.h +++ b/ext/standard/php_image.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_image.h,v 1.29.2.1 2006/01/01 12:50:15 sniper Exp $ */ +/* $Id: php_image.h,v 1.29.2.1.2.1 2007/01/01 09:36:08 sebastian Exp $ */ #ifndef PHP_IMAGE_H #define PHP_IMAGE_H diff --git a/ext/standard/php_incomplete_class.h b/ext/standard/php_incomplete_class.h index b0f9f1a3a..b194ede8d 100644 --- a/ext/standard/php_incomplete_class.h +++ b/ext/standard/php_incomplete_class.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_incomplete_class.h,v 1.17.2.2 2006/01/28 06:14:34 fmk Exp $ */ +/* $Id: php_incomplete_class.h,v 1.17.2.2.2.1 2007/01/01 09:36:08 sebastian Exp $ */ #ifndef PHP_INCOMPLETE_CLASS_H #define PHP_INCOMPLETE_CLASS_H diff --git a/ext/standard/php_iptc.h b/ext/standard/php_iptc.h index bc8be839a..c85b84ab2 100644 --- a/ext/standard/php_iptc.h +++ b/ext/standard/php_iptc.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_iptc.h,v 1.11.2.1 2006/01/01 12:50:15 sniper Exp $ */ +/* $Id: php_iptc.h,v 1.11.2.1.2.1 2007/01/01 09:36:08 sebastian Exp $ */ #ifndef PHP_IPTC_H #define PHP_IPTC_H diff --git a/ext/standard/php_lcg.h b/ext/standard/php_lcg.h index fcc08b78a..0d9f7af4a 100644 --- a/ext/standard/php_lcg.h +++ b/ext/standard/php_lcg.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_lcg.h,v 1.21.2.1 2006/01/01 12:50:15 sniper Exp $ */ +/* $Id: php_lcg.h,v 1.21.2.1.2.1 2007/01/01 09:36:08 sebastian Exp $ */ #ifndef PHP_LCG_H #define PHP_LCG_H diff --git a/ext/standard/php_link.h b/ext/standard/php_link.h index f9be666a4..0cde3a678 100644 --- a/ext/standard/php_link.h +++ b/ext/standard/php_link.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_link.h,v 1.12.2.1 2006/01/01 12:50:15 sniper Exp $ */ +/* $Id: php_link.h,v 1.12.2.1.2.1 2007/01/01 09:36:08 sebastian Exp $ */ #ifndef PHP_LINK_H #define PHP_LINK_H diff --git a/ext/standard/php_mail.h b/ext/standard/php_mail.h index 0961f5fe1..69010bd2c 100644 --- a/ext/standard/php_mail.h +++ b/ext/standard/php_mail.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_mail.h,v 1.18.2.1 2006/01/01 12:50:15 sniper Exp $ */ +/* $Id: php_mail.h,v 1.18.2.1.2.1 2007/01/01 09:36:08 sebastian Exp $ */ #ifndef PHP_MAIL_H #define PHP_MAIL_H diff --git a/ext/standard/php_math.h b/ext/standard/php_math.h index 19fa2518b..e7766a57a 100644 --- a/ext/standard/php_math.h +++ b/ext/standard/php_math.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -17,12 +17,16 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_math.h,v 1.28.2.2 2006/01/13 13:04:27 tony2001 Exp $ */ +/* $Id: php_math.h,v 1.28.2.2.2.3 2007/01/01 09:36:08 sebastian Exp $ */ #ifndef PHP_MATH_H #define PHP_MATH_H PHPAPI char *_php_math_number_format(double, int, char , char); +PHPAPI char * _php_math_longtobase(zval *arg, int base); +PHPAPI long _php_math_basetolong(zval *arg, int base); +PHPAPI int _php_math_basetozval(zval *arg, int base, zval *ret); +PHPAPI char * _php_math_zvaltobase(zval *arg, int base TSRMLS_DC); PHP_FUNCTION(sin); PHP_FUNCTION(cos); diff --git a/ext/standard/php_metaphone.h b/ext/standard/php_metaphone.h index efce8cc2b..b886a357f 100644 --- a/ext/standard/php_metaphone.h +++ b/ext/standard/php_metaphone.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_metaphone.h,v 1.16.2.1 2006/01/01 12:50:15 sniper Exp $ */ +/* $Id: php_metaphone.h,v 1.16.2.1.2.1 2007/01/01 09:36:08 sebastian Exp $ */ #ifndef PHP_METAPHONE_H #define PHP_METAPHONE_H diff --git a/ext/standard/php_rand.h b/ext/standard/php_rand.h index 4438af8a6..b6bb2c348 100644 --- a/ext/standard/php_rand.h +++ b/ext/standard/php_rand.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -20,7 +20,7 @@ | Based on code from: Shawn Cokus <Cokus@math.washington.edu> | +----------------------------------------------------------------------+ */ -/* $Id: php_rand.h,v 1.28.2.1 2006/01/01 12:50:15 sniper Exp $ */ +/* $Id: php_rand.h,v 1.28.2.1.2.1 2007/01/01 09:36:08 sebastian Exp $ */ #ifndef PHP_RAND_H #define PHP_RAND_H diff --git a/ext/standard/php_smart_str.h b/ext/standard/php_smart_str.h index e38ee8d23..4e8eb52fc 100644 --- a/ext/standard/php_smart_str.h +++ b/ext/standard/php_smart_str.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_smart_str.h,v 1.30.2.3 2006/05/03 13:32:10 iliaa Exp $ */ +/* $Id: php_smart_str.h,v 1.30.2.3.2.1 2007/01/01 09:36:08 sebastian Exp $ */ #ifndef PHP_SMART_STR_H #define PHP_SMART_STR_H diff --git a/ext/standard/php_smart_str_public.h b/ext/standard/php_smart_str_public.h index 869ad5ff4..d71d30618 100644 --- a/ext/standard/php_smart_str_public.h +++ b/ext/standard/php_smart_str_public.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_smart_str_public.h,v 1.10.2.1 2006/01/01 12:50:15 sniper Exp $ */ +/* $Id: php_smart_str_public.h,v 1.10.2.1.2.1 2007/01/01 09:36:08 sebastian Exp $ */ #ifndef PHP_SMART_STR_PUBLIC_H #define PHP_SMART_STR_PUBLIC_H diff --git a/ext/standard/php_standard.h b/ext/standard/php_standard.h index b76c284ca..e210bf6fb 100644 --- a/ext/standard/php_standard.h +++ b/ext/standard/php_standard.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_standard.h,v 1.24.2.2 2006/01/04 21:31:29 derick Exp $ */ +/* $Id: php_standard.h,v 1.24.2.2.2.1 2007/01/01 09:36:08 sebastian Exp $ */ #include "basic_functions.h" #include "php_math.h" diff --git a/ext/standard/php_string.h b/ext/standard/php_string.h index d4f38d217..b4936d84e 100644 --- a/ext/standard/php_string.h +++ b/ext/standard/php_string.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_string.h,v 1.87.2.2.2.1 2006/08/28 23:33:37 iliaa Exp $ */ +/* $Id: php_string.h,v 1.87.2.2.2.3 2007/01/01 09:36:08 sebastian Exp $ */ /* Synced with php 3.0 revision 1.43 1999-06-16 [ssb] */ @@ -132,6 +132,7 @@ PHPAPI char *php_str_to_str(char *haystack, int length, char *needle, int needle_len, char *str, int str_len, int *_new_length); PHPAPI char *php_trim(char *c, int len, char *what, int what_len, zval *return_value, int mode TSRMLS_DC); PHPAPI size_t php_strip_tags(char *rbuf, int len, int *state, char *allow, int allow_len); +PHPAPI size_t php_strip_tags_ex(char *rbuf, int len, int *stateptr, char *allow, int allow_len, zend_bool allow_tag_spaces); PHPAPI int php_char_to_str_ex(char *str, uint len, char from, char *to, int to_len, zval *result, int case_sensitivity, int *replace_count); PHPAPI int php_char_to_str(char *str, uint len, char from, char *to, int to_len, zval *result); PHPAPI void php_implode(zval *delim, zval *arr, zval *return_value TSRMLS_DC); diff --git a/ext/standard/php_type.h b/ext/standard/php_type.h index b3b865d53..fee24bdf7 100644 --- a/ext/standard/php_type.h +++ b/ext/standard/php_type.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_type.h,v 1.6.2.1 2006/01/01 12:50:15 sniper Exp $ */ +/* $Id: php_type.h,v 1.6.2.1.2.1 2007/01/01 09:36:08 sebastian Exp $ */ #ifndef PHP_TYPE_H #define PHP_TYPE_H diff --git a/ext/standard/php_uuencode.h b/ext/standard/php_uuencode.h index c735d2a26..908d64e6e 100644 --- a/ext/standard/php_uuencode.h +++ b/ext/standard/php_uuencode.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_uuencode.h,v 1.4.2.1 2006/01/01 12:50:15 sniper Exp $ */ +/* $Id: php_uuencode.h,v 1.4.2.1.2.1 2007/01/01 09:36:08 sebastian Exp $ */ #ifndef PHP_UUENCODE_H #define PHP_UUENCODE_H diff --git a/ext/standard/php_var.h b/ext/standard/php_var.h index 332aa4f86..329375d17 100644 --- a/ext/standard/php_var.h +++ b/ext/standard/php_var.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_var.h,v 1.30.2.1.2.1 2006/05/30 14:51:20 iliaa Exp $ */ +/* $Id: php_var.h,v 1.30.2.1.2.5 2007/01/01 09:36:08 sebastian Exp $ */ #ifndef PHP_VAR_H #define PHP_VAR_H @@ -28,10 +28,8 @@ PHP_FUNCTION(var_export); PHP_FUNCTION(debug_zval_dump); PHP_FUNCTION(serialize); PHP_FUNCTION(unserialize); -#if MEMORY_LIMIT PHP_FUNCTION(memory_get_usage); PHP_FUNCTION(memory_get_peak_usage); -#endif PHPAPI void php_var_dump(zval **struc, int level TSRMLS_DC); PHPAPI void php_var_export(zval **struc, int level TSRMLS_DC); diff --git a/ext/standard/php_versioning.h b/ext/standard/php_versioning.h index 629ac61e1..a23aa7506 100644 --- a/ext/standard/php_versioning.h +++ b/ext/standard/php_versioning.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_versioning.h,v 1.10.2.1 2006/01/01 12:50:15 sniper Exp $ */ +/* $Id: php_versioning.h,v 1.10.2.1.2.1 2007/01/01 09:36:08 sebastian Exp $ */ #ifndef PHP_VERSIONING_H #define PHP_VERSIONING_H diff --git a/ext/standard/proc_open.c b/ext/standard/proc_open.c index 8d7bc669f..6cdf7ddee 100644 --- a/ext/standard/proc_open.c +++ b/ext/standard/proc_open.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -15,7 +15,7 @@ | Author: Wez Furlong <wez@thebrainroom.com> | +----------------------------------------------------------------------+ */ -/* $Id: proc_open.c,v 1.36.2.1.2.1 2006/06/01 14:03:49 tony2001 Exp $ */ +/* $Id: proc_open.c,v 1.36.2.1.2.15 2007/04/16 08:09:55 dmitry Exp $ */ #if 0 && (defined(__linux__) || defined(sun) || defined(__IRIX__)) # define _BSD_SOURCE /* linux wants this when XOPEN mode is on */ @@ -216,10 +216,10 @@ static void proc_open_rsrc_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC) #ifdef PHP_WIN32 - WaitForSingleObject(proc->child, INFINITE); - GetExitCodeProcess(proc->child, &wstatus); + WaitForSingleObject(proc->childHandle, INFINITE); + GetExitCodeProcess(proc->childHandle, &wstatus); FG(pclose_ret) = wstatus; - CloseHandle(proc->child); + CloseHandle(proc->childHandle); #elif HAVE_SYS_WAIT_H @@ -248,7 +248,7 @@ static void proc_open_rsrc_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC) /* {{{ php_make_safe_mode_command */ static int php_make_safe_mode_command(char *cmd, char **safecmd, int is_persistent TSRMLS_DC) { - int lcmd, larg0, ldir, len, overflow_limit; + int lcmd, larg0; char *space, *sep, *arg0; if (!PG(safe_mode)) { @@ -257,42 +257,27 @@ static int php_make_safe_mode_command(char *cmd, char **safecmd, int is_persiste } lcmd = strlen(cmd); - ldir = strlen(PG(safe_mode_exec_dir)); - len = lcmd + ldir + 2; - overflow_limit = len; - arg0 = emalloc(len); - - strcpy(arg0, cmd); - - space = strchr(arg0, ' '); + arg0 = estrndup(cmd, lcmd); + + space = memchr(arg0, ' ', lcmd); if (space) { *space = '\0'; + larg0 = space - arg0; + } else { + larg0 = lcmd; } - larg0 = strlen(arg0); - if (strstr(arg0, "..")) { + if (php_memnstr(arg0, "..", sizeof("..")-1, arg0 + larg0)) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "No '..' components allowed in path"); efree(arg0); return FAILURE; } - *safecmd = emalloc(len); - strcpy(*safecmd, PG(safe_mode_exec_dir)); - overflow_limit -= ldir; - - sep = strrchr(arg0, PHP_DIR_SEPARATOR); - if (sep) { - strcat(*safecmd, sep); - overflow_limit -= strlen(sep); - } else { - strcat(*safecmd, "/"); - strcat(*safecmd, arg0); - overflow_limit -= larg0 + 1; - } - if (space) { - strncat(*safecmd, cmd + larg0, overflow_limit); - } + sep = zend_memrchr(arg0, PHP_DIR_SEPARATOR, larg0); + + spprintf(safecmd, 0, "%s%s%s%s", PG(safe_mode_exec_dir), (sep ? sep : "/"), (sep ? "" : arg0), (space ? cmd + larg0 : "")); + efree(arg0); arg0 = php_escape_shell_cmd(*safecmd); efree(*safecmd); @@ -315,7 +300,7 @@ PHP_MINIT_FUNCTION(proc_open) } /* }}} */ -/* {{{ proto int proc_terminate(resource process [, long signal]) +/* {{{ proto bool proc_terminate(resource process [, long signal]) kill a process opened by proc_open */ PHP_FUNCTION(proc_terminate) { @@ -330,13 +315,18 @@ PHP_FUNCTION(proc_terminate) ZEND_FETCH_RESOURCE(proc, struct php_process_handle *, &zproc, -1, "process", le_proc_open); #ifdef PHP_WIN32 - TerminateProcess(proc->child, 255); + if (TerminateProcess(proc->childHandle, 255)) { + RETURN_TRUE; + } else { + RETURN_FALSE; + } #else - kill(proc->child, sig_no); + if (kill(proc->child, sig_no) == 0) { + RETURN_TRUE; + } else { + RETURN_FALSE; + } #endif - - zend_list_delete(Z_LVAL_P(zproc)); - RETURN_LONG(FG(pclose_ret)); } /* }}} */ @@ -386,7 +376,7 @@ PHP_FUNCTION(proc_get_status) #ifdef PHP_WIN32 - GetExitCodeProcess(proc->child, &wstatus); + GetExitCodeProcess(proc->childHandle, &wstatus); running = wstatus == STILL_ACTIVE; exitcode == STILL_ACTIVE ? -1 : wstatus; @@ -485,6 +475,7 @@ PHP_FUNCTION(proc_open) struct php_proc_open_descriptor_item descriptors[PHP_PROC_OPEN_MAX_DESCRIPTORS]; #ifdef PHP_WIN32 PROCESS_INFORMATION pi; + HANDLE childHandle; STARTUPINFO si; BOOL newprocok; SECURITY_ATTRIBUTES security; @@ -503,6 +494,7 @@ PHP_FUNCTION(proc_open) int is_persistent = 0; /* TODO: ensure that persistent procs will work */ #ifdef PHP_WIN32 int suppress_errors = 0; + int bypass_shell = 0; #endif #if PHP_CAN_DO_PTS php_file_descriptor_t dev_ptmx = -1; /* master */ @@ -523,10 +515,17 @@ PHP_FUNCTION(proc_open) if (other_options) { zval **item; if (SUCCESS == zend_hash_find(Z_ARRVAL_P(other_options), "suppress_errors", sizeof("suppress_errors"), (void**)&item)) { - if (Z_TYPE_PP(item) == IS_BOOL && Z_BVAL_PP(item)) { + if ((Z_TYPE_PP(item) == IS_BOOL || Z_TYPE_PP(item) == IS_LONG) && + Z_LVAL_PP(item)) { suppress_errors = 1; } } + if (SUCCESS == zend_hash_find(Z_ARRVAL_P(other_options), "bypass_shell", sizeof("bypass_shell"), (void**)&item)) { + if ((Z_TYPE_PP(item) == IS_BOOL || Z_TYPE_PP(item) == IS_LONG) && + Z_LVAL_PP(item)) { + bypass_shell = 1; + } + } } #endif @@ -639,8 +638,6 @@ PHP_FUNCTION(proc_open) descriptors[ndesc].mode_flags |= O_BINARY; #endif - - } else if (strcmp(Z_STRVAL_PP(ztype), "file") == 0) { zval **zfile, **zmode; int fd; @@ -674,7 +671,8 @@ PHP_FUNCTION(proc_open) } #ifdef PHP_WIN32 - descriptors[ndesc].childend = (HANDLE)_get_osfhandle(fd); + descriptors[ndesc].childend = dup_fd_as_handle(fd); + _close(fd); #else descriptors[ndesc].childend = fd; #endif @@ -742,27 +740,38 @@ PHP_FUNCTION(proc_open) memset(&pi, 0, sizeof(pi)); - command_with_cmd = emalloc(command_len + sizeof(COMSPEC_9X) + 1 + sizeof(" /c ")); - sprintf(command_with_cmd, "%s /c %s", GetVersion() < 0x80000000 ? COMSPEC_NT : COMSPEC_9X, command); - if (suppress_errors) { old_error_mode = SetErrorMode(SEM_FAILCRITICALERRORS|SEM_NOGPFAULTERRORBOX); } - newprocok = CreateProcess(NULL, command_with_cmd, &security, &security, TRUE, NORMAL_PRIORITY_CLASS, env.envp, cwd, &si, &pi); + if (bypass_shell) { + newprocok = CreateProcess(NULL, command, &security, &security, TRUE, NORMAL_PRIORITY_CLASS|CREATE_NO_WINDOW, env.envp, cwd, &si, &pi); + } else { + spprintf(&command_with_cmd, 0, "%s /c %s", GetVersion() < 0x80000000 ? COMSPEC_NT : COMSPEC_9X, command); + + newprocok = CreateProcess(NULL, command_with_cmd, &security, &security, TRUE, NORMAL_PRIORITY_CLASS|CREATE_NO_WINDOW, env.envp, cwd, &si, &pi); + + efree(command_with_cmd); + } if (suppress_errors) { SetErrorMode(old_error_mode); } - efree(command_with_cmd); - if (FALSE == newprocok) { + /* clean up all the descriptors */ + for (i = 0; i < ndesc; i++) { + CloseHandle(descriptors[i].childend); + if (descriptors[i].parentend) { + CloseHandle(descriptors[i].parentend); + } + } php_error_docref(NULL TSRMLS_CC, E_WARNING, "CreateProcess failed"); goto exit_fail; } - child = pi.hProcess; + childHandle = pi.hProcess; + child = pi.dwProcessId; CloseHandle(pi.hThread); #elif defined(NETWARE) @@ -775,6 +784,9 @@ PHP_FUNCTION(proc_open) channel.errfd = -1; /* Duplicate the command as processing downwards will modify it*/ command_dup = strdup(command); + if (!command_dup) { + goto exit_fail; + } /* get a number of args */ construct_argc_argv(command_dup, NULL, &command_num_args, NULL); child_argv = (char**) malloc((command_num_args + 1) * sizeof(char*)); @@ -800,7 +812,8 @@ PHP_FUNCTION(proc_open) /* clean up all the descriptors */ for (i = 0; i < ndesc; i++) { close(descriptors[i].childend); - close(descriptors[i].parentend); + if (descriptors[i].parentend) + close(descriptors[i].parentend); } php_error_docref(NULL TSRMLS_CC, E_WARNING, "procve failed - %s", strerror(errno)); goto exit_fail; @@ -867,7 +880,8 @@ PHP_FUNCTION(proc_open) /* clean up all the descriptors */ for (i = 0; i < ndesc; i++) { close(descriptors[i].childend); - close(descriptors[i].parentend); + if (descriptors[i].parentend) + close(descriptors[i].parentend); } php_error_docref(NULL TSRMLS_CC, E_WARNING, "fork failed - %s", strerror(errno)); @@ -885,6 +899,9 @@ PHP_FUNCTION(proc_open) proc->command = command; proc->npipes = ndesc; proc->child = child; +#ifdef PHP_WIN32 + proc->childHandle = childHandle; +#endif proc->env = env; if (pipes != NULL) { @@ -929,10 +946,14 @@ PHP_FUNCTION(proc_open) break; } #ifdef PHP_WIN32 - stream = php_stream_fopen_from_fd(_open_osfhandle((long)descriptors[i].parentend, + stream = php_stream_fopen_from_fd(_open_osfhandle((zend_intptr_t)descriptors[i].parentend, descriptors[i].mode_flags), mode_string, NULL); #else stream = php_stream_fopen_from_fd(descriptors[i].parentend, mode_string, NULL); +# if defined(F_SETFD) && defined(FD_CLOEXEC) + /* mark the descriptor close-on-exec, so that it won't be inherited by potential other children */ + fcntl(descriptors[i].parentend, F_SETFD, FD_CLOEXEC); +# endif #endif if (stream) { zval *retfp; diff --git a/ext/standard/proc_open.h b/ext/standard/proc_open.h index 490b92f6b..520a83e92 100644 --- a/ext/standard/proc_open.h +++ b/ext/standard/proc_open.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -15,11 +15,11 @@ | Author: Wez Furlong <wez@thebrainroom.com> | +----------------------------------------------------------------------+ */ -/* $Id: proc_open.h,v 1.5.2.1 2006/01/01 12:50:15 sniper Exp $ */ +/* $Id: proc_open.h,v 1.5.2.1.2.2 2007/01/01 09:36:08 sebastian Exp $ */ #ifdef PHP_WIN32 typedef HANDLE php_file_descriptor_t; -typedef HANDLE php_process_id_t; +typedef DWORD php_process_id_t; #else typedef int php_file_descriptor_t; typedef pid_t php_process_id_t; @@ -40,6 +40,9 @@ typedef struct _php_process_env { struct php_process_handle { php_process_id_t child; +#ifdef PHP_WIN32 + HANDLE childHandle; +#endif int npipes; long pipes[PHP_PROC_OPEN_MAX_DESCRIPTORS]; char *command; diff --git a/ext/standard/quot_print.c b/ext/standard/quot_print.c index 589144c93..a8ba0f8c2 100644 --- a/ext/standard/quot_print.c +++ b/ext/standard/quot_print.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: quot_print.c,v 1.29.2.2 2006/01/01 12:50:15 sniper Exp $ */ +/* $Id: quot_print.c,v 1.29.2.2.2.1 2007/01/01 09:36:08 sebastian Exp $ */ #include <stdlib.h> diff --git a/ext/standard/quot_print.h b/ext/standard/quot_print.h index 98bb75ce0..9ffc9286b 100644 --- a/ext/standard/quot_print.h +++ b/ext/standard/quot_print.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: quot_print.h,v 1.13.2.1 2006/01/01 12:50:15 sniper Exp $ */ +/* $Id: quot_print.h,v 1.13.2.1.2.1 2007/01/01 09:36:08 sebastian Exp $ */ #ifndef QUOT_PRINT_H #define QUOT_PRINT_H diff --git a/ext/standard/rand.c b/ext/standard/rand.c index d7a99a02d..d9161a15f 100644 --- a/ext/standard/rand.c +++ b/ext/standard/rand.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -17,10 +17,13 @@ | Pedro Melo <melo@ip.pt> | | Sterling Hughes <sterling@php.net> | | | - | Based on code from: Shawn Cokus <Cokus@math.washington.edu> | + | Based on code from: Richard J. Wagner <rjwagner@writeme.com> | + | Makoto Matsumoto <matumoto@math.keio.ac.jp> | + | Takuji Nishimura | + | Shawn Cokus <Cokus@math.washington.edu> | +----------------------------------------------------------------------+ */ -/* $Id: rand.c,v 1.70.2.1 2006/01/01 12:50:15 sniper Exp $ */ +/* $Id: rand.c,v 1.70.2.1.2.2 2007/01/01 09:36:08 sebastian Exp $ */ #include <stdlib.h> @@ -85,152 +88,127 @@ PHPAPI long php_rand(TSRMLS_D) /* MT RAND FUNCTIONS */ /* - This is the ``Mersenne Twister'' random number generator MT19937, which - generates pseudorandom integers uniformly distributed in 0..(2^32 - 1) - starting from any odd seed in 0..(2^32 - 1). This version is a recode - by Shawn Cokus (Cokus@math.washington.edu) on March 8, 1998 of a version by - Takuji Nishimura (who had suggestions from Topher Cooper and Marc Rieffel in - July-August 1997). - - Effectiveness of the recoding (on Goedel2.math.washington.edu, a DEC Alpha - running OSF/1) using GCC -O3 as a compiler: before recoding: 51.6 sec. to - generate 300 million random numbers; after recoding: 24.0 sec. for the same - (i.e., 46.5% of original time), so speed is now about 12.5 million random - number generations per second on this machine. - - According to the URL <http://www.math.keio.ac.jp/~matumoto/emt.html> - (and paraphrasing a bit in places), the Mersenne Twister is ``designed - with consideration of the flaws of various existing generators,'' has - a period of 2^19937 - 1, gives a sequence that is 623-dimensionally - equidistributed, and ``has passed many stringent tests, including the - die-hard test of G. Marsaglia and the load test of P. Hellekalek and - S. Wegenkittl.'' It is efficient in memory usage (typically using 2506 - to 5012 bytes of static data, depending on data type sizes, and the code - is quite short as well). It generates random numbers in batches of 624 - at a time, so the caching and pipelining of modern systems is exploited. - It is also divide- and mod-free. - - This library is free software; you can redistribute it and/or modify it - under the terms of the GNU Library General Public License as published by - the Free Software Foundation (either version 2 of the License or, at your - option, any later version). This library is distributed in the hope that - it will be useful, but WITHOUT ANY WARRANTY, without even the implied - warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - the GNU Library General Public License for more details. You should have - received a copy of the GNU Library General Public License along with this - library; if not, write to the Free Software Foundation, Inc., 59 Temple - Place, Suite 330, Boston, MA 02111-1307, USA. - - The code as Shawn received it included the following notice: - - Copyright (C) 1997 Makoto Matsumoto and Takuji Nishimura. When - you use this, send an e-mail to <matumoto@math.keio.ac.jp> with - an appropriate reference to your work. - - It would be nice to CC: <Cokus@math.washington.edu> when you write. - - - - php_uint32 must be an unsigned integer type capable of holding at least 32 - bits; exactly 32 should be fastest, but 64 is better on an Alpha with - GCC at -O3 optimization so try your options and see what's best for you - - Melo: we should put some ifdefs here to catch those alphas... + The following php_mt_...() functions are based on a C++ class MTRand by + Richard J. Wagner. For more information see the web page at + http://www-personal.engin.umich.edu/~wagnerr/MersenneTwister.html + + Mersenne Twister random number generator -- a C++ class MTRand + Based on code by Makoto Matsumoto, Takuji Nishimura, and Shawn Cokus + Richard J. Wagner v1.0 15 May 2003 rjwagner@writeme.com + + The Mersenne Twister is an algorithm for generating random numbers. It + was designed with consideration of the flaws in various other generators. + The period, 2^19937-1, and the order of equidistribution, 623 dimensions, + are far greater. The generator is also fast; it avoids multiplication and + division, and it benefits from caches and pipelines. For more information + see the inventors' web page at http://www.math.keio.ac.jp/~matumoto/emt.html + + Reference + M. Matsumoto and T. Nishimura, "Mersenne Twister: A 623-Dimensionally + Equidistributed Uniform Pseudo-Random Number Generator", ACM Transactions on + Modeling and Computer Simulation, Vol. 8, No. 1, January 1998, pp 3-30. + + Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura, + Copyright (C) 2000 - 2003, Richard J. Wagner + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + 3. The names of its contributors may not be used to endorse or promote + products derived from this software without specific prior written + permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + The original code included the following notice: + + When you use this, send an email to: matumoto@math.keio.ac.jp + with an appropriate reference to your work. + + It would be nice to CC: rjwagner@writeme.com and Cokus@math.washington.edu + when you write. */ + #define N MT_N /* length of state vector */ #define M (397) /* a period parameter */ -#define K (0x9908B0DFU) /* a magic constant */ #define hiBit(u) ((u) & 0x80000000U) /* mask all but highest bit of u */ #define loBit(u) ((u) & 0x00000001U) /* mask all but lowest bit of u */ #define loBits(u) ((u) & 0x7FFFFFFFU) /* mask the highest bit of u */ #define mixBits(u, v) (hiBit(u)|loBits(v)) /* move hi bit of u to hi bit of v */ -/* {{{ php_mt_srand +#define twist(m,u,v) (m ^ (mixBits(u,v)>>1) ^ ((php_uint32)(-(php_int32)(loBit(u))) & 0x9908b0dfU)) + +/* {{{ php_mt_initialize */ -PHPAPI void php_mt_srand(php_uint32 seed TSRMLS_DC) +static inline void php_mt_initialize(php_uint32 seed, php_uint32 *state) { - /* - We initialize state[0..(N-1)] via the generator - - x_new = (69069 * x_old) mod 2^32 - - from Line 15 of Table 1, p. 106, Sec. 3.3.4 of Knuth's - _The Art of Computer Programming_, Volume 2, 3rd ed. - - Notes (SJC): I do not know what the initial state requirements - of the Mersenne Twister are, but it seems this seeding generator - could be better. It achieves the maximum period for its modulus - (2^30) iff x_initial is odd (p. 20-21, Sec. 3.2.1.2, Knuth); if - x_initial can be even, you have sequences like 0, 0, 0, ...; - 2^31, 2^31, 2^31, ...; 2^30, 2^30, 2^30, ...; 2^29, 2^29 + 2^31, - 2^29, 2^29 + 2^31, ..., etc. so I force seed to be odd below. - - - Even if x_initial is odd, if x_initial is 1 mod 4 then - - the lowest bit of x is always 1, - the next-to-lowest bit of x is always 0, - the 2nd-from-lowest bit of x alternates ... 0 1 0 1 0 1 0 1 ... , - the 3rd-from-lowest bit of x 4-cycles ... 0 1 1 0 0 1 1 0 ... , - the 4th-from-lowest bit of x has the 8-cycle ... 0 0 0 1 1 1 1 0 ... , - ... - - and if x_initial is 3 mod 4 then - - the lowest bit of x is always 1, - the next-to-lowest bit of x is always 1, - the 2nd-from-lowest bit of x alternates ... 0 1 0 1 0 1 0 1 ... , - the 3rd-from-lowest bit of x 4-cycles ... 0 0 1 1 0 0 1 1 ... , - the 4th-from-lowest bit of x has the 8-cycle ... 0 0 1 1 1 1 0 0 ... , - ... - - The generator's potency (min. s>=0 with (69069-1)^s = 0 mod 2^32) is - 16, which seems to be alright by p. 25, Sec. 3.2.1.3 of Knuth. It - also does well in the dimension 2..5 spectral tests, but it could be - better in dimension 6 (Line 15, Table 1, p. 106, Sec. 3.3.4, Knuth). - - Note that the random number user does not see the values generated - here directly since reloadMT() will always munge them first, so maybe - none of all of this matters. In fact, the seed values made here could - even be extra-special desirable if the Mersenne Twister theory says - so-- that's why the only change I made is to restrict to odd seeds. - */ - - register php_uint32 x = (seed | 1U) & 0xFFFFFFFFU, *s = BG(state); - register int j; - - for (BG(left) = 0, *s++ = x, j = N; --j; - *s++ = (x *= 69069U) & 0xFFFFFFFFU); - - /* Seed only once */ - BG(mt_rand_is_seeded) = 1; + /* Initialize generator state with seed + See Knuth TAOCP Vol 2, 3rd Ed, p.106 for multiplier. + In previous versions, most significant bits (MSBs) of the seed affect + only MSBs of the state array. Modified 9 Jan 2002 by Makoto Matsumoto. */ + + register php_uint32 *s = state; + register php_uint32 *r = state; + register int i = 1; + + *s++ = seed & 0xffffffffU; + for( ; i < N; ++i ) { + *s++ = ( 1812433253U * ( *r ^ (*r >> 30) ) + i ) & 0xffffffffU; + r++; + } } /* }}} */ /* {{{ php_mt_reload */ -static php_uint32 php_mt_reload(TSRMLS_D) +static inline void php_mt_reload(TSRMLS_D) { - register php_uint32 *p0 = BG(state), *p2 = BG(state) + 2, *pM = BG(state) + M, s0, s1; - register int j; - - if (BG(left) < -1) - php_mt_srand(4357U TSRMLS_CC); - - BG(left) = N - 1, BG(next) = BG(state) + 1; - - for (s0 = BG(state)[0], s1 = BG(state)[1], j = N - M + 1; --j; s0 = s1, s1 = *p2++) - *p0++ = *pM++ ^ (mixBits(s0, s1) >> 1) ^ (loBit(s1) ? K : 0U); - - for (pM = BG(state), j = M; --j; s0 = s1, s1 = *p2++) - *p0++ = *pM++ ^ (mixBits(s0, s1) >> 1) ^ (loBit(s1) ? K : 0U); + /* Generate N new values in state + Made clearer and faster by Matthew Bellew (matthew.bellew@home.com) */ + + register php_uint32 *state = BG(state); + register php_uint32 *p = state; + register int i; + + for (i = N - M; i--; ++p) + *p = twist(p[M], p[0], p[1]); + for (i = M; --i; ++p) + *p = twist(p[M-N], p[0], p[1]); + *p = twist(p[M-N], p[0], state[0]); + BG(left) = N; + BG(next) = state; +} +/* }}} */ - s1 = BG(state)[0], *p0 = *pM ^ (mixBits(s0, s1) >> 1) ^ (loBit(s1) ? K : 0U); - s1 ^= (s1 >> 11); - s1 ^= (s1 << 7) & 0x9D2C5680U; - s1 ^= (s1 << 15) & 0xEFC60000U; +/* {{{ php_mt_srand + */ +PHPAPI void php_mt_srand(php_uint32 seed TSRMLS_DC) +{ + /* Seed the generator with a simple uint32 */ + php_mt_initialize(seed, BG(state)); + php_mt_reload(TSRMLS_C); - return s1 ^ (s1 >> 18); + /* Seed only once */ + BG(mt_rand_is_seeded) = 1; } /* }}} */ @@ -238,17 +216,21 @@ static php_uint32 php_mt_reload(TSRMLS_D) */ PHPAPI php_uint32 php_mt_rand(TSRMLS_D) { - php_uint32 y; - - if (--BG(left) < 0) - return php_mt_reload(TSRMLS_C); - - y = *BG(next)++; - y ^= (y >> 11); - y ^= (y << 7) & 0x9D2C5680U; - y ^= (y << 15) & 0xEFC60000U; + /* Pull a 32-bit integer from the generator state + Every other access function simply transforms the numbers extracted here */ + + register php_uint32 s1; - return y ^ (y >> 18); + if (BG(left) == 0) { + php_mt_reload(TSRMLS_C); + } + --BG(left); + + s1 = *BG(next)++; + s1 ^= (s1 >> 11); + s1 ^= (s1 << 7) & 0x9d2c5680U; + s1 ^= (s1 << 15) & 0xefc60000U; + return ( s1 ^ (s1 >> 18) ); } /* }}} */ diff --git a/ext/standard/reg.c b/ext/standard/reg.c index f72476f69..beacf285f 100644 --- a/ext/standard/reg.c +++ b/ext/standard/reg.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -17,7 +17,7 @@ | Jaakko Hyvätti <jaakko@hyvatti.iki.fi> | +----------------------------------------------------------------------+ */ -/* $Id: reg.c,v 1.82.2.3 2006/02/26 10:49:50 helly Exp $ */ +/* $Id: reg.c,v 1.82.2.3.2.2 2007/01/01 09:36:08 sebastian Exp $ */ #include <stdio.h> #include <ctype.h> @@ -425,7 +425,7 @@ PHPAPI char *php_reg_replace(const char *pattern, const char *replace, const cha buf = nbuf; } /* stick that last bit of string on our output */ - strcat(buf, &string[pos]); + strlcat(buf, &string[pos], buf_len); } } diff --git a/ext/standard/reg.h b/ext/standard/reg.h index 7df88a669..2d3b7e8ea 100644 --- a/ext/standard/reg.h +++ b/ext/standard/reg.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -17,7 +17,7 @@ */ -/* $Id: reg.h,v 1.21.2.1 2006/01/01 12:50:15 sniper Exp $ */ +/* $Id: reg.h,v 1.21.2.1.2.1 2007/01/01 09:36:08 sebastian Exp $ */ #ifndef REG_H #define REG_H diff --git a/ext/standard/scanf.c b/ext/standard/scanf.c index 7659cce40..6f29c48e3 100644 --- a/ext/standard/scanf.c +++ b/ext/standard/scanf.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: scanf.c,v 1.31.2.2.2.1 2006/08/04 11:50:15 tony2001 Exp $ */ +/* $Id: scanf.c,v 1.31.2.2.2.3 2007/02/24 02:17:27 helly Exp $ */ /* scanf.c -- @@ -1094,7 +1094,7 @@ PHPAPI int php_sscanf_internal( char *string, char *format, *end = '\0'; value = (int) (*fn)(buf, NULL, base); if ((flags & SCAN_UNSIGNED) && (value < 0)) { - sprintf(buf, "%u", value); /* INTL: ISO digit */ + snprintf(buf, sizeof(buf), "%u", value); /* INTL: ISO digit */ if (numVars && objIndex >= argCount) { break; } else if (numVars) { diff --git a/ext/standard/scanf.h b/ext/standard/scanf.h index fdd9a90dc..391c9d504 100644 --- a/ext/standard/scanf.h +++ b/ext/standard/scanf.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: scanf.h,v 1.14.2.2 2006/01/01 12:50:15 sniper Exp $ */ +/* $Id: scanf.h,v 1.14.2.2.2.1 2007/01/01 09:36:08 sebastian Exp $ */ #ifndef SCANF_H #define SCANF_H diff --git a/ext/standard/sha1.c b/ext/standard/sha1.c index 824fe230e..ff327b292 100644 --- a/ext/standard/sha1.c +++ b/ext/standard/sha1.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: sha1.c,v 1.13.2.1 2006/01/01 12:50:15 sniper Exp $ */ +/* $Id: sha1.c,v 1.13.2.1.2.1 2007/01/01 09:36:08 sebastian Exp $ */ #include "php.h" diff --git a/ext/standard/sha1.h b/ext/standard/sha1.h index c55207955..fc9049000 100644 --- a/ext/standard/sha1.h +++ b/ext/standard/sha1.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: sha1.h,v 1.5.2.1.2.1 2006/09/29 22:35:47 iliaa Exp $ */ +/* $Id: sha1.h,v 1.5.2.1.2.2 2007/01/01 09:36:08 sebastian Exp $ */ #ifndef SHA1_H #define SHA1_H diff --git a/ext/standard/soundex.c b/ext/standard/soundex.c index 6af503b5e..31f803dff 100644 --- a/ext/standard/soundex.c +++ b/ext/standard/soundex.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -15,7 +15,7 @@ | Author: Bjørn Borud - Guardian Networks AS <borud@guardian.no> | +----------------------------------------------------------------------+ */ -/* $Id: soundex.c,v 1.25.2.1 2006/01/01 12:50:15 sniper Exp $ */ +/* $Id: soundex.c,v 1.25.2.1.2.1 2007/01/01 09:36:08 sebastian Exp $ */ #include "php.h" #include <stdlib.h> diff --git a/ext/standard/streamsfuncs.c b/ext/standard/streamsfuncs.c index 9a1564cb9..48e5e1481 100644 --- a/ext/standard/streamsfuncs.c +++ b/ext/standard/streamsfuncs.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: streamsfuncs.c,v 1.58.2.6.2.9 2006/10/11 23:22:45 pollita Exp $ */ +/* $Id: streamsfuncs.c,v 1.58.2.6.2.14 2007/04/09 15:38:58 dmitry Exp $ */ #include "php.h" #include "php_globals.h" @@ -361,7 +361,7 @@ PHP_FUNCTION(stream_socket_recvfrom) RETURN_FALSE; } - read_buf = emalloc(to_read + 1); + read_buf = safe_emalloc(1, to_read, 1); recvd = php_stream_xport_recvfrom(stream, read_buf, to_read, flags, NULL, NULL, zremote ? &Z_STRVAL_P(zremote) : NULL, @@ -530,7 +530,7 @@ PHP_FUNCTION(stream_get_transports) while (zend_hash_get_current_key_ex(stream_xport_hash, &stream_xport, &stream_xport_len, &num_key, 0, NULL) == HASH_KEY_IS_STRING) { - add_next_index_stringl(return_value, stream_xport, stream_xport_len, 1); + add_next_index_stringl(return_value, stream_xport, stream_xport_len - 1, 1); zend_hash_move_forward(stream_xport_hash); } } else { @@ -558,7 +558,7 @@ PHP_FUNCTION(stream_get_wrappers) (key_flags = zend_hash_get_current_key_ex(url_stream_wrappers_hash, &stream_protocol, &stream_protocol_len, &num_key, 0, NULL)) != HASH_KEY_NON_EXISTANT; zend_hash_move_forward(url_stream_wrappers_hash)) { if (key_flags == HASH_KEY_IS_STRING) { - add_next_index_stringl(return_value, stream_protocol, stream_protocol_len, 1); + add_next_index_stringl(return_value, stream_protocol, stream_protocol_len - 1, 1); } } } else { @@ -712,7 +712,7 @@ PHP_FUNCTION(stream_select) struct timeval tv; struct timeval *tv_p = NULL; fd_set rfds, wfds, efds; - int max_fd = 0; + php_socket_t max_fd = 0; int retval, sets = 0; long usec = 0; int set_count, max_set_count = 0; @@ -1341,6 +1341,36 @@ PHP_FUNCTION(stream_socket_enable_crypto) } /* }}} */ +#ifdef HAVE_SHUTDOWN +/* {{{ proto int stream_socket_shutdown(resource stream, int how) + causes all or part of a full-duplex connection on the socket associated + with stream to be shut down. If how is SHUT_RD, further receptions will + be disallowed. If how is SHUT_WR, further transmissions will be disallowed. + If how is SHUT_RDWR, further receptions and transmissions will be + disallowed. */ +PHP_FUNCTION(stream_socket_shutdown) +{ + long how; + zval *zstream; + php_stream *stream; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl", &zstream, &how) == FAILURE) { + RETURN_FALSE; + } + + if (how != STREAM_SHUT_RD && + how != STREAM_SHUT_WR && + how != STREAM_SHUT_RDWR) { + RETURN_FALSE; + } + + php_stream_from_zval(stream, &zstream); + + RETURN_BOOL(php_stream_xport_shutdown(stream, (stream_shutdown_t)how TSRMLS_CC) == 0); +} +#endif +/* }}} */ + /* * Local variables: * tab-width: 4 diff --git a/ext/standard/streamsfuncs.h b/ext/standard/streamsfuncs.h index 338f606ed..87b85f7ea 100644 --- a/ext/standard/streamsfuncs.h +++ b/ext/standard/streamsfuncs.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: streamsfuncs.h,v 1.13.2.1.2.1 2006/06/26 16:33:39 bjori Exp $ */ +/* $Id: streamsfuncs.h,v 1.13.2.1.2.3 2007/01/01 09:36:09 sebastian Exp $ */ /* Flags for stream_socket_client */ #define PHP_STREAM_CLIENT_PERSISTENT 1 @@ -53,6 +53,7 @@ PHP_FUNCTION(stream_filter_prepend); PHP_FUNCTION(stream_filter_append); PHP_FUNCTION(stream_filter_remove); PHP_FUNCTION(stream_socket_enable_crypto); +PHP_FUNCTION(stream_socket_shutdown); PHP_FUNCTION(stream_socket_pair); /* diff --git a/ext/standard/string.c b/ext/standard/string.c index 0b1b19d75..56543ac60 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: string.c,v 1.445.2.14.2.27 2006/10/11 14:19:55 iliaa Exp $ */ +/* $Id: string.c,v 1.445.2.14.2.54 2007/03/26 10:25:41 tony2001 Exp $ */ /* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */ @@ -905,7 +905,7 @@ PHPAPI void php_implode(zval *delim, zval *arr, zval *return_value TSRMLS_DC) case IS_LONG: { char stmp[MAX_LENGTH_OF_LONG + 1]; - str_len = sprintf(stmp, "%ld", Z_LVAL_PP(tmp)); + str_len = slprintf(stmp, sizeof(stmp), "%ld", Z_LVAL_PP(tmp)); smart_str_appendl(&implstr, stmp, str_len); } break; @@ -955,7 +955,12 @@ PHPAPI void php_implode(zval *delim, zval *arr, zval *return_value TSRMLS_DC) } smart_str_0(&implstr); - RETURN_STRINGL(implstr.c, implstr.len, 0); + if (implstr.len) { + RETURN_STRINGL(implstr.c, implstr.len, 0); + } else { + smart_str_free(&implstr); + RETURN_EMPTY_STRING(); + } } /* }}} */ @@ -1230,11 +1235,11 @@ quit_loop: } len = cend - comp; - ret = emalloc(len + 1); - memcpy(ret, comp, len); - ret[len] = '\0'; if (p_ret) { + ret = emalloc(len + 1); + memcpy(ret, comp, len); + ret[len] = '\0'; *p_ret = ret; } if (p_len) { @@ -1876,6 +1881,8 @@ PHP_FUNCTION(strripos) if (offset >= 0) { if (offset > haystack_len) { + efree(needle_dup); + efree(haystack_dup); php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Offset is greater than the length of haystack string"); RETURN_FALSE; } @@ -1883,6 +1890,8 @@ PHP_FUNCTION(strripos) e = haystack_dup + haystack_len - needle_len; } else { if (-offset > haystack_len) { + efree(needle_dup); + efree(haystack_dup); php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Offset is greater than the length of haystack string"); RETURN_FALSE; } @@ -2054,11 +2063,23 @@ PHP_FUNCTION(substr) if (argc > 2) { convert_to_long_ex(len); l = Z_LVAL_PP(len); + if ((l < 0 && -l > Z_STRLEN_PP(str))) { + RETURN_FALSE; + } else if (l > Z_STRLEN_PP(str)) { + l = Z_STRLEN_PP(str); + } } else { l = Z_STRLEN_PP(str); } f = Z_LVAL_PP(from); + if (f > Z_STRLEN_PP(str) || (f < 0 && -f > Z_STRLEN_PP(str))) { + RETURN_FALSE; + } + + if (l < 0 && (l + Z_STRLEN_PP(str) - f) < 0) { + RETURN_FALSE; + } /* if "from" position is negative, count start position from the end * of the string @@ -2181,6 +2202,12 @@ PHP_FUNCTION(substr_replace) } } + if (f > Z_STRLEN_PP(str) || (f < 0 && -f > Z_STRLEN_PP(str))) { + RETURN_FALSE; + } else if (l > Z_STRLEN_PP(str) || (l < 0 && -l > Z_STRLEN_PP(str))) { + RETURN_FALSE; + } + if ((f + l) > Z_STRLEN_PP(str)) { l = Z_STRLEN_PP(str) - f; } @@ -2831,11 +2858,8 @@ PHP_FUNCTION(addcslashes) RETURN_STRINGL(Z_STRVAL_PP(str), Z_STRLEN_PP(str), 1); } - RETURN_STRING(php_addcslashes(Z_STRVAL_PP(str), - Z_STRLEN_PP(str), - &Z_STRLEN_P(return_value), 0, - Z_STRVAL_PP(what), - Z_STRLEN_PP(what) TSRMLS_CC), 0); + Z_STRVAL_P(return_value) = php_addcslashes(Z_STRVAL_PP(str), Z_STRLEN_PP(str), &Z_STRLEN_P(return_value), 0, Z_STRVAL_PP(what), Z_STRLEN_PP(what) TSRMLS_CC); + RETURN_STRINGL(Z_STRVAL_P(return_value), Z_STRLEN_P(return_value), 0); } /* }}} */ @@ -2906,7 +2930,7 @@ char *php_strerror(int errnum) return(sys_errlist[errnum]); } - (void) sprintf(BG(str_ebuf), "Unknown error: %d", errnum); + (void) snprintf(BG(str_ebuf), sizeof(php_basic_globals.str_ebuf), "Unknown error: %d", errnum); return(BG(str_ebuf)); } /* }}} */ @@ -2990,10 +3014,6 @@ PHPAPI char *php_addcslashes(char *str, int length, int *new_length, int should_ wlength = strlen(what); } - if (!length) { - length = strlen(str); - } - php_charmask(what, wlength, flags TSRMLS_CC); for (source = str, end = source + length, target = new_str; (c = *source) || (source < end); source++) { @@ -3143,7 +3163,7 @@ PHPAPI int php_char_to_str_ex(char *str, uint len, char from, char *to, int to_l } Z_STRLEN_P(result) = len + (char_count * (to_len - 1)); - Z_STRVAL_P(result) = target = emalloc(Z_STRLEN_P(result) + 1); + Z_STRVAL_P(result) = target = safe_emalloc(char_count, to_len, len + 1); Z_TYPE_P(result) = IS_STRING; if (case_sensitivity) { @@ -3333,16 +3353,33 @@ nothing_todo: new_str = estrndup(haystack, length); return new_str; } else { - if (case_sensitivity ? strncmp(haystack, needle, length) : strncasecmp(haystack, needle, length)) { + if (case_sensitivity && memcmp(haystack, needle, length)) { goto nothing_todo; - } else { - *_new_length = str_len; - new_str = estrndup(str, str_len); - if (replace_count) { - (*replace_count)++; + } else if (!case_sensitivity) { + char *l_haystack, *l_needle; + + l_haystack = estrndup(haystack, length); + l_needle = estrndup(needle, length); + + php_strtolower(l_haystack, length); + php_strtolower(l_needle, length); + + if (memcmp(l_haystack, l_needle, length)) { + efree(l_haystack); + efree(l_needle); + goto nothing_todo; } - return new_str; + efree(l_haystack); + efree(l_needle); + } + + *_new_length = str_len; + new_str = estrndup(str, str_len); + + if (replace_count) { + (*replace_count)++; } + return new_str; } } @@ -3872,7 +3909,7 @@ PHP_FUNCTION(strip_tags) } convert_to_string_ex(str); buf = estrndup(Z_STRVAL_PP(str), Z_STRLEN_PP(str)); - retval_len = php_strip_tags(buf, Z_STRLEN_PP(str), NULL, allowed_tags, allowed_tags_len); + retval_len = php_strip_tags_ex(buf, Z_STRLEN_PP(str), NULL, allowed_tags, allowed_tags_len, 0); RETURN_STRINGL(buf, retval_len, 0); } /* }}} */ @@ -3949,6 +3986,7 @@ PHP_FUNCTION(setlocale) } retval = setlocale (cat, loc); + zend_update_current_locale(); if (retval) { /* Remember if locale was changed */ if (loc) { @@ -4026,7 +4064,13 @@ PHP_FUNCTION(parse_str) int php_tag_find(char *tag, int len, char *set) { char c, *n, *t; int state=0, done=0; - char *norm = emalloc(len+1); + char *norm; + + if (len <= 0) { + return 0; + } + + norm = emalloc(len+1); n = norm; t = tag; @@ -4036,9 +4080,6 @@ int php_tag_find(char *tag, int len, char *set) { and turn any <a whatever...> into just <a> and any </tag> into <tag> */ - if (!len) { - return 0; - } while (!done) { switch (c) { case '<': @@ -4076,6 +4117,11 @@ int php_tag_find(char *tag, int len, char *set) { } /* }}} */ +PHPAPI size_t php_strip_tags(char *rbuf, int len, int *stateptr, char *allow, int allow_len) +{ + return php_strip_tags_ex(rbuf, len, stateptr, allow, allow_len, 0); +} + /* {{{ php_strip_tags A simple little state-machine to strip out html and php tags @@ -4096,10 +4142,10 @@ int php_tag_find(char *tag, int len, char *set) { swm: Added ability to strip <?xml tags without assuming it PHP code. */ -PHPAPI size_t php_strip_tags(char *rbuf, int len, int *stateptr, char *allow, int allow_len) +PHPAPI size_t php_strip_tags_ex(char *rbuf, int len, int *stateptr, char *allow, int allow_len, zend_bool allow_tag_spaces) { char *tbuf, *buf, *p, *tp, *rp, c, lc; - int br, i=0, depth=0; + int br, i=0, depth=0, in_q = 0; int state = 0; if (stateptr) @@ -4124,7 +4170,7 @@ PHPAPI size_t php_strip_tags(char *rbuf, int len, int *stateptr, char *allow, in case '\0': break; case '<': - if (isspace(*(p + 1))) { + if (isspace(*(p + 1)) && !allow_tag_spaces) { goto reg_char; } if (state == 0) { @@ -4133,7 +4179,7 @@ PHPAPI size_t php_strip_tags(char *rbuf, int len, int *stateptr, char *allow, in if (allow) { tp = ((tp-tbuf) >= PHP_TAG_BUF_SIZE ? tbuf: tp); *(tp++) = '<'; - } + } } else if (state == 1) { depth++; } @@ -4172,11 +4218,15 @@ PHPAPI size_t php_strip_tags(char *rbuf, int len, int *stateptr, char *allow, in depth--; break; } - + + if (in_q) { + break; + } + switch (state) { case 1: /* HTML/XML */ lc = '>'; - state = 0; + in_q = state = 0; if (allow) { tp = ((tp-tbuf) >= PHP_TAG_BUF_SIZE ? tbuf: tp); *(tp++) = '>'; @@ -4191,19 +4241,19 @@ PHPAPI size_t php_strip_tags(char *rbuf, int len, int *stateptr, char *allow, in case 2: /* PHP */ if (!br && lc != '\"' && *(p-1) == '?') { - state = 0; + in_q = state = 0; tp = tbuf; } break; case 3: - state = 0; + in_q = state = 0; tp = tbuf; break; case 4: /* JavaScript/CSS/etc... */ if (p >= buf + 2 && *(p-1) == '-' && *(p-2) == '-') { - state = 0; + in_q = state = 0; tp = tbuf; } break; @@ -4228,6 +4278,13 @@ PHPAPI size_t php_strip_tags(char *rbuf, int len, int *stateptr, char *allow, in tp = ((tp-tbuf) >= PHP_TAG_BUF_SIZE ? tbuf: tp); *(tp++) = c; } + if (state && p != buf && *(p-1) != '\\' && (!in_q || *p == in_q)) { + if (in_q) { + in_q = 0; + } else { + in_q = *p; + } + } break; case '!': @@ -4600,18 +4657,20 @@ PHP_FUNCTION(substr_count) php_error_docref(NULL TSRMLS_CC, E_WARNING, "Offset should be greater than or equal to 0."); RETURN_FALSE; } - p += Z_LVAL_PP(offset); - if (p > endp) { + + if (Z_LVAL_PP(offset) > Z_STRLEN_PP(haystack)) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Offset value %ld exceeds string length.", Z_LVAL_PP(offset)); RETURN_FALSE; } + p += Z_LVAL_PP(offset); + if (ac == 4) { convert_to_long_ex(length); if (Z_LVAL_PP(length) <= 0) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Length should be greater than 0."); RETURN_FALSE; } - if ((p + Z_LVAL_PP(length)) > endp) { + if (Z_LVAL_PP(length) > (Z_STRLEN_PP(haystack) - Z_LVAL_PP(offset))) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Length value %ld exceeds string length.", Z_LVAL_PP(length)); RETURN_FALSE; } @@ -5032,11 +5091,16 @@ PHP_FUNCTION(substr_compare) offset = (offset < 0) ? 0 : offset; } - if ((offset + len) > s1_len) { + if(offset > s1_len) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "The start position cannot exceed initial string length"); RETURN_FALSE; } + if(len > s1_len - offset) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "The length cannot exceed initial string length"); + RETURN_FALSE; + } + cmp_len = (uint) (len ? len : MAX(s2_len, (s1_len - offset))); if (!cs) { diff --git a/ext/standard/syslog.c b/ext/standard/syslog.c index 2407fb56a..93c1e31b5 100644 --- a/ext/standard/syslog.c +++ b/ext/standard/syslog.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: syslog.c,v 1.49.2.3 2006/03/21 00:59:08 iliaa Exp $ */ +/* $Id: syslog.c,v 1.49.2.3.2.1 2007/01/01 09:36:09 sebastian Exp $ */ #include "php.h" diff --git a/ext/standard/tests/array/array_diff_key.phpt b/ext/standard/tests/array/array_diff_key.phpt index 91664a871..765431f12 100644 --- a/ext/standard/tests/array/array_diff_key.phpt +++ b/ext/standard/tests/array/array_diff_key.phpt @@ -66,13 +66,13 @@ function comp_func($a, $b) { ------ Test 1 -------- array(4) { [1]=> - &int(2) + int(2) [6]=> - &int(12) + int(12) [15]=> - &int(30) + int(30) [1200]=> - &int(2400) + int(2400) } array(4) { [1]=> @@ -188,11 +188,11 @@ array(3) { ------ Test 7 -------- array(3) { [7]=> - &int(14) + int(14) [11]=> - &int(22) + int(22) [1100]=> - &int(2200) + int(2200) } array(3) { [7]=> diff --git a/ext/standard/tests/array/array_flip.phpt b/ext/standard/tests/array/array_flip.phpt index 27b14fdd9..af26fd80c 100644 --- a/ext/standard/tests/array/array_flip.phpt +++ b/ext/standard/tests/array/array_flip.phpt @@ -14,6 +14,13 @@ $trans = array("a" => 1, 2 => "i");
$trans = array_flip($trans);
var_dump($trans);
+
+var_dump(array_flip());
+var_dump(array_flip(array()));
+var_dump(array_flip(array(1)));
+var_dump(array_flip(array(array())));
+
+echo "Done\n";
?>
--EXPECTF--
Warning: array_flip(): Can only flip STRING and INTEGER values! in %s on line %d
@@ -35,3 +42,17 @@ array(6) { ["i"]=>
int(2)
}
+
+Warning: Wrong parameter count for array_flip() in %s on line %d
+NULL
+array(0) {
+}
+array(1) {
+ [1]=>
+ int(0)
+}
+
+Warning: array_flip(): Can only flip STRING and INTEGER values! in %s on line %d
+array(0) {
+}
+Done
diff --git a/ext/standard/tests/array/array_intersect_key.phpt b/ext/standard/tests/array/array_intersect_key.phpt index 6a5965ba7..6d2783940 100644 --- a/ext/standard/tests/array/array_intersect_key.phpt +++ b/ext/standard/tests/array/array_intersect_key.phpt @@ -62,9 +62,9 @@ function comp_func($a, $b) { --EXPECTF-- array(3) { [2]=> - &int(4) + int(4) [-20]=> - &int(-40) + int(-40) [-2500]=> &int(-5000) } @@ -138,11 +138,11 @@ array(1) { } array(4) { [0]=> - &int(0) + int(0) [2]=> - &int(4) + int(4) [-20]=> - &int(-40) + int(-40) [-2500]=> &int(-5000) } diff --git a/ext/standard/tests/array/array_key_exists.phpt b/ext/standard/tests/array/array_key_exists.phpt new file mode 100644 index 000000000..e7b6c0677 --- /dev/null +++ b/ext/standard/tests/array/array_key_exists.phpt @@ -0,0 +1,40 @@ +--TEST-- +array_key_exists() tests +--FILE-- +<?php + +var_dump(array_key_exists()); +var_dump(array_key_exists(array(), array())); +var_dump(array_key_exists("", "")); +var_dump(array_key_exists("", array())); +var_dump(array_key_exists(1, array())); + +var_dump(array_key_exists(1, array(1,2,3))); +var_dump(array_key_exists("a", array(3,2,1,"a"=>1))); +var_dump(array_key_exists("a", array(3,2,1))); +var_dump(array_key_exists(NULL, array(5,6,7,""=>"value", 3,2,1))); +var_dump(array_key_exists(NULL, array(5,6,7,3,2,1))); +var_dump(array_key_exists(false, array(5,6,7,""=>"value", 3,2,1))); + +echo "Done\n"; +?> +--EXPECTF-- +Warning: Wrong parameter count for array_key_exists() in %s on line %d +NULL + +Warning: array_key_exists(): The first argument should be either a string or an integer in %s on line %d +bool(false) + +Warning: array_key_exists(): The second argument should be either an array or an object in %s on line %d +bool(false) +bool(false) +bool(false) +bool(true) +bool(true) +bool(false) +bool(true) +bool(false) + +Warning: array_key_exists(): The first argument should be either a string or an integer in %s on line %d +bool(false) +Done diff --git a/ext/standard/tests/array/array_pad.phpt b/ext/standard/tests/array/array_pad.phpt new file mode 100644 index 000000000..e6c4590c1 --- /dev/null +++ b/ext/standard/tests/array/array_pad.phpt @@ -0,0 +1,101 @@ +--TEST-- +array_pad() tests +--FILE-- +<?php + +var_dump(array_pad()); +var_dump(array_pad(array())); +var_dump(array_pad(array(), 1)); +var_dump(array_pad(array(), 1, 0)); + +var_dump(array_pad(array(), 0, 0)); +var_dump(array_pad(array(), -1, 0)); +var_dump(array_pad(array("", -1, 2.0), 5, 0)); +var_dump(array_pad(array("", -1, 2.0), 5, array())); +var_dump(array_pad(array("", -1, 2.0), 2, array())); +var_dump(array_pad(array("", -1, 2.0), -3, array())); +var_dump(array_pad(array("", -1, 2.0), -4, array())); +var_dump(array_pad(array("", -1, 2.0), 2000000, 0)); +var_dump(array_pad("", 2000000, 0)); + +echo "Done\n"; +?> +--EXPECTF-- +Warning: Wrong parameter count for array_pad() in %s on line %d +NULL + +Warning: Wrong parameter count for array_pad() in %s on line %d +NULL + +Warning: Wrong parameter count for array_pad() in %s on line %d +NULL +array(1) { + [0]=> + int(0) +} +array(0) { +} +array(1) { + [0]=> + int(0) +} +array(5) { + [0]=> + string(0) "" + [1]=> + int(-1) + [2]=> + float(2) + [3]=> + int(0) + [4]=> + int(0) +} +array(5) { + [0]=> + string(0) "" + [1]=> + int(-1) + [2]=> + float(2) + [3]=> + array(0) { + } + [4]=> + array(0) { + } +} +array(3) { + [0]=> + string(0) "" + [1]=> + int(-1) + [2]=> + float(2) +} +array(3) { + [0]=> + string(0) "" + [1]=> + int(-1) + [2]=> + float(2) +} +array(4) { + [0]=> + array(0) { + } + [1]=> + string(0) "" + [2]=> + int(-1) + [3]=> + float(2) +} + +Warning: array_pad(): You may only pad up to 1048576 elements at a time in %s on line %d +bool(false) + +Warning: array_pad(): The argument should be an array in %s on line %d +NULL +Done diff --git a/ext/standard/tests/array/array_rand.phpt b/ext/standard/tests/array/array_rand.phpt new file mode 100644 index 000000000..22424465a --- /dev/null +++ b/ext/standard/tests/array/array_rand.phpt @@ -0,0 +1,51 @@ +--TEST-- +array_rand() tests +--FILE-- +<?php + +var_dump(array_rand()); +var_dump(array_rand(array())); +var_dump(array_rand(array(), 0)); +var_dump(array_rand(0, 0)); +var_dump(array_rand(array(1,2,3), 0)); +var_dump(array_rand(array(1,2,3), -1)); +var_dump(array_rand(array(1,2,3), 10)); +var_dump(array_rand(array(1,2,3), 3)); +var_dump(array_rand(array(1,2,3), 2)); + +echo "Done\n"; +?> +--EXPECTF-- +Warning: Wrong parameter count for array_rand() in %s on line %d +NULL +NULL + +Warning: array_rand(): Second argument has to be between 1 and the number of elements in the array in %s on line %d +NULL + +Warning: array_rand(): First argument has to be an array in %s on line %d +NULL + +Warning: array_rand(): Second argument has to be between 1 and the number of elements in the array in %s on line %d +NULL + +Warning: array_rand(): Second argument has to be between 1 and the number of elements in the array in %s on line %d +NULL + +Warning: array_rand(): Second argument has to be between 1 and the number of elements in the array in %s on line %d +NULL +array(3) { + [0]=> + int(%d) + [1]=> + int(%d) + [2]=> + int(%d) +} +array(2) { + [0]=> + int(%d) + [1]=> + int(%d) +} +Done diff --git a/ext/standard/tests/array/array_sum.phpt b/ext/standard/tests/array/array_sum.phpt index f1868cb2e..08aec2155 100644 --- a/ext/standard/tests/array/array_sum.phpt +++ b/ext/standard/tests/array/array_sum.phpt @@ -1,7 +1,8 @@ --TEST-- Test array_sum() --INI-- -memory_limit=64M +precision=14 +memory_limit=128M --FILE-- <?php $i = 0; diff --git a/ext/standard/tests/array/array_unshift.phpt b/ext/standard/tests/array/array_unshift.phpt new file mode 100644 index 000000000..0e8dae919 --- /dev/null +++ b/ext/standard/tests/array/array_unshift.phpt @@ -0,0 +1,40 @@ +--TEST-- +array_unshift() tests +--FILE-- +<?php + +$a = array(); +$s = ""; +var_dump(array_unshift($a, $s)); +var_dump($a); +var_dump(array_unshift($s, $a)); +var_dump($a); +var_dump(array_unshift($a, $a)); +var_dump($a); + +echo "Done\n"; +?> +--EXPECTF-- +int(1) +array(1) { + [0]=> + string(0) "" +} + +Warning: array_unshift(): The first argument should be an array in %s on line %d +bool(false) +array(1) { + [0]=> + string(0) "" +} +int(2) +array(2) { + [0]=> + array(1) { + [0]=> + string(0) "" + } + [1]=> + string(0) "" +} +Done diff --git a/ext/standard/tests/array/array_user_key_compare.phpt b/ext/standard/tests/array/array_user_key_compare.phpt new file mode 100644 index 000000000..7f82f71ca --- /dev/null +++ b/ext/standard/tests/array/array_user_key_compare.phpt @@ -0,0 +1,19 @@ +--TEST-- +Fix UMR in array_user_key_compare (MOPB24) +--FILE-- +<?php +$arr = array("A" => 1, "B" => 1); + +function array_compare(&$key1, &$key2) + { + $GLOBALS['a'] = &$key2; + unset($key2); + return 1; + } + +uksort($arr, "array_compare"); +var_dump($a); + +?> +--EXPECTF-- +string(1) "A" diff --git a/ext/standard/tests/array/array_values.phpt b/ext/standard/tests/array/array_values.phpt new file mode 100644 index 000000000..42e252ac8 --- /dev/null +++ b/ext/standard/tests/array/array_values.phpt @@ -0,0 +1,47 @@ +--TEST-- +array_values() tests +--FILE-- +<?php + +var_dump(array_values()); +var_dump(array_values(array())); +var_dump(array_values("")); +var_dump(array_values(new stdclass)); + +$a = array(1, 2, 2.0, "asdasd", array(1,2,3)); + +var_dump(array_values($a)); + +echo "Done\n"; +?> +--EXPECTF-- +Warning: Wrong parameter count for array_values() in %s on line %d +NULL +array(0) { +} + +Warning: array_values(): The argument should be an array in %s on line %d +NULL + +Warning: array_values(): The argument should be an array in %s on line %d +NULL +array(5) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + float(2) + [3]=> + string(6) "asdasd" + [4]=> + array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } +} +Done diff --git a/ext/standard/tests/array/bug30074.phpt b/ext/standard/tests/array/bug30074.phpt new file mode 100644 index 000000000..7720fe000 --- /dev/null +++ b/ext/standard/tests/array/bug30074.phpt @@ -0,0 +1,15 @@ +--TEST-- +Bug #30074 (EG(uninitialized_zval_ptr) gets set to reference using EXTR_REFS, affecting later values) +--FILE-- +<?php +error_reporting(E_ALL & ~E_NOTICE); // We don't want the notice for $undefined +$result = extract(array('a'=>$undefined), EXTR_REFS); +var_dump(array($a)); +echo "Done\n"; +?> +--EXPECT-- +array(1) { + [0]=> + NULL +} +Done diff --git a/ext/standard/tests/array/bug33382.phpt b/ext/standard/tests/array/bug33382.phpt index 407b5846f..376227f1f 100644 --- a/ext/standard/tests/array/bug33382.phpt +++ b/ext/standard/tests/array/bug33382.phpt @@ -1,5 +1,5 @@ --TEST-- -bug #33382 ( array_reverse() fails after *sort() ) +Bug #33382 ( array_reverse() fails after *sort() ) --FILE-- <?php diff --git a/ext/standard/tests/array/bug36975.phpt b/ext/standard/tests/array/bug36975.phpt new file mode 100644 index 000000000..f37c933e3 --- /dev/null +++ b/ext/standard/tests/array/bug36975.phpt @@ -0,0 +1,62 @@ +--TEST-- +Bug #36975 (natcasesort() causes array_pop() to misbehave) +--FILE-- +<?php +$a = array('aa', 'aa', 'bb', 'bb', 'cc', 'cc'); +$test = natcasesort($a); +if ($test) { + echo "natcasesort success!\n"; +} +$val = array_pop($a); +$a[] = $val; +var_dump($a); + +$b = array(1 => 'foo', 0 => 'baz'); +array_pop($b); +$b[] = 'bar'; +array_push($b, 'bar'); +print_r($b); + +$c = array(0, 0, 0, 0, 0); +asort($c); +array_pop($c); +$c[] = 'foo'; +$c[] = 'bar'; +var_dump($c); +?> +--EXPECT-- +natcasesort success! +array(6) { + [0]=> + string(2) "aa" + [1]=> + string(2) "aa" + [3]=> + string(2) "bb" + [2]=> + string(2) "bb" + [5]=> + string(2) "cc" + [6]=> + string(2) "cc" +} +Array +( + [1] => foo + [2] => bar + [3] => bar +) +array(6) { + [4]=> + int(0) + [3]=> + int(0) + [2]=> + int(0) + [1]=> + int(0) + [5]=> + string(3) "foo" + [6]=> + string(3) "bar" +} diff --git a/ext/standard/tests/array/bug39576.phpt b/ext/standard/tests/array/bug39576.phpt new file mode 100644 index 000000000..7c8aeef17 --- /dev/null +++ b/ext/standard/tests/array/bug39576.phpt @@ -0,0 +1,52 @@ +--TEST-- +Bug #39576 (array_walk() doesn't separate userdata zval) +--FILE-- +<?php + +class Test { + + public $_table = ''; + public $_columns = array (); + public $_primary = array (); + +} + +$test = new Test (); +$test->name = 'test'; +$test->_columns['name'] = new stdClass; + +function test ($value, $column, &$columns) {} + +array_walk ( + get_object_vars ($test), + 'test', + $test->_columns +); + +var_dump($test); + +array_intersect_key ( + get_object_vars ($test), + $test->_primary +); + +echo "Done\n"; +?> +--EXPECTF-- +Strict Standards: Only variables should be passed by reference in %s on line %d +object(Test)#%d (4) { + ["_table"]=> + string(0) "" + ["_columns"]=> + array(1) { + ["name"]=> + object(stdClass)#%d (0) { + } + } + ["_primary"]=> + array(0) { + } + ["name"]=> + string(4) "test" +} +Done diff --git a/ext/standard/tests/array/bug40191.phpt b/ext/standard/tests/array/bug40191.phpt new file mode 100644 index 000000000..038104b57 --- /dev/null +++ b/ext/standard/tests/array/bug40191.phpt @@ -0,0 +1,25 @@ +--TEST-- +Bug #40191 (use of array_unique() with objects triggers segfault) +--SKIPIF-- +<?php if (!extension_loaded('spl')) die("skip SPL is not available"); ?> +--FILE-- +<?php + +$arrObj = new ArrayObject(); +$arrObj->append('foo'); +$arrObj->append('bar'); +$arrObj->append('foo'); + +$arr = array_unique($arrObj); +var_dump($arr); + +echo "Done\n"; +?> +--EXPECTF-- +array(2) { + [0]=> + string(3) "foo" + [1]=> + string(3) "bar" +} +Done diff --git a/ext/standard/tests/array/bug40709.phpt b/ext/standard/tests/array/bug40709.phpt new file mode 100644 index 000000000..6ab6bbd41 --- /dev/null +++ b/ext/standard/tests/array/bug40709.phpt @@ -0,0 +1,28 @@ +--TEST-- +Bug #40709 (array_reduce() behaves strange with one item stored arrays) +--SKIPIF-- +--FILE-- +<?php +function CommaSeperatedList($a, $b) { + if($a == null) + return $b; + else + return $a.','.$b; +} + +$arr1 = array(1,2,3); +$arr2 = array(1); + +echo "result for arr1: ".array_reduce($arr1,'CommaSeperatedList')."\n"; +echo "result for arr2: ".array_reduce($arr2,'CommaSeperatedList')."\n"; +echo "result for arr1: ".array_reduce($arr1,'CommaSeperatedList')."\n"; +echo "result for arr2: ".array_reduce($arr2,'CommaSeperatedList')."\n"; + +echo "Done\n"; +?> +--EXPECT-- +result for arr1: 1,2,3 +result for arr2: 1 +result for arr1: 1,2,3 +result for arr2: 1 +Done diff --git a/ext/standard/tests/array/bug41121.phpt b/ext/standard/tests/array/bug41121.phpt new file mode 100644 index 000000000..a03bdaf4c --- /dev/null +++ b/ext/standard/tests/array/bug41121.phpt @@ -0,0 +1,128 @@ +--TEST-- +Bug #41121 (range() overflow handling for large numbers on 32bit machines) +--INI-- +precision=14 +--SKIPIF-- +<?php if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only"); ?> +--FILE-- +<?php + +// posotive steps +var_dump(range(2147483400, 2147483600, 100)); +var_dump( range(2147483646, 2147483648, 1 ) ); +var_dump( range(2147483646, 2147483657, 1 ) ); +var_dump( range(2147483630, 2147483646, 5 ) ); + +// negative steps +var_dump( range(-2147483645, -2147483648, 1 ) ); +var_dump( range(-2147483645, -2147483649, 1 ) ); +var_dump( range(-2147483630, -2147483646, 5 ) ); + +// low > high +var_dump(range(2147483647, 2147483645, 1 )); +var_dump(range(2147483648, 2147483645, 1 )); + +?> +--EXPECT-- +array(3) { + [0]=> + int(2147483400) + [1]=> + int(2147483500) + [2]=> + int(2147483600) +} +array(3) { + [0]=> + float(2147483646) + [1]=> + float(2147483647) + [2]=> + float(2147483648) +} +array(12) { + [0]=> + float(2147483646) + [1]=> + float(2147483647) + [2]=> + float(2147483648) + [3]=> + float(2147483649) + [4]=> + float(2147483650) + [5]=> + float(2147483651) + [6]=> + float(2147483652) + [7]=> + float(2147483653) + [8]=> + float(2147483654) + [9]=> + float(2147483655) + [10]=> + float(2147483656) + [11]=> + float(2147483657) +} +array(4) { + [0]=> + int(2147483630) + [1]=> + int(2147483635) + [2]=> + int(2147483640) + [3]=> + int(2147483645) +} +array(4) { + [0]=> + float(-2147483645) + [1]=> + float(-2147483646) + [2]=> + float(-2147483647) + [3]=> + float(-2147483648) +} +array(5) { + [0]=> + float(-2147483645) + [1]=> + float(-2147483646) + [2]=> + float(-2147483647) + [3]=> + float(-2147483648) + [4]=> + float(-2147483649) +} +array(4) { + [0]=> + int(-2147483630) + [1]=> + int(-2147483635) + [2]=> + int(-2147483640) + [3]=> + int(-2147483645) +} +array(3) { + [0]=> + int(2147483647) + [1]=> + int(2147483646) + [2]=> + int(2147483645) +} +array(4) { + [0]=> + float(2147483648) + [1]=> + float(2147483647) + [2]=> + float(2147483646) + [3]=> + float(2147483645) +} diff --git a/ext/standard/tests/array/compact.phpt b/ext/standard/tests/array/compact.phpt new file mode 100644 index 000000000..b70e55846 --- /dev/null +++ b/ext/standard/tests/array/compact.phpt @@ -0,0 +1,60 @@ +--TEST-- +compact() tests +--FILE-- +<?php + +$var1 = "test"; +$var2 = "one more"; +$var3 = "and the last one"; +$_ = "a"; + +var_dump(compact("var1", "var2", "var3")); +var_dump(compact("")); +var_dump(compact("-1")); +var_dump(compact(".")); +var_dump(compact("_")); +var_dump(compact("var3", "var4")); +var_dump(compact(array("var2", "var3"))); +var_dump(compact(array(array("var1"), array("var1")))); + +$a = array(2.0, -5); +var_dump(compact($a)); + +echo "Done\n"; +?> +--EXPECTF-- +array(3) { + ["var1"]=> + string(4) "test" + ["var2"]=> + string(8) "one more" + ["var3"]=> + string(16) "and the last one" +} +array(0) { +} +array(0) { +} +array(0) { +} +array(1) { + ["_"]=> + string(1) "a" +} +array(1) { + ["var3"]=> + string(16) "and the last one" +} +array(2) { + ["var2"]=> + string(8) "one more" + ["var3"]=> + string(16) "and the last one" +} +array(1) { + ["var1"]=> + string(4) "test" +} +array(0) { +} +Done diff --git a/ext/standard/tests/array/locale_sort.phpt b/ext/standard/tests/array/locale_sort.phpt index b4e15fa52..4b7068fa8 100644 --- a/ext/standard/tests/array/locale_sort.phpt +++ b/ext/standard/tests/array/locale_sort.phpt @@ -2,13 +2,13 @@ Sort with SORT_LOCALE_STRING --SKIPIF-- <?php -if ("fr_FR" != setlocale(LC_CTYPE, "fr_FR")) { +if (false == setlocale(LC_CTYPE, "fr_FR", "fr_FR.ISO8859-1")) { die("skip setlocale() failed\n"); } ?> --FILE-- <?php -setlocale(LC_ALL, 'fr_FR'); +setlocale(LC_ALL, 'fr_FR', 'fr_FR.ISO8859-1'); $table = array("AB" => "Alberta", "BC" => "Colombie-Britannique", "MB" => "Manitoba", diff --git a/ext/standard/tests/assert/assert02.phpt b/ext/standard/tests/assert/assert02.phpt index 88a1e1242..ac0824cda 100644 --- a/ext/standard/tests/assert/assert02.phpt +++ b/ext/standard/tests/assert/assert02.phpt @@ -31,12 +31,12 @@ Warning: assert(): Assertion "$a" failed in %sassert02.php on line %d Parse error: %s error%sassert02.php(%d) : assert code on line 1 in handler() -string(64) "assert(): Failure evaluating code: +string(%d) "assert(): Failure evaluating code: aa=sd+as+safsafasfaçsafçsafç" Warning: assert(): Assertion "0" failed in %sassert02.php on line %d Parse error: %s error%sassert02.php(%d) : assert code on line 1 in handler() -string(64) "assert(): Failure evaluating code: +string(%d) "assert(): Failure evaluating code: aa=sd+as+safsafasfaçsafçsafç" diff --git a/ext/standard/tests/assert/assert03.phpt b/ext/standard/tests/assert/assert03.phpt new file mode 100644 index 000000000..077474d4d --- /dev/null +++ b/ext/standard/tests/assert/assert03.phpt @@ -0,0 +1,33 @@ +--TEST-- +assert() - set callback using ini_set() +--FILE-- +<?php +function a($file,$line,$myev) +{ + echo "assertion failed - a - $line,\"$myev\"\n"; +} + +function b($file,$line,$myev) +{ + echo "assertion failed - b - $line,\"$myev\"\n"; +} + +assert_options(ASSERT_ACTIVE,1); +assert_options(ASSERT_QUIET_EVAL,1); +assert_options(ASSERT_WARNING,0); + +$a = 0; + +assert_options(ASSERT_CALLBACK,"a"); +assert('$a != 0'); + + /* Modify call back using ini_set() */ +ini_set("assert.callback", "b"); +assert('$a != 0'); + +?> +==DONE== +--EXPECTF-- +assertion failed - a - %d,"$a != 0" +assertion failed - b - %d,"$a != 0" +==DONE== diff --git a/ext/standard/tests/assert/assert04.phpt b/ext/standard/tests/assert/assert04.phpt new file mode 100644 index 000000000..43028ad3a --- /dev/null +++ b/ext/standard/tests/assert/assert04.phpt @@ -0,0 +1,41 @@ +--TEST-- +misc assert() tests tests +--FILE-- +<?php +/* Assert not active */ +assert_options(ASSERT_ACTIVE, 0); +assert(1); + + +/* Wrong parameter count in assert */ +assert_options(ASSERT_ACTIVE, 1); +assert(2,3); + +/* Wrong parameter count in assert_options */ +assert_options(ASSERT_ACTIVE, 0, 2); + +/* Wrong parameter name in assert_options */ +$test="ASSERT_FRED"; +assert_options($test, 1); + +/* Assert false */ +assert(0); + + +/* Assert false and bail*/ +assert_options(ASSERT_BAIL, 1); +assert(0); + +echo "not reached\n"; + +?> +--EXPECTF-- +Warning: Wrong parameter count for assert() in %s on line %d + +Warning: Wrong parameter count for assert_options() in %s on line %d + +Warning: assert_options(): Unknown value 0 in %s on line %d + +Warning: assert(): Assertion failed in %s on line %d + +Warning: assert(): Assertion failed in %s on line %d diff --git a/ext/standard/tests/file/bug22414.phpt b/ext/standard/tests/file/bug22414.phpt index 0775fc8a7..b60b865e7 100644 --- a/ext/standard/tests/file/bug22414.phpt +++ b/ext/standard/tests/file/bug22414.phpt @@ -16,8 +16,13 @@ output_handler= /* Binary Data Test */ - $cmd = $php . ' -n -r \"readfile(@getenv(\'TEST_PHP_EXECUTABLE\')); \"'; - $cmd = $php . ' -n -r \' passthru("'.$cmd.'"); \' > '.$tmpfile ; + if (substr(PHP_OS, 0, 3) != 'WIN') { + $cmd = $php . ' -n -r \"readfile(@getenv(\'TEST_PHP_EXECUTABLE\')); \"'; + $cmd = $php . ' -n -r \' passthru("'.$cmd.'"); \' > '.$tmpfile ; + } else { + $cmd = $php . ' -n -r \"readfile(@getenv(\\\\\\"TEST_PHP_EXECUTABLE\\\\\\")); \"'; + $cmd = $php . ' -n -r " passthru(\''.$cmd.'\');" > '.$tmpfile ; + } exec($cmd); if (md5_file($php) == md5_file($tmpfile)) { diff --git a/ext/standard/tests/file/bug24313.phpt b/ext/standard/tests/file/bug24313.phpt index 04057c58a..e5bceee85 100644 --- a/ext/standard/tests/file/bug24313.phpt +++ b/ext/standard/tests/file/bug24313.phpt @@ -1,5 +1,11 @@ --TEST-- Bug #24313 (file_exists() throws a warning on nonexistent files when is open_basedir enabled) +--SKIPIF-- +<?php +if (substr(PHP_OS, 0, 3) == 'WIN') { + die('skip "/dev" is not available'); +} +?> --INI-- open_basedir=/dev --FILE-- diff --git a/ext/standard/tests/file/bug26615.phpt b/ext/standard/tests/file/bug26615.phpt index 34d71e4b3..4de8b4a46 100644 --- a/ext/standard/tests/file/bug26615.phpt +++ b/ext/standard/tests/file/bug26615.phpt @@ -6,7 +6,11 @@ variables_order=E <?php $out = array(); $status = -1; -exec($_ENV['TEST_PHP_EXECUTABLE'].' -r \'for($i=1;$i<=5000;$i++) print "$i\n";\' | tr \'\n\' \' \'', $out, $status); +if (substr(PHP_OS, 0, 3) != 'WIN') { + exec($_ENV['TEST_PHP_EXECUTABLE'].' -r \'for($i=1;$i<=5000;$i++) print "$i\n";\' | tr \'\n\' \' \'', $out, $status); +} else { + exec($_ENV['TEST_PHP_EXECUTABLE'].' -r "for($i=1;$i<=5000;$i++) echo $i,\' \';"', $out, $status); +} print_r($out); ?> --EXPECT-- diff --git a/ext/standard/tests/file/bug26938.phpt b/ext/standard/tests/file/bug26938.phpt index 8e059ee84..c43e6b103 100644 --- a/ext/standard/tests/file/bug26938.phpt +++ b/ext/standard/tests/file/bug26938.phpt @@ -5,12 +5,21 @@ Bug #26938 (exec does not read consecutive long lines correctly) $out = array(); $status = -1; $php = getenv('TEST_PHP_EXECUTABLE'); -exec($php . ' -r \'' - . '$lengths = array(10,20000,10000,5,10000,3);' - . 'foreach($lengths as $length) {' - . ' for($i=0;$i<$length;$i++) print chr(65+$i % 27);' - . ' print "\n";' - . '}\'', $out, $status); +if (substr(PHP_OS, 0, 3) != 'WIN') { + exec($php . ' -r \'' + . '$lengths = array(10,20000,10000,5,10000,3);' + . 'foreach($lengths as $length) {' + . ' for($i=0;$i<$length;$i++) print chr(65+$i % 27);' + . ' print "\n";' + . '}\'', $out, $status); +} else { + exec($php . ' -r "' + . '$lengths = array(10,20000,10000,5,10000,3);' + . 'foreach($lengths as $length) {' + . ' for($i=0;$i<$length;$i++) print chr(65+$i % 27);' + . ' print \\"\\n\\";' + . '}"', $out, $status); +} for ($i=0;$i<6;$i++) print "md5(line $i)= " . md5($out[$i]) . " (length " . strlen($out[$i]) . ")\n"; diff --git a/ext/standard/tests/file/bug27508.phpt b/ext/standard/tests/file/bug27508.phpt index 5374a0dcb..cc46a3e3e 100644 --- a/ext/standard/tests/file/bug27508.phpt +++ b/ext/standard/tests/file/bug27508.phpt @@ -54,12 +54,13 @@ debug_zval_dump(feof($fp)); rewind($fp); echo ftell($fp) . "\n"; debug_zval_dump(feof($fp)); -while (!feof($fp)) { +while ($fp && !feof($fp)) { echo fgets($fp); } fclose($fp); unlink($tn); +?> --EXPECT-- bool(false) refcount(1) 0 diff --git a/ext/standard/tests/file/bug35740.phpt b/ext/standard/tests/file/bug35740.phpt index 78df1843c..3526b2497 100644 --- a/ext/standard/tests/file/bug35740.phpt +++ b/ext/standard/tests/file/bug35740.phpt @@ -1,5 +1,5 @@ --TEST-- -bug #35740 (memory leak when including a directory) +Bug #35740 (memory leak when including a directory) --FILE-- <?php diff --git a/ext/standard/tests/file/bug39367.phpt b/ext/standard/tests/file/bug39367.phpt new file mode 100755 index 000000000..01fb5e8c8 --- /dev/null +++ b/ext/standard/tests/file/bug39367.phpt @@ -0,0 +1,33 @@ +--TEST-- +Bug #39367 (clearstatcache() doesn't clear realpath cache) +--SKIPIF-- +<?php +if (substr(PHP_OS, 0, 3) == 'WIN') { + die('skip no symlinks on Windows'); +} +?> +--FILE-- +<?php +function test() { + unlink('/tmp/1link'); + unlink('/tmp/1tmp'); + unlink('/tmp/testfile1'); + + file_put_contents('/tmp/testfile1', 'ok'); + symlink('/tmp/testfile1', '/tmp/1tmp'); + rename('/tmp/1tmp', '/tmp/1link'); + echo file_get_contents('/tmp/1link')."\n"; + + unlink('/tmp/1link'); + clearstatcache(); + + echo file_get_contents('/tmp/1link')."\n"; + + unlink('/tmp/1link'); + unlink('/tmp/1tmp'); + unlink('/tmp/testfile1'); +} +@test(); +?> +--EXPECT-- +ok diff --git a/ext/standard/tests/file/bug39538.phpt b/ext/standard/tests/file/bug39538.phpt new file mode 100644 index 000000000..1724a7247 --- /dev/null +++ b/ext/standard/tests/file/bug39538.phpt @@ -0,0 +1,39 @@ +--TEST-- +Bug #39538 (fgetcsv can't handle starting newlines and trailing odd number of backslashes) +--FILE-- +<?php +$content = array("\"\nthis is an test\", \"next data\", \"p\narsed\"","\"\r\nthis is an test\", \"next data\", \"p\r\narsed\"","\"\n\rthis is an test\", \"next data\", \"p\n\rarsed\""); + +$file = dirname(__FILE__) . "/bug39538.csv"; +@unlink($file); +foreach ($content as $v) { + file_put_contents($file, $v); + print_r (fgetcsv(fopen($file, "r"), filesize($file))); +} +@unlink($file); +?> +--EXPECT-- +Array +( + [0] => +this is an test + [1] => next data + [2] => p +arsed +) +Array +( + [0] =>
+this is an test + [1] => next data + [2] => p
+arsed +) +Array +( + [0] => +
this is an test + [1] => next data + [2] => p +
arsed +) diff --git a/ext/standard/tests/file/bug39551.phpt b/ext/standard/tests/file/bug39551.phpt new file mode 100644 index 000000000..67dc7e7b2 --- /dev/null +++ b/ext/standard/tests/file/bug39551.phpt @@ -0,0 +1,28 @@ +--TEST-- +Bug #39551 (Segfault with stream_bucket_new in user filter) +--FILE-- +<?php + +$bucket = stream_bucket_new(fopen('php://temp', 'w+'), ''); + +class bucketFilter { + public function filter($in, $out, &$consumed, $closing ){ + + $bucket = stream_bucket_new(fopen('php://temp', 'w+'), ''); + stream_bucket_append($out, $bucket); + return PSFS_PASS_ON; + } +} + +stream_filter_register('bucketfault', 'bucketFilter'); +stream_filter_append($s = fopen('php://temp', 'r+'), 'bucketfault'); +stream_get_contents($s); + +echo "Done\n"; +?> +--EXPECTF-- +Done +--UEXPECTF-- +Done + +Notice: Unknown: 0 character unicode buffer downcoded for binary stream runtime_encoding in Unknown on line 0 diff --git a/ext/standard/tests/file/bug39673.phpt b/ext/standard/tests/file/bug39673.phpt new file mode 100644 index 000000000..3836f2103 --- /dev/null +++ b/ext/standard/tests/file/bug39673.phpt @@ -0,0 +1,40 @@ +--TEST-- +Bug #39673 (file_get_contents causes bus error on certain offsets) +--FILE-- +<?php + +$str = str_repeat("test", 3456); + +$filename = dirname(__FILE__).'/bug39673.txt'; +file_put_contents($filename, $str); + +$offsets = array( + -1, + 0, + 3456*4, + 3456*4 - 1, + 3456*4 + 1, + 2000, + 5000, + 100000, +); + + +foreach ($offsets as $offset) { + $r = file_get_contents($filename, false, null, $offset); + var_dump(strlen($r)); +} + +@unlink($filename); +echo "Done\n"; +?> +--EXPECTF-- +int(13824) +int(13824) +int(0) +int(1) +int(0) +int(11824) +int(8824) +int(0) +Done diff --git a/ext/standard/tests/file/bug40374.phpt b/ext/standard/tests/file/bug40374.phpt new file mode 100644 index 000000000..2be48008d --- /dev/null +++ b/ext/standard/tests/file/bug40374.phpt @@ -0,0 +1,17 @@ +--TEST-- +Bug #40374 (php_shutdown_temporary_directory() tries to free local value) +--FILE-- +<?php + +$file = tempnam(sys_get_temp_dir(), "test_"); +var_dump($file); +$fp = fopen($file, "w"); +fwrite($fp, "test"); +fclose($fp); +unlink($file); + +echo "Done\n"; +?> +--EXPECTF-- +string(%d) "%s" +Done diff --git a/ext/standard/tests/file/disk.phpt b/ext/standard/tests/file/disk.phpt new file mode 100644 index 000000000..6eef4b4a7 --- /dev/null +++ b/ext/standard/tests/file/disk.phpt @@ -0,0 +1,48 @@ +--TEST-- +disk_total_space() and disk_free_space() tests +--INI-- +precision=14 +--SKIPIF-- +<?php +if (substr(PHP_OS, 0, 3) == 'WIN') { + die('skip not for Windows'); +} +?> +--FILE-- +<?php + +var_dump(disk_free_space()); +var_dump(disk_total_space()); + +var_dump(disk_free_space(-1)); +var_dump(disk_total_space(-1)); + +var_dump(disk_free_space("/")); +var_dump(disk_total_space("/")); + +var_dump(disk_free_space("/some/path/here")); +var_dump(disk_total_space("/some/path/here")); + +echo "Done\n"; +?> +--EXPECTF-- +Warning: disk_free_space() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +Warning: disk_total_space() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +Warning: disk_free_space(): No such file or directory in %s on line %d +bool(false) + +Warning: disk_total_space(): No such file or directory in %s on line %d +bool(false) +float(%d) +float(%d) + +Warning: disk_free_space(): No such file or directory in %s on line %d +bool(false) + +Warning: disk_total_space(): No such file or directory in %s on line %d +bool(false) +Done diff --git a/ext/standard/tests/file/fgetss.phpt b/ext/standard/tests/file/fgetss.phpt new file mode 100644 index 000000000..b4ac21167 --- /dev/null +++ b/ext/standard/tests/file/fgetss.phpt @@ -0,0 +1,83 @@ +--TEST-- +fgetss() tests +--FILE-- +<?php + +$filename = dirname(__FILE__)."/fgetss.html"; + +$array = array( + "askasdfasdf<b>aaaaaa\n</b>dddddd", + "asdqw<i onClick=\"hello();\">\naaaa<>qqqq", + "aaa<script>function foo() {}</script>qqq", + "asdasd<a\n asdjeje", + "", + "some text \n<b>blah</i>", + "some another text <> hoho </>" + ); + +foreach ($array as $str) { + file_put_contents($filename, $str); + $fp = fopen($filename, "r"); + var_dump(fgetss($fp)); + var_dump(fgetss($fp)); +} + +foreach ($array as $str) { + file_put_contents($filename, $str); + $fp = fopen($filename, "r"); + var_dump(fgetss($fp, 10)); + var_dump(fgetss($fp, 10)); +} + +var_dump(fgetss($fp, -10)); +var_dump(fgetss($fp, 0)); +fclose($fp); +var_dump(fgetss($fp, 0)); + +@unlink($filename); + +echo "Done\n"; +?> +--EXPECTF-- +string(18) "askasdfasdfaaaaaa +" +string(6) "dddddd" +string(6) "asdqw +" +string(8) "aaaaqqqq" +string(23) "aaafunction foo() {}qqq" +bool(false) +string(6) "asdasd" +string(0) "" +bool(false) +bool(false) +string(11) "some text +" +string(4) "blah" +string(24) "some another text hoho " +bool(false) +string(9) "askasdfas" +string(6) "dfaaaa" +string(5) "asdqw" +string(0) "" +string(3) "aaa" +string(7) "functio" +string(6) "asdasd" +string(0) "" +bool(false) +bool(false) +string(9) "some text" +string(2) " +" +string(9) "some anot" +string(9) "her text " + +Warning: fgetss(): Length parameter must be greater than 0 in %s on line %d +bool(false) + +Warning: fgetss(): Length parameter must be greater than 0 in %s on line %d +bool(false) + +Warning: fgetss(): %d is not a valid stream resource in %s on line %d +bool(false) +Done diff --git a/ext/standard/tests/file/fgetss1.phpt b/ext/standard/tests/file/fgetss1.phpt new file mode 100644 index 000000000..96b8b6f53 --- /dev/null +++ b/ext/standard/tests/file/fgetss1.phpt @@ -0,0 +1,69 @@ +--TEST-- +more fgetss() tests +--FILE-- +<?php + +$filename = dirname(__FILE__)."/fgetss1.html"; + +$array = array( + "askasdfasdf<b>aaaaaa\n</b>dddddd", + "asdqw<i onClick=\"hello();\">\naaaa<>qqqq", + "aaa<script>function foo() {}</script>qqq", + "asdasd<a\n asdjeje", + "", + "some text \n<b>blah</i>", + "some another text <> hoho </>" + ); + +foreach ($array as $str) { + file_put_contents($filename, $str); + $fp = fopen($filename, "r"); + var_dump(fgetss($fp, 1000, "<i>,<b>,<a>")); + var_dump(fgetss($fp)); +} + +foreach ($array as $str) { + file_put_contents($filename, $str); + $fp = fopen($filename, "r"); + var_dump(fgetss($fp, 10)); + var_dump(fgetss($fp, 10, "<script>,<a>")); +} + +@unlink($filename); + +echo "Done\n"; +?> +--EXPECTF-- +string(21) "askasdfasdf<b>aaaaaa +" +string(6) "dddddd" +string(28) "asdqw<i onClick="hello();"> +" +string(8) "aaaaqqqq" +string(23) "aaafunction foo() {}qqq" +bool(false) +string(6) "asdasd" +string(0) "" +bool(false) +bool(false) +string(11) "some text +" +string(4) "blah" +string(24) "some another text hoho " +bool(false) +string(9) "askasdfas" +string(6) "dfaaaa" +string(5) "asdqw" +string(0) "" +string(3) "aaa" +string(9) "t>functio" +string(6) "asdasd" +string(0) "" +bool(false) +bool(false) +string(9) "some text" +string(2) " +" +string(9) "some anot" +string(9) "her text " +Done diff --git a/ext/standard/tests/file/file_put_contents.phpt b/ext/standard/tests/file/file_put_contents.phpt index de08141b8..4566c3756 100644 --- a/ext/standard/tests/file/file_put_contents.phpt +++ b/ext/standard/tests/file/file_put_contents.phpt @@ -2,13 +2,18 @@ file_put_contents() and invalid parameters --FILE-- <?php - +class foo { + function __toString() { + return __METHOD__; + } +} $file = dirname(__FILE__)."/file_put_contents.txt"; $context = stream_context_create(); var_dump(file_put_contents($file, $context)); var_dump(file_put_contents($file, new stdClass)); +var_dump(file_put_contents($file, new foo)); $fp = fopen($file, "r"); var_dump(file_put_contents($file, "string", 0, $fp)); @@ -19,9 +24,8 @@ echo "Done\n"; --EXPECTF-- Warning: file_put_contents(): supplied resource is not a valid stream resource in %s on line %d bool(false) - -Warning: file_put_contents(): The 2nd parameter should be either a string or an array in %s on line %d bool(false) +int(15) Warning: file_put_contents(): supplied resource is not a valid Stream-Context resource in %s on line %d int(6) diff --git a/ext/standard/tests/file/filestat.phpt b/ext/standard/tests/file/filestat.phpt new file mode 100644 index 000000000..d02f9f2a1 --- /dev/null +++ b/ext/standard/tests/file/filestat.phpt @@ -0,0 +1,63 @@ +--TEST-- +various file stat func tests +--FILE-- +<?php + +var_dump(fileinode(".")); +var_dump(fileowner(".")); +var_dump(filegroup(".")); +var_dump(fileatime(".")); +var_dump(filectime(".")); + +var_dump(fileinode("./..")); +var_dump(fileowner("./..")); +var_dump(filegroup("./..")); +var_dump(fileatime("./..")); +var_dump(filectime("./..")); + +var_dump(fileinode(__FILE__)); +var_dump(fileowner(__FILE__)); +var_dump(filegroup(__FILE__)); +var_dump(fileatime(__FILE__)); +var_dump(filectime(__FILE__)); + +var_dump(fileinode("/no/such/file/or/dir")); +var_dump(fileowner("/no/such/file/or/dir")); +var_dump(filegroup("/no/such/file/or/dir")); +var_dump(fileatime("/no/such/file/or/dir")); +var_dump(filectime("/no/such/file/or/dir")); + +echo "Done\n"; +?> +--EXPECTF-- +int(%d) +int(%d) +int(%d) +int(%d) +int(%d) +int(%d) +int(%d) +int(%d) +int(%d) +int(%d) +int(%d) +int(%d) +int(%d) +int(%d) +int(%d) + +Warning: fileinode(): stat failed for /no/such/file/or/dir in %s on line %d +bool(false) + +Warning: fileowner(): stat failed for /no/such/file/or/dir in %s on line %d +bool(false) + +Warning: filegroup(): stat failed for /no/such/file/or/dir in %s on line %d +bool(false) + +Warning: fileatime(): stat failed for /no/such/file/or/dir in %s on line %d +bool(false) + +Warning: filectime(): stat failed for /no/such/file/or/dir in %s on line %d +bool(false) +Done diff --git a/ext/standard/tests/file/flock.phpt b/ext/standard/tests/file/flock.phpt new file mode 100644 index 000000000..efc059cff --- /dev/null +++ b/ext/standard/tests/file/flock.phpt @@ -0,0 +1,64 @@ +--TEST-- +flock() tests +--FILE-- +<?php + +$file = dirname(__FILE__)."/flock.dat"; + +var_dump(flock()); +var_dump(flock("", "", $var)); + +$fp = fopen($file, "w"); +fclose($fp); + +var_dump(flock($fp, LOCK_SH|LOCK_NB)); + +$fp = fopen($file, "w"); + +var_dump(flock($fp, LOCK_SH|LOCK_NB)); +var_dump(flock($fp, LOCK_UN)); +var_dump(flock($fp, LOCK_EX)); +var_dump(flock($fp, LOCK_UN)); + +$would = array(1,2,3); +var_dump(flock($fp, LOCK_SH|LOCK_NB, $would)); +var_dump($would); +var_dump(flock($fp, LOCK_UN, $would)); +var_dump($would); +var_dump(flock($fp, LOCK_EX, $would)); +var_dump($would); +var_dump(flock($fp, LOCK_UN, $would)); +var_dump($would); + +var_dump(flock($fp, -1)); +var_dump(flock($fp, 0)); + +@unlink($file); +echo "Done\n"; +?> +--EXPECTF-- +Warning: flock() expects at least 2 parameters, 0 given in %s on line %d +NULL + +Warning: flock() expects parameter 1 to be resource, string given in %s on line %d +NULL + +Warning: flock(): %d is not a valid stream resource in %s on line %d +bool(false) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +int(0) +bool(true) +int(0) +bool(true) +int(0) +bool(true) +int(0) +bool(true) + +Warning: flock(): Illegal operation argument in %s on line %d +bool(false) +Done diff --git a/ext/standard/tests/file/fscanf.phpt b/ext/standard/tests/file/fscanf.phpt new file mode 100644 index 000000000..67bd8ee10 --- /dev/null +++ b/ext/standard/tests/file/fscanf.phpt @@ -0,0 +1,100 @@ +--TEST-- +fscanf() tests +--FILE-- +<?php + +$filename = dirname(__FILE__)."/fscanf.dat"; + +var_dump(fscanf()); +var_dump(fscanf(array())); +var_dump(fscanf(array(), array(), new stdclass)); + +file_put_contents($filename, "data"); + +$fp = fopen($filename, "r"); +var_dump(fscanf($fp, "%d", $v)); +var_dump($v); +fclose($fp); + +$fp = fopen($filename, "r"); +var_dump(fscanf($fp, "%s", $v)); +var_dump($v); +fclose($fp); + +$fp = fopen($filename, "r"); +var_dump(fscanf($fp, "%s", $v, $v1)); +var_dump($v); +var_dump($v1); +fclose($fp); + +$v = array(); +$v1 = array(); +$fp = fopen($filename, "r"); +var_dump(fscanf($fp, "", $v, $v1)); +var_dump($v); +var_dump($v1); +fclose($fp); + +$v = array(); +$v1 = array(); +$fp = fopen($filename, "r"); +var_dump(fscanf($fp, "%.a", $v, $v1)); +var_dump($v); +var_dump($v1); +fclose($fp); + +@unlink($filename); +touch($filename); + +$fp = fopen($filename, "r"); +var_dump(fscanf($fp, "%s", $v)); +var_dump($v); +fclose($fp); + +file_put_contents($filename, "data"); + +$fp = fopen($filename, "r"); +var_dump(fscanf($fp, "%s%d", $v)); + +@unlink($filename); +echo "Done\n"; +?> +--EXPECTF-- +Warning: Wrong parameter count for fscanf() in %s on line %d +NULL + +Warning: Wrong parameter count for fscanf() in %s on line %d +NULL + +Warning: fscanf(): supplied argument is not a valid File-Handle resource in %s on line %d +bool(false) +int(0) +NULL +int(1) +string(4) "data" + +Warning: fscanf(): Variable is not assigned by any conversion specifiers in %s on line %d +int(-1) +string(4) "data" +NULL + +Warning: fscanf(): Variable is not assigned by any conversion specifiers in %s on line %d +int(-1) +array(0) { +} +array(0) { +} + +Warning: fscanf(): Bad scan conversion character "." in %s on line %d +int(-1) +array(0) { +} +array(0) { +} +bool(false) +array(0) { +} + +Warning: fscanf(): Different numbers of variable names and field specifiers in %s on line %d +int(-1) +Done diff --git a/ext/standard/tests/file/fstat.phpt b/ext/standard/tests/file/fstat.phpt new file mode 100644 index 000000000..e1ae3e20b --- /dev/null +++ b/ext/standard/tests/file/fstat.phpt @@ -0,0 +1,74 @@ +--TEST-- +fstat() tests +--FILE-- +<?php + +$filename = dirname(__FILE__)."/fstat.dat"; + +$fp = fopen($filename, "w"); +var_dump(fstat($fp)); +fclose($fp); +var_dump(fstat($fp)); + +@unlink($filename); +echo "Done\n"; +?> +--EXPECTF-- +array(26) { + [0]=> + int(%i) + [1]=> + int(%i) + [2]=> + int(%i) + [3]=> + int(%i) + [4]=> + int(%i) + [5]=> + int(%i) + [6]=> + int(%i) + [7]=> + int(%i) + [8]=> + int(%i) + [9]=> + int(%i) + [10]=> + int(%i) + [11]=> + int(%i) + [12]=> + int(%i) + ["dev"]=> + int(%i) + ["ino"]=> + int(%i) + ["mode"]=> + int(%i) + ["nlink"]=> + int(%i) + ["uid"]=> + int(%i) + ["gid"]=> + int(%i) + ["rdev"]=> + int(%i) + ["size"]=> + int(%i) + ["atime"]=> + int(%i) + ["mtime"]=> + int(%i) + ["ctime"]=> + int(%i) + ["blksize"]=> + int(%i) + ["blocks"]=> + int(%i) +} + +Warning: fstat(): %d is not a valid stream resource in %s on line %d +bool(false) +Done diff --git a/ext/standard/tests/file/ftruncate.phpt b/ext/standard/tests/file/ftruncate.phpt Binary files differnew file mode 100644 index 000000000..8954ef12f --- /dev/null +++ b/ext/standard/tests/file/ftruncate.phpt diff --git a/ext/standard/tests/file/fwrite.phpt b/ext/standard/tests/file/fwrite.phpt new file mode 100644 index 000000000..ba9b5013f --- /dev/null +++ b/ext/standard/tests/file/fwrite.phpt @@ -0,0 +1,50 @@ +--TEST-- +fwrite() tests +--FILE-- +<?php + +$filename = dirname(__FILE__)."/fwrite.dat"; + +$fp = fopen($filename, "w"); +var_dump(fwrite($fp)); +var_dump(fwrite($fp, array())); +fclose($fp); + +$fp = fopen($filename, "r"); +var_dump(fwrite($fp, "data")); + +$fp = fopen($filename, "w"); +var_dump(fwrite($fp, "data", -1)); +var_dump(fwrite($fp, "data", 100000)); +fclose($fp); + +var_dump(fwrite($fp, "data", -1)); + +var_dump(fwrite(array(), "data", -1)); +var_dump(fwrite(array(), "data")); +var_dump(fwrite(array())); + +var_dump(file_get_contents($filename)); + +@unlink($filename); +echo "Done\n"; +?> +--EXPECTF-- +Warning: Wrong parameter count for fwrite() in %s on line %d +NULL + +Notice: Array to string conversion in %s on line %d +int(5) +int(0) +int(0) +int(4) +int(0) +int(0) + +Warning: fwrite(): supplied argument is not a valid stream resource in %s on line %d +bool(false) + +Warning: Wrong parameter count for fwrite() in %s on line %d +NULL +string(4) "data" +Done diff --git a/ext/standard/tests/file/get_current_user.phpt b/ext/standard/tests/file/get_current_user.phpt new file mode 100644 index 000000000..7c721303d --- /dev/null +++ b/ext/standard/tests/file/get_current_user.phpt @@ -0,0 +1,15 @@ +--TEST-- +get_current_user() tests +--FILE-- +<?php + +var_dump(get_current_user("blah")); +var_dump(get_current_user()); + +echo "Done\n"; +?> +--EXPECTF-- +Warning: Wrong parameter count for get_current_user() in %s on line %d +NULL +string(%d) %s +Done diff --git a/ext/standard/tests/file/magic_quotes.phpt b/ext/standard/tests/file/magic_quotes.phpt new file mode 100644 index 000000000..4956f63aa --- /dev/null +++ b/ext/standard/tests/file/magic_quotes.phpt @@ -0,0 +1,61 @@ +--TEST-- +various magic quotes tests +--FILE-- +<?php + +$filename = dirname(__FILE__)."/magic_quotes.dat"; + +var_dump(get_magic_quotes_runtime()); +var_dump(get_magic_quotes_runtime("blah")); + +file_put_contents($filename, "some'content'here\"and}there"); + +var_dump(set_magic_quotes_runtime(true)); +var_dump(get_magic_quotes_runtime()); +var_dump(set_magic_quotes_runtime(-1)); +var_dump(get_magic_quotes_runtime()); + +var_dump(file_get_contents($filename)); + +var_dump(set_magic_quotes_runtime(0)); +var_dump(get_magic_quotes_runtime()); + +var_dump(file_get_contents($filename)); + +var_dump(set_magic_quotes_runtime(1)); +var_dump(get_magic_quotes_runtime()); + +file_put_contents($filename, "some'content'here\"and}there"); + +var_dump(file_get_contents($filename)); + +var_dump(set_magic_quotes_runtime(0)); +var_dump(set_magic_quotes_runtime()); +var_dump(get_magic_quotes_runtime()); + +var_dump(file_get_contents($filename)); + + +@unlink($filename); + +echo "Done\n"; +?> +--EXPECTF-- +int(0) +int(0) +bool(true) +int(1) +bool(true) +int(1) +string(30) "some\'content\'here\"and}there" +bool(true) +int(0) +string(27) "some'content'here"and}there" +bool(true) +int(1) +string(30) "some\'content\'here\"and}there" +bool(true) +bool(false) +int(0) +string(27) "some'content'here"and}there" +Done diff --git a/ext/standard/tests/file/mkdir-002.phpt b/ext/standard/tests/file/mkdir-002.phpt index bc4f19aca..ccfd6c3d7 100644 --- a/ext/standard/tests/file/mkdir-002.phpt +++ b/ext/standard/tests/file/mkdir-002.phpt @@ -1,5 +1,11 @@ --TEST-- mkdir(dir, 0777) tests +--SKIPIF-- +<?php +if (substr(PHP_OS, 0, 3) == 'WIN') { + die('skip no symlinks on Windows'); +} +?> --FILE-- <?php diff --git a/ext/standard/tests/file/mkdir-006.phpt b/ext/standard/tests/file/mkdir-006.phpt index 5bfa8e814..9fcb92802 100644 --- a/ext/standard/tests/file/mkdir-006.phpt +++ b/ext/standard/tests/file/mkdir-006.phpt @@ -1,11 +1,5 @@ --TEST-- recursive mkdir() with unclean paths ---SKIPIF-- -<?php -if (substr(PHP_OS, 0, 3) != 'WIN') { - die('skip only for Windows'); -} -?> --FILE-- <?php chdir(dirname(__FILE__)); diff --git a/ext/standard/tests/file/proc_open01.phpt b/ext/standard/tests/file/proc_open01.phpt index c5b0ed971..2c211f616 100644 --- a/ext/standard/tests/file/proc_open01.phpt +++ b/ext/standard/tests/file/proc_open01.phpt @@ -32,7 +32,7 @@ for ($left = strlen($test_string); $left > 0;) { $read_fds = array($pipes[1]); $write_fds = NULL; $exp_fds = NULL; - $retval = stream_select($read_fds, $write_fds, $exp_fds, 1); + $retval = stream_select($read_fds, $write_fds, $exp_fds, 5); if ($retval === false) { print "select() failed\n"; break; diff --git a/ext/standard/tests/file/statpage.phpt b/ext/standard/tests/file/statpage.phpt new file mode 100644 index 000000000..f11be9734 --- /dev/null +++ b/ext/standard/tests/file/statpage.phpt @@ -0,0 +1,20 @@ +--TEST-- +getlastmod() and others +--FILE-- +<?php + +var_dump(getlastmod()); +var_dump(getmyinode()); +var_dump(getmyuid()); +var_dump(getmypid()); +var_dump(getmygid()); + +echo "Done\n"; +?> +--EXPECTF-- +int(%d) +int(%d) +int(%d) +int(%d) +int(%d) +Done diff --git a/ext/standard/tests/file/stream_001.phpt b/ext/standard/tests/file/stream_001.phpt index 8a3f03409..6df43471e 100644 --- a/ext/standard/tests/file/stream_001.phpt +++ b/ext/standard/tests/file/stream_001.phpt @@ -17,7 +17,7 @@ Notice: fopen(): Unable to find the wrapper "file" - did you forget to enable it Warning: fopen(): Plainfiles wrapper disabled in %s on line %d -Warning: fopen(file:///%s): failed to open stream: no suitable wrapper could be found in %s on line %d +Warning: fopen(file://%s): failed to open stream: no suitable wrapper could be found in %s on line %d bool(false) bool(true) resource(%d) of type (stream) diff --git a/ext/standard/tests/file/stream_002.phpt b/ext/standard/tests/file/stream_002.phpt index ae10abf2d..e982f704c 100644 --- a/ext/standard/tests/file/stream_002.phpt +++ b/ext/standard/tests/file/stream_002.phpt @@ -31,10 +31,10 @@ bool(false) int(0) string(27) "Failed to parse address "["" -Warning: stream_socket_client(): unable to connect to [ (Failed to parse IPv6 address "[ ") in %s on line %d +Warning: stream_socket_client(): unable to connect to [ (Failed to parse%saddress "[ ") in %s on line %d bool(false) int(0) -string(33) "Failed to parse IPv6 address "[ "" +string(%d) "Failed to parse%saddress "[ "" Warning: stream_socket_client(): unable to connect to . (Failed to parse address ".") in %s on line %d bool(false) diff --git a/ext/standard/tests/file/symlink.phpt b/ext/standard/tests/file/symlink.phpt new file mode 100644 index 000000000..489c26644 --- /dev/null +++ b/ext/standard/tests/file/symlink.phpt @@ -0,0 +1,78 @@ +--TEST-- +symlink() & friends +--SKIPIF-- +<?php +if (substr(PHP_OS, 0, 3) == 'WIN') { + die('skip no symlinks on Windows'); +} +?> +--FILE-- +<?php + +$filename = dirname(__FILE__)."/symlink.dat"; +$link = dirname(__FILE__)."/symlink.link"; + +var_dump(symlink($filename, $link)); +var_dump(readlink($link)); +var_dump(linkinfo($link)); +@unlink($link); + +var_dump(readlink($link)); +var_dump(linkinfo($link)); + +touch($filename); +var_dump(symlink($filename, dirname(__FILE__))); +@unlink($link); + +var_dump(symlink($filename, $link)); +@unlink($link); + +touch($link); +var_dump(symlink($filename, $link)); +@unlink($link); + +var_dump(link($filename, $link)); +@unlink($filename); + +var_dump(link($filename, $link)); +@unlink($link); + +var_dump(symlink(".", ".")); +var_dump(link(".", ".")); +var_dump(readlink(".")); +var_dump(linkinfo(".")); + +echo "Done\n"; +?> +--EXPECTF-- +bool(true) +string(%d) "%ssymlink.dat" +int(%d) + +Warning: readlink(): No such file or directory in %s on line %d +bool(false) + +Warning: linkinfo(): No such file or directory in %s on line %d +int(-1) + +Warning: symlink(): File exists in %s on line %d +bool(false) +bool(true) + +Warning: symlink(): File exists in %s on line %d +bool(false) +bool(true) + +Warning: link(): No such file or directory in %s on line %d +bool(false) + +Warning: symlink(): %s in %s on line %d +bool(false) + +Warning: link(): %s in %s on line %d +bool(false) + +Warning: readlink(): Invalid argument in %s on line %d +bool(false) +int(%d) +Done diff --git a/ext/standard/tests/file/touch.phpt b/ext/standard/tests/file/touch.phpt new file mode 100644 index 000000000..504674f17 --- /dev/null +++ b/ext/standard/tests/file/touch.phpt @@ -0,0 +1,49 @@ +--TEST-- +touch() tests +--FILE-- +<?php + +$filename = dirname(__FILE__)."/touch.dat"; + +var_dump(touch()); +var_dump(touch($filename)); +var_dump(filemtime($filename)); +@unlink($filename); +var_dump(touch($filename, 101)); +var_dump(filemtime($filename)); + +@unlink($filename); +var_dump(touch($filename, -1)); +var_dump(filemtime($filename)); + +@unlink($filename); +var_dump(touch($filename, 100, 100)); +var_dump(filemtime($filename)); + +@unlink($filename); +var_dump(touch($filename, 100, -100)); +var_dump(filemtime($filename)); + +var_dump(touch("/no/such/file/or/directory")); + +@unlink($filename); + +echo "Done\n"; +?> +--EXPECTF-- +Warning: Wrong parameter count for touch() in %s on line %d +NULL +bool(true) +int(%d) +bool(true) +int(101) +bool(true) +int(%i) +bool(true) +int(100) +bool(true) +int(100) + +Warning: touch(): Unable to create file /no/such/file/or/directory because No such file or directory in %s on line %d +bool(false) +Done diff --git a/ext/standard/tests/general_functions/001.phpt b/ext/standard/tests/general_functions/001.phpt index 164bd7fb2..bfd82e55b 100644 --- a/ext/standard/tests/general_functions/001.phpt +++ b/ext/standard/tests/general_functions/001.phpt @@ -61,7 +61,7 @@ sprintf octal binary test: passed sprintf float test: passed 99.00 99.00 -1.23400e-18 -1.23400e+18 -9.84324e+6 --9.84324e+6 +1.234000e-18 +1.234000e+18 +9.843243e+6 +-9.843243e+6 diff --git a/ext/standard/tests/general_functions/bug27678.phpt b/ext/standard/tests/general_functions/bug27678.phpt index ec9cf93cf..5db5890a1 100644 --- a/ext/standard/tests/general_functions/bug27678.phpt +++ b/ext/standard/tests/general_functions/bug27678.phpt @@ -1,5 +1,5 @@ --TEST-- -bug #27678 (number_format() crashes with large numbers) +Bug #27678 (number_format() crashes with large numbers) --FILE-- <?php diff --git a/ext/standard/tests/general_functions/bug34794.phpt b/ext/standard/tests/general_functions/bug34794.phpt new file mode 100644 index 000000000..3aacf7e51 --- /dev/null +++ b/ext/standard/tests/general_functions/bug34794.phpt @@ -0,0 +1,34 @@ +--TEST-- +bug #34794: proc_close() hangs when used with two processes +--SKIPIF-- +<?php +if (!is_executable('/bin/cat')) echo 'skip cat not found'; +?> +--FILE-- +<?php +echo "Opening process 1\n"; +$process1 = proc_open('/bin/cat', array(0 => array('pipe', 'r'), 1 =>array('pipe', 'r')), $pipes1); + +echo "Opening process 2\n"; +$process2 = proc_open('/bin/cat', array(0 => array('pipe', 'r'), 1 =>array('pipe', 'r')), $pipes2); + + +echo "Closing process 1\n"; +fclose($pipes1[0]); +fclose($pipes1[1]); +proc_close($process1); + +echo "Closing process 2\n"; +fclose($pipes2[0]); +fclose($pipes2[1]); +proc_close($process2); + +echo "Done\n"; + +?> +--EXPECTF-- +Opening process 1 +Opening process 2 +Closing process 1 +Closing process 2 +Done diff --git a/ext/standard/tests/general_functions/bug39322.phpt b/ext/standard/tests/general_functions/bug39322.phpt new file mode 100644 index 000000000..cb3459995 --- /dev/null +++ b/ext/standard/tests/general_functions/bug39322.phpt @@ -0,0 +1,44 @@ +--TEST-- +bug #39322: proc_terminate() loosing process resource +--SKIPIF-- +<?php +if (!is_executable('/bin/sleep')) echo 'skip sleep not found'; +?> +--FILE-- +<?php +$descriptors = array( + 0 => array('pipe', 'r'), + 1 => array('pipe', 'w'), + 2 => array('pipe', 'w')); + +$pipes = array(); + +$process = proc_open('/bin/sleep 120', $descriptors, $pipes); + +proc_terminate($process); +sleep(1); // wait a bit to let the process finish +var_dump(proc_get_status($process)); + +echo "Done!\n"; + +?> +--EXPECTF-- +array(8) { + ["command"]=> + string(14) "/bin/sleep 120" + ["pid"]=> + int(%d) + ["running"]=> + bool(false) + ["signaled"]=> + bool(true) + ["stopped"]=> + bool(false) + ["exitcode"]=> + int(-1) + ["termsig"]=> + int(15) + ["stopsig"]=> + int(0) +} +Done! diff --git a/ext/standard/tests/general_functions/bug40398.phpt b/ext/standard/tests/general_functions/bug40398.phpt new file mode 100755 index 000000000..ab3cc2a2b --- /dev/null +++ b/ext/standard/tests/general_functions/bug40398.phpt @@ -0,0 +1,90 @@ +--TEST-- +Bug #40398 (parent and self callback functions erroneously called statically) +--FILE-- +<?php + +class Base +{ + function __construct($msg) + { + echo __METHOD__ . "($msg)\n"; + } +} + +class Derived_1 extends Base +{ + public function __construct() + { + $args = func_get_args(); + call_user_func_array(array($this, 'Base::__construct'), $args); + } +} + +class Derived_2 extends Base +{ + public function __construct() + { + $args = func_get_args(); + call_user_func_array(array($this, 'parent::__construct'), $args); + } +} + +class Derived_3 extends Base +{ + public function __construct() + { + $args = func_get_args(); + call_user_func_array('Base::__construct', $args); + } +} + +class Derived_4 extends Base +{ + public function __construct() + { + $args = func_get_args(); + call_user_func_array('parent::__construct', $args); + } +} + +class Derived_5 extends Base +{ + public function __construct() + { + $args = func_get_args(); + call_user_func_array(array('Base', '__construct'), $args); + } +} + +class Derived_6 extends Base +{ + public function __construct() + { + $args = func_get_args(); + call_user_func_array(array('parent', '__construct'), $args); + } +} + +new Derived_1('1'); +new Derived_2('2'); +new Derived_3('3'); +new Derived_4('4'); +new Derived_5('5'); +new Derived_6('6'); + +?> +===DONE=== +--EXPECTF-- +Base::__construct(1) +Base::__construct(2) + +Warning: call_user_func_array(): First argument is expected to be a valid callback, 'Base::__construct' was given in %sbug40398.php on line %d + +Warning: call_user_func_array(): First argument is expected to be a valid callback, 'parent::__construct' was given in %sbug40398.php on line %d + +Strict Standards: Non-static method Base::__construct() cannot be called statically, assuming $this from compatible context Derived_5 in %sbug40398.php on line %d +Base::__construct(5) + +Strict Standards: Non-static method Base::__construct() cannot be called statically, assuming $this from compatible context Derived_6 in %sbug40398.php on line %d +Base::__construct(6) +===DONE=== diff --git a/ext/standard/tests/general_functions/bug40752.phpt b/ext/standard/tests/general_functions/bug40752.phpt new file mode 100644 index 000000000..30ed8a4aa --- /dev/null +++ b/ext/standard/tests/general_functions/bug40752.phpt @@ -0,0 +1,37 @@ +--TEST-- +Bug #40752 (parse_ini_file() segfaults when a scalar setting is redeclared as an array) +--FILE-- +<?php + +$file = dirname(__FILE__)."/bug40752.ini"; +file_put_contents($file, ' +foo = 1; +foo[] = 1; +'); + +var_dump(parse_ini_file($file)); + +file_put_contents($file, ' +foo[] = 1; +foo = 1; +'); + +var_dump(parse_ini_file($file)); + +unlink($file); + +echo "Done\n"; +?> +--EXPECTF-- +array(1) { + ["foo"]=> + array(1) { + [0]=> + string(1) "1" + } +} +array(1) { + ["foo"]=> + string(1) "1" +} +Done diff --git a/ext/standard/tests/general_functions/bug41037.phpt b/ext/standard/tests/general_functions/bug41037.phpt new file mode 100644 index 000000000..eab2c334c --- /dev/null +++ b/ext/standard/tests/general_functions/bug41037.phpt @@ -0,0 +1,23 @@ +--TEST-- +Bug #41037 (unregister_tick_function() inside the tick function crash PHP) +--FILE-- +<?php + +function a() { + echo "hello"; + unregister_tick_function('a'); +} + +declare (ticks=1); +register_tick_function('a'); + +echo "Done\n"; +?> +--EXPECTF-- +hello +Warning: unregister_tick_function(): Unable to delete tick function executed at the moment in %s on line %d +Done +hello +Warning: unregister_tick_function(): Unable to delete tick function executed at the moment in %s on line %d +hello +Warning: unregister_tick_function(): Unable to delete tick function executed at the moment in %s on line %d diff --git a/ext/standard/tests/general_functions/error_get_last.phpt b/ext/standard/tests/general_functions/error_get_last.phpt new file mode 100644 index 000000000..3ce1339d1 --- /dev/null +++ b/ext/standard/tests/general_functions/error_get_last.phpt @@ -0,0 +1,43 @@ +--TEST-- +error_get_last() tests +--FILE-- +<?php + +var_dump(error_get_last()); +var_dump(error_get_last(true)); +var_dump(error_get_last()); + +$a = $b; + +var_dump(error_get_last()); + +echo "Done\n"; +?> +--EXPECTF-- +NULL + +Warning: Wrong parameter count for error_get_last() in %s on line %d +NULL +array(4) { + ["type"]=> + int(2) + ["message"]=> + string(42) "Wrong parameter count for error_get_last()" + ["file"]=> + string(%d) "%s" + ["line"]=> + int(%d) +} + +Notice: Undefined variable: b in %s on line %d +array(4) { + ["type"]=> + int(8) + ["message"]=> + string(21) "Undefined variable: b" + ["file"]=> + string(%d) "%s" + ["line"]=> + int(%d) +} +Done diff --git a/ext/standard/tests/general_functions/getrusage.phpt b/ext/standard/tests/general_functions/getrusage.phpt new file mode 100644 index 000000000..55abbac37 --- /dev/null +++ b/ext/standard/tests/general_functions/getrusage.phpt @@ -0,0 +1,23 @@ +--TEST-- +getrusage() tests +--SKIPIF-- +<?php if (!function_exists("getrusage")) print "skip"; ?> +--FILE-- +<?php + +var_dump(gettype(getrusage())); +var_dump(gettype(getrusage(1))); +var_dump(gettype(getrusage(-1))); +var_dump(getrusage(array())); + + +echo "Done\n"; +?> +--EXPECTF-- +string(5) "array" +string(5) "array" +string(5) "array" + +Warning: getrusage() expects parameter 1 to be long, array given in %s on line %d +NULL +Done diff --git a/ext/standard/tests/general_functions/head.phpt b/ext/standard/tests/general_functions/head.phpt new file mode 100644 index 000000000..e83bbf6ac --- /dev/null +++ b/ext/standard/tests/general_functions/head.phpt @@ -0,0 +1,53 @@ +--TEST-- +header() and friends +--SKIPIF-- +<?php +if (php_sapi_name() != "cli") { + die("skip this test is for CLI"); +} +?> +--FILE-- +<?php + +$v1 = headers_sent(); +$v2 = headers_list(); +var_dump(header("HTTP 1.0", true, 200)); + +var_dump($v1); +var_dump($v2); + +var_dump(header("")); +var_dump(header("", true)); +var_dump(headers_sent()); +var_dump(headers_list()); +var_dump(header("HTTP blah")); +var_dump(header("HTTP blah", true)); +var_dump(headers_sent()); +var_dump(headers_list()); + +echo "Done\n"; +?> +--EXPECTF-- +NULL +bool(false) +array(0) { +} + +Warning: Cannot modify header information - headers already sent by (output started at %s:%d) in %s on line %d +NULL + +Warning: Cannot modify header information - headers already sent by (output started at %s:%d) in %s on line %d +NULL +bool(true) +array(0) { +} + +Warning: Cannot modify header information - headers already sent by (output started at %s:%d) in %s on line %d +NULL + +Warning: Cannot modify header information - headers already sent by (output started at %s:%d) in %s on line %d +NULL +bool(true) +array(0) { +} +Done diff --git a/ext/standard/tests/general_functions/highlight_heredoc.phpt b/ext/standard/tests/general_functions/highlight_heredoc.phpt index 58f83806a..ee4e2e828 100644 --- a/ext/standard/tests/general_functions/highlight_heredoc.phpt +++ b/ext/standard/tests/general_functions/highlight_heredoc.phpt @@ -1,5 +1,7 @@ --TEST-- highlight_string() handling of heredoc +--INI-- +highlight.html=#000000 --FILE-- <?php $str = ' diff --git a/ext/standard/tests/general_functions/import_request.phpt b/ext/standard/tests/general_functions/import_request.phpt new file mode 100644 index 000000000..23dc049db --- /dev/null +++ b/ext/standard/tests/general_functions/import_request.phpt @@ -0,0 +1,78 @@ +--TEST-- +import_request_variables() tests +--GET-- +a=1&b=heh&c=3&d[]=5&GLOBALS=test&1=hm +--POST-- +ap=25&bp=test&cp=blah3&dp[]=ar +--FILE-- +<?php + +var_dump(import_request_variables()); +var_dump(import_request_variables("")); +var_dump(import_request_variables("", "")); + +var_dump(import_request_variables("g", "")); +var_dump($a, $b, $c, $ap); + +var_dump(import_request_variables("g", "g_")); +var_dump($g_a, $g_b, $g_c, $g_ap, $g_1); + +var_dump(import_request_variables("GP", "i_")); +var_dump($i_a, $i_b, $i_c, $i_ap, $i_bp, $i_cp, $i_dp); + +var_dump(import_request_variables("gGg", "r_")); +var_dump($r_a, $r_b, $r_c, $r_ap); + +echo "Done\n"; +?> +--EXPECTF-- +Warning: Wrong parameter count for import_request_variables() in %s on line %d +NULL + +Notice: import_request_variables(): No prefix specified - possible security hazard in %s on line %d +NULL + +Notice: import_request_variables(): No prefix specified - possible security hazard in %s on line %d +NULL + +Notice: import_request_variables(): No prefix specified - possible security hazard in %s on line %d + +Warning: import_request_variables(): Attempted GLOBALS variable overwrite. in %s on line %d + +Warning: import_request_variables(): Numeric key detected - possible security hazard. in %s on line %d +NULL + +Notice: Undefined variable: ap in %s on line %d +string(1) "1" +string(3) "heh" +string(1) "3" +NULL +NULL + +Notice: Undefined variable: g_ap in %s on line %d + +Notice: Undefined variable: g_1 in %s on line %d +string(1) "1" +string(3) "heh" +string(1) "3" +NULL +NULL +NULL +string(1) "1" +string(3) "heh" +string(1) "3" +string(2) "25" +string(4) "test" +string(5) "blah3" +array(1) { + [0]=> + string(2) "ar" +} +NULL + +Notice: Undefined variable: r_ap in %s on line %d +string(1) "1" +string(3) "heh" +string(1) "3" +NULL +Done diff --git a/ext/standard/tests/general_functions/include_path.phpt b/ext/standard/tests/general_functions/include_path.phpt new file mode 100644 index 000000000..12d7c3f22 --- /dev/null +++ b/ext/standard/tests/general_functions/include_path.phpt @@ -0,0 +1,75 @@ +--TEST-- +*_include_path() tests +--INI-- +include_path=. +--FILE-- +<?php + +var_dump(get_include_path()); +var_dump(get_include_path("var")); + +var_dump(restore_include_path()); +var_dump(restore_include_path("")); + + +var_dump(set_include_path()); +var_dump(get_include_path()); +var_dump(set_include_path("var")); +var_dump(get_include_path()); + +var_dump(restore_include_path()); +var_dump(get_include_path()); + +var_dump(set_include_path(".:/path/to/dir")); +var_dump(get_include_path()); + +var_dump(restore_include_path()); +var_dump(get_include_path()); + +var_dump(set_include_path("")); +var_dump(get_include_path()); + +var_dump(restore_include_path()); +var_dump(get_include_path()); + +var_dump(set_include_path(array())); +var_dump(get_include_path()); + +var_dump(restore_include_path()); +var_dump(get_include_path()); + + +echo "Done\n"; +?> +--EXPECTF-- +string(1) "." + +Warning: Wrong parameter count for get_include_path() in %s on line %d +NULL +NULL + +Warning: Wrong parameter count for restore_include_path() in %s on line %d +NULL + +Warning: Wrong parameter count for set_include_path() in %s on line %d +NULL +string(1) "." +string(1) "." +string(3) "var" +NULL +string(1) "." +string(1) "." +string(14) ".:/path/to/dir" +NULL +string(1) "." +string(1) "." +string(1) "." +NULL +string(1) "." + +Notice: Array to string conversion in %s on line %d +string(1) "." +string(5) "Array" +NULL +string(1) "." +Done diff --git a/ext/standard/tests/general_functions/ini_get_all.phpt b/ext/standard/tests/general_functions/ini_get_all.phpt new file mode 100644 index 000000000..6016873fd --- /dev/null +++ b/ext/standard/tests/general_functions/ini_get_all.phpt @@ -0,0 +1,51 @@ +--TEST-- +ini_get_all() tests +--SKIPIF-- +<?php if (!extension_loaded("pcre")) die("skip"); ?> +--FILE-- +<?php + +var_dump(gettype(ini_get_all())); +var_dump(ini_get_all("")); +var_dump(ini_get_all("nosuchextension")); +var_dump(ini_get_all("reflection")); +var_dump(ini_get_all("pcre")); + +var_dump(ini_get_all("", "")); + +echo "Done\n"; +?> +--EXPECTF-- +string(5) "array" + +Warning: ini_get_all(): Unable to find extension '' in %s on line %d +bool(false) + +Warning: ini_get_all(): Unable to find extension 'nosuchextension' in %s on line %d +bool(false) +array(0) { +} +array(2) { + ["pcre.backtrack_limit"]=> + array(3) { + ["global_value"]=> + string(6) "100000" + ["local_value"]=> + string(6) "100000" + ["access"]=> + int(7) + } + ["pcre.recursion_limit"]=> + array(3) { + ["global_value"]=> + string(6) "100000" + ["local_value"]=> + string(6) "100000" + ["access"]=> + int(7) + } +} + +Warning: ini_get_all() expects at most 1 parameter, 2 given in %s on line %d +bool(false) +Done diff --git a/ext/standard/tests/general_functions/parse_ini_file.phpt b/ext/standard/tests/general_functions/parse_ini_file.phpt new file mode 100644 index 000000000..399a224db --- /dev/null +++ b/ext/standard/tests/general_functions/parse_ini_file.phpt @@ -0,0 +1,175 @@ +--TEST-- +parse_ini_file() tests +--FILE-- +<?php + +$filename = dirname(__FILE__)."/parse_ini_file.dat"; + +var_dump(parse_ini_file()); +var_dump(parse_ini_file(1,1,1)); +var_dump(parse_ini_file($filename)); +var_dump(parse_ini_file($filename, true)); + +$ini = " +test = +"; +file_put_contents($filename, $ini); +var_dump(parse_ini_file($filename)); + +$ini = " +test== +"; +file_put_contents($filename, $ini); +var_dump(parse_ini_file($filename)); + +$ini = " +test=test= +"; +file_put_contents($filename, $ini); +var_dump(parse_ini_file($filename)); + +$ini = " +test= \"new +line\" +"; +file_put_contents($filename, $ini); +var_dump(parse_ini_file($filename)); + +define("TEST_CONST", "test const value"); +$ini = " +test=TEST_CONST +"; +file_put_contents($filename, $ini); +var_dump(parse_ini_file($filename)); + +$ini = " +[section] +test=hello +"; +file_put_contents($filename, $ini); +var_dump(parse_ini_file($filename, true)); + +$ini = " +[section] +test=hello +"; +file_put_contents($filename, $ini); +var_dump(parse_ini_file($filename, false)); + +$ini = " +section.test=hello +"; +file_put_contents($filename, $ini); +var_dump(parse_ini_file($filename, true)); + +$ini = " +[section] +section.test=hello +"; +file_put_contents($filename, $ini); +var_dump(parse_ini_file($filename, true)); + +$ini = " +[section] +1=2 +"; +file_put_contents($filename, $ini); +var_dump(parse_ini_file($filename, true)); + +$ini = " +1=2 +"; +file_put_contents($filename, $ini); +var_dump(parse_ini_file($filename, true)); + +$ini = " +test=test2 +test=test3 +test=test4 +"; +file_put_contents($filename, $ini); +var_dump(parse_ini_file($filename, true)); + + +@unlink($filename); +echo "Done\n"; +?> +--EXPECTF-- +Warning: Wrong parameter count for parse_ini_file() in %s on line %d +NULL + +Warning: Wrong parameter count for parse_ini_file() in %s on line %d +NULL + +Warning: parse_ini_file(%sparse_ini_file.dat): failed to open stream: No such file or directory in %s on line %d +array(0) { +} + +Warning: parse_ini_file(%sparse_ini_file.dat): failed to open stream: No such file or directory in %s on line %d +array(0) { +} +array(1) { + ["test"]=> + string(0) "" +} + +Warning: Error parsing %sparse_ini_file.dat on line 2 + in %s on line %d +array(1) { + ["test"]=> + string(0) "" +} + +Warning: Error parsing %sparse_ini_file.dat on line 2 + in %s on line %d +array(1) { + ["test"]=> + string(4) "test" +} +array(1) { + ["test"]=> + string(8) "new +line" +} +array(1) { + ["test"]=> + string(16) "test const value" +} +array(1) { + ["section"]=> + array(1) { + ["test"]=> + string(5) "hello" + } +} +array(1) { + ["test"]=> + string(5) "hello" +} +array(1) { + ["section.test"]=> + string(5) "hello" +} +array(1) { + ["section"]=> + array(1) { + ["section.test"]=> + string(5) "hello" + } +} +array(1) { + ["section"]=> + array(1) { + [1]=> + string(1) "2" + } +} +array(1) { + [1]=> + string(1) "2" +} +array(1) { + ["test"]=> + string(5) "test4" +} +Done diff --git a/ext/standard/tests/general_functions/phpcredits.phpt b/ext/standard/tests/general_functions/phpcredits.phpt new file mode 100644 index 000000000..2a8acc9a8 --- /dev/null +++ b/ext/standard/tests/general_functions/phpcredits.phpt @@ -0,0 +1,54 @@ +--TEST-- +phpcredits() +--FILE-- +<?php + +var_dump(phpcredits()); +var_dump(phpcredits(array())); + +echo "--\n"; +var_dump(phpcredits(0)); + +echo "--\n"; +var_dump(phpcredits(CREDITS_GROUP)); + +?> +--EXPECTF-- +PHP Credits + +PHP Group +%s + +Language Design & Concept +%s + +%wPHP %d Authors%w +%s + +%wSAPI Modules%w +%s + +%wModule Authors%w +%s + +%wPHP Documentation%w +%s + +PHP Quality Assurance Team +%s + +PHP Website Team +%s +bool(true) + +Warning: phpcredits() expects parameter 1 to be long, array given in %sphpcredits.php on line 4 +NULL +-- +PHP Credits +bool(true) +-- +PHP Credits + +PHP Group +%s +bool(true) diff --git a/ext/standard/tests/general_functions/phpcredits2.phpt b/ext/standard/tests/general_functions/phpcredits2.phpt new file mode 100644 index 000000000..e3b6e354d --- /dev/null +++ b/ext/standard/tests/general_functions/phpcredits2.phpt @@ -0,0 +1,32 @@ +--TEST-- +phpcredits() CGI +--SKIPIF-- +<?php if (php_sapi_name()=='cli') echo 'skip'; ?> +--POST-- +dummy=x +--FILE-- +<?php + +var_dump(phpcredits()); +var_dump(phpcredits(array())); + +echo "--\n"; +var_dump(phpcredits(0)); + +echo "--\n"; +var_dump(phpcredits(CREDITS_GROUP)); + +?> +--EXPECTF-- +<!DOCTYPE %s>%s</html> +bool(true) + +Warning: phpcredits() expects parameter 1 to be long, array given in %sphpcredits2.php on line 4 +NULL +-- +<h1>PHP Credits</h1> +bool(true) +-- +<h1>PHP Credits</h1> +%sPHP Group%s +bool(true) diff --git a/ext/standard/tests/general_functions/phpinfo.phpt b/ext/standard/tests/general_functions/phpinfo.phpt new file mode 100644 index 000000000..dab7f327c --- /dev/null +++ b/ext/standard/tests/general_functions/phpinfo.phpt @@ -0,0 +1,75 @@ +--TEST-- +phpinfo() +--FILE-- +<?php +var_dump(phpinfo()); + +echo "--\n"; +var_dump(phpinfo(array())); + +echo "--\n"; +var_dump(phpinfo(0)); + +echo "--\n"; +var_dump(phpinfo(INFO_LICENSE)); + +?> +--EXPECTF-- +phpinfo() +PHP Version => %s + +System => %s +Build Date => %s +Configure Command => %s +Server API => Command Line Interface +Virtual Directory Support => %s +Configuration File (php.ini) Path => %s +PHP API => %d +PHP Extension => %d +Zend Extension => %d +Debug Build => %s +Thread Safety => %s +Zend Memory Manager => %s +IPv6 Support => %s +Registered PHP Streams => %s +Registered Stream Socket Transports => %s +Registered Stream Filters => %s + +%s + _______________________________________________________________________ + + +Configuration + +PHP Core + +%s + +Additional Modules + +%s + +Environment + +%s + +PHP Variables + +%s + +PHP License +%s +bool(true) +-- + +Warning: phpinfo() expects parameter 1 to be long, array given in %sphpinfo.php on line 5 +NULL +-- +phpinfo() +bool(true) +-- +phpinfo() + +PHP License +%s +bool(true) diff --git a/ext/standard/tests/general_functions/phpinfo2.phpt b/ext/standard/tests/general_functions/phpinfo2.phpt new file mode 100644 index 000000000..ba9cc28ab --- /dev/null +++ b/ext/standard/tests/general_functions/phpinfo2.phpt @@ -0,0 +1,33 @@ +--TEST-- +phpinfo() CGI +--SKIPIF-- +<?php if (php_sapi_name()=='cli') echo 'skip'; ?> +--POST-- +dummy=x +--FILE-- +<?php +var_dump(phpinfo()); + +echo "--\n"; +var_dump(phpinfo(array())); + +echo "--\n"; +var_dump(phpinfo(0)); + +echo "--\n"; +var_dump(phpinfo(INFO_LICENSE)); + +?> +--EXPECTF-- +<!DOCTYPE %s> +%s</html>bool(true) +-- + +Warning: phpinfo() expects parameter 1 to be long, array given in %sphpinfo2.php on line 5 +NULL +-- +<!DOCTYPE %s> +%s</html>bool(true) +-- +<!DOCTYPE %s> +%s</html>bool(true) diff --git a/ext/standard/tests/general_functions/proc_open02.phpt b/ext/standard/tests/general_functions/proc_open02.phpt new file mode 100644 index 000000000..3cba15e9a --- /dev/null +++ b/ext/standard/tests/general_functions/proc_open02.phpt @@ -0,0 +1,72 @@ +--TEST-- +proc_open +--SKIPIF-- +<?php +if (!is_executable('/bin/sleep')) echo 'skip no sleep'; +if (!is_executable('/usr/bin/nohup')) echo 'skip no nohup'; +?> +--FILE-- +<?php +$ds = array(array('pipe', 'r')); + +$cat = proc_open( + '/usr/bin/nohup /bin/sleep 50', + $ds, + $pipes +); + +sleep(1); // let the OS run the nohup process before sending the signal + +var_dump(proc_terminate($cat, 1)); // send a SIGHUP +sleep(1); +var_dump(proc_get_status($cat)); + +var_dump(proc_terminate($cat)); // now really quit it +sleep(1); +var_dump(proc_get_status($cat)); + +proc_close($cat); + +echo "Done!\n"; + +?> +--EXPECTF-- +bool(true) +array(8) { + ["command"]=> + string(28) "/usr/bin/nohup /bin/sleep 50" + ["pid"]=> + int(%d) + ["running"]=> + bool(true) + ["signaled"]=> + bool(false) + ["stopped"]=> + bool(false) + ["exitcode"]=> + int(-1) + ["termsig"]=> + int(0) + ["stopsig"]=> + int(0) +} +bool(true) +array(8) { + ["command"]=> + string(28) "/usr/bin/nohup /bin/sleep 50" + ["pid"]=> + int(%d) + ["running"]=> + bool(false) + ["signaled"]=> + bool(true) + ["stopped"]=> + bool(false) + ["exitcode"]=> + int(-1) + ["termsig"]=> + int(15) + ["stopsig"]=> + int(0) +} +Done! diff --git a/ext/standard/tests/general_functions/putenv.phpt b/ext/standard/tests/general_functions/putenv.phpt new file mode 100644 index 000000000..afe1badce --- /dev/null +++ b/ext/standard/tests/general_functions/putenv.phpt @@ -0,0 +1,28 @@ +--TEST-- +putenv() basic tests +--FILE-- +<?php + +$var_name="SUCHVARSHOULDNOTEXIST"; + +var_dump(getenv($var_name)); +var_dump(putenv($var_name."=value")); +var_dump(getenv($var_name)); + +var_dump(putenv($var_name."=")); +var_dump(getenv($var_name)); + +var_dump(putenv($var_name)); +var_dump(getenv($var_name)); + +echo "Done\n"; +?> +--EXPECTF-- +bool(false) +bool(true) +string(5) "value" +bool(true) +string(0) "" +bool(true) +bool(false) +Done diff --git a/ext/standard/tests/general_functions/rand.phpt b/ext/standard/tests/general_functions/rand.phpt new file mode 100644 index 000000000..e75bd6d37 --- /dev/null +++ b/ext/standard/tests/general_functions/rand.phpt @@ -0,0 +1,63 @@ +--TEST-- +rand() and mt_rand() tests +--FILE-- +<?php + +var_dump(mt_rand()); +var_dump(mt_rand(-1)); +var_dump(mt_rand(-1,1)); +var_dump(mt_rand(0,3)); + +var_dump(rand()); +var_dump(rand(-1)); +var_dump(rand(-1,1)); +var_dump(rand(0,3)); + +var_dump(srand()); +var_dump(srand(-1)); +var_dump(srand(array())); + +var_dump(mt_srand()); +var_dump(mt_srand(-1)); +var_dump(mt_srand(array())); + +var_dump(getrandmax()); +var_dump(getrandmax(1)); + +var_dump(mt_getrandmax()); +var_dump(mt_getrandmax(1)); + +echo "Done\n"; +?> +--EXPECTF-- +int(%d) + +Warning: mt_rand() expects exactly 2 parameters, 1 given in %s on line %d +NULL +int(%i) +int(%d) +int(%d) + +Warning: rand() expects exactly 2 parameters, 1 given in %s on line %d +NULL +int(%i) +int(%d) +NULL +NULL + +Warning: srand() expects parameter 1 to be long, array given in %s on line %d +NULL +NULL +NULL + +Warning: mt_srand() expects parameter 1 to be long, array given in %s on line %d +NULL +int(%d) + +Warning: Wrong parameter count for getrandmax() in %s on line %d +NULL +int(%d) + +Warning: Wrong parameter count for mt_getrandmax() in %s on line %d +NULL +Done diff --git a/ext/standard/tests/general_functions/sys_getloadavg.phpt b/ext/standard/tests/general_functions/sys_getloadavg.phpt new file mode 100644 index 000000000..cb3a798db --- /dev/null +++ b/ext/standard/tests/general_functions/sys_getloadavg.phpt @@ -0,0 +1,32 @@ +--TEST-- +sys_getloadavg() tests +--SKIPIF-- +<?php +if (!function_exists("sys_getloadavg")) die("skip"); +?> +--FILE-- +<?php + +var_dump(sys_getloadavg("")); +var_dump(sys_getloadavg()); + +echo "Done\n"; +?> +--EXPECTF-- +array(3) { + [0]=> + float(%f) + [1]=> + float(%f) + [2]=> + float(%f) +} +array(3) { + [0]=> + float(%f) + [1]=> + float(%f) + [2]=> + float(%f) +} +Done diff --git a/ext/standard/tests/general_functions/type.phpt b/ext/standard/tests/general_functions/type.phpt new file mode 100644 index 000000000..98eccbbda --- /dev/null +++ b/ext/standard/tests/general_functions/type.phpt @@ -0,0 +1,351 @@ +--TEST-- +gettype(), settype() and friends +--FILE-- +<?php + +function foo($errno, $errstr, $errfile, $errline) { + var_dump($errstr); +} + +set_error_handler("foo"); + +$fp = fopen(__FILE__, "r"); +fclose($fp); +$fp1 = fopen(__FILE__, "r"); + +$var1 = "another string"; +$var2 = array(2,3,4); + +$array = array( + array(1,2,3), + $var1, + $var2, + 1, + 2.0, + NULL, + false, + "some string", + $fp, + $fp1, + new stdclass, +); + +$types = array( + "null", + "integer", + "double", + "boolean", + "resource", + "array", + "object", + "string" + ); + +foreach ($array as $var) { + var_dump(gettype($var)); +} + +foreach ($types as $type) { + foreach ($array as $var) { + var_dump(settype($var, $type)); + var_dump($var); + } +} + +echo "Done\n"; +?> +--EXPECTF-- +string(5) "array" +string(6) "string" +string(5) "array" +string(7) "integer" +string(6) "double" +string(4) "NULL" +string(7) "boolean" +string(6) "string" +string(12) "unknown type" +string(8) "resource" +string(6) "object" +bool(true) +NULL +bool(true) +NULL +bool(true) +NULL +bool(true) +NULL +bool(true) +NULL +bool(true) +NULL +bool(true) +NULL +bool(true) +NULL +bool(true) +NULL +bool(true) +NULL +bool(true) +NULL +bool(true) +int(1) +bool(true) +int(0) +bool(true) +int(1) +bool(true) +int(1) +bool(true) +int(2) +bool(true) +int(0) +bool(true) +int(0) +bool(true) +int(0) +bool(true) +int(5) +bool(true) +int(6) +string(54) "Object of class stdClass could not be converted to int" +bool(true) +int(%d) +bool(true) +float(1) +bool(true) +float(0) +bool(true) +float(1) +bool(true) +float(1) +bool(true) +float(2) +bool(true) +float(0) +bool(true) +float(0) +bool(true) +float(0) +bool(true) +float(5) +bool(true) +float(6) +string(57) "Object of class stdClass could not be converted to double" +bool(true) +float(%d) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(false) +bool(true) +bool(false) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +string(42) "settype(): Cannot convert to resource type" +bool(false) +array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) +} +string(42) "settype(): Cannot convert to resource type" +bool(false) +string(14) "another string" +string(42) "settype(): Cannot convert to resource type" +bool(false) +array(3) { + [0]=> + int(2) + [1]=> + int(3) + [2]=> + int(4) +} +string(42) "settype(): Cannot convert to resource type" +bool(false) +int(1) +string(42) "settype(): Cannot convert to resource type" +bool(false) +float(2) +string(42) "settype(): Cannot convert to resource type" +bool(false) +NULL +string(42) "settype(): Cannot convert to resource type" +bool(false) +bool(false) +string(42) "settype(): Cannot convert to resource type" +bool(false) +string(11) "some string" +string(42) "settype(): Cannot convert to resource type" +bool(false) +resource(%d) of type (Unknown) +string(42) "settype(): Cannot convert to resource type" +bool(false) +resource(%d) of type (stream) +string(42) "settype(): Cannot convert to resource type" +bool(false) +object(stdClass)#%d (0) { +} +bool(true) +array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) +} +bool(true) +array(1) { + [0]=> + string(14) "another string" +} +bool(true) +array(3) { + [0]=> + int(2) + [1]=> + int(3) + [2]=> + int(4) +} +bool(true) +array(1) { + [0]=> + int(1) +} +bool(true) +array(1) { + [0]=> + float(2) +} +bool(true) +array(0) { +} +bool(true) +array(1) { + [0]=> + bool(false) +} +bool(true) +array(1) { + [0]=> + string(11) "some string" +} +bool(true) +array(1) { + [0]=> + resource(%d) of type (Unknown) +} +bool(true) +array(1) { + [0]=> + resource(%d) of type (stream) +} +bool(true) +array(0) { +} +bool(true) +object(stdClass)#%d (3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) +} +bool(true) +object(stdClass)#%d (1) { + ["scalar"]=> + string(14) "another string" +} +bool(true) +object(stdClass)#%d (3) { + [0]=> + int(2) + [1]=> + int(3) + [2]=> + int(4) +} +bool(true) +object(stdClass)#%d (1) { + ["scalar"]=> + int(1) +} +bool(true) +object(stdClass)#%d (1) { + ["scalar"]=> + float(2) +} +bool(true) +object(stdClass)#%d (0) { +} +bool(true) +object(stdClass)#%d (1) { + ["scalar"]=> + bool(false) +} +bool(true) +object(stdClass)#%d (1) { + ["scalar"]=> + string(11) "some string" +} +bool(true) +object(stdClass)#%d (1) { + ["scalar"]=> + resource(%d) of type (Unknown) +} +bool(true) +object(stdClass)#%d (1) { + ["scalar"]=> + resource(%d) of type (stream) +} +bool(true) +object(stdClass)#%d (0) { +} +string(26) "Array to string conversion" +bool(true) +string(5) "Array" +bool(true) +string(14) "another string" +string(26) "Array to string conversion" +bool(true) +string(5) "Array" +bool(true) +string(1) "1" +bool(true) +string(1) "2" +bool(true) +string(0) "" +bool(true) +string(0) "" +bool(true) +string(11) "some string" +bool(true) +string(14) "Resource id #%d" +bool(true) +string(14) "Resource id #%d" +string(57) "Object of class stdClass could not be converted to string" +string(45) "Object of class stdClass to string conversion" +bool(true) +string(6) "Object" +Done diff --git a/ext/standard/tests/math/constants.phpt b/ext/standard/tests/math/constants.phpt index 7b5110f53..deeb785f4 100644 --- a/ext/standard/tests/math/constants.phpt +++ b/ext/standard/tests/math/constants.phpt @@ -1,5 +1,7 @@ --TEST-- Math constants +--INI-- +precision=14 --FILE-- <?php $constants = array( diff --git a/ext/standard/tests/math/hexdec.phpt b/ext/standard/tests/math/hexdec.phpt index d8ff71f1c..d9e644aaf 100644 --- a/ext/standard/tests/math/hexdec.phpt +++ b/ext/standard/tests/math/hexdec.phpt @@ -1,5 +1,7 @@ --TEST-- overflow check for _php_math_basetozval +--INI-- +precision=14 --FILE-- <?php diff --git a/ext/standard/tests/network/inet.phpt b/ext/standard/tests/network/inet.phpt new file mode 100644 index 000000000..09cf20623 --- /dev/null +++ b/ext/standard/tests/network/inet.phpt @@ -0,0 +1,75 @@ +--TEST-- +inet_ntop() & inet_pton() tests +--SKIPIF-- +<?php +if (!function_exists("inet_ntop")) die("skip no inet_ntop()"); +if (!function_exists("inet_pton")) die("skip no inet_pton()"); +?> +--FILE-- +<?php + +$packed = chr(127) . chr(0) . chr(0) . chr(1); +var_dump(inet_ntop($packed)); + +$packed = chr(255) . chr(255) . chr(255) . chr(0); +var_dump(inet_ntop($packed)); + +var_dump(inet_ntop()); +var_dump(inet_ntop(-1)); +var_dump(inet_ntop("")); +var_dump(inet_ntop("blah-blah")); + +var_dump(inet_pton()); +var_dump(inet_pton("")); +var_dump(inet_pton(-1)); +var_dump(inet_pton("abra")); + +$array = array( + "127.0.0.1", + "66.163.161.116", + "255.255.255.255", + "0.0.0.0", + ); +foreach ($array as $val) { + var_dump($packed = inet_pton($val)); + var_dump(inet_ntop($packed)); +} + +echo "Done\n"; +?> +--EXPECTF-- +string(9) "127.0.0.1" +string(13) "255.255.255.0" + +Warning: inet_ntop() expects exactly 1 parameter, 0 given in %s on line %d +bool(false) + +Warning: inet_ntop(): Invalid in_addr value in %s on line %d +bool(false) + +Warning: inet_ntop(): Invalid in_addr value in %s on line %d +bool(false) + +Warning: inet_ntop(): Invalid in_addr value in %s on line %d +bool(false) + +Warning: inet_pton() expects exactly 1 parameter, 0 given in %s on line %d +bool(false) + +Warning: inet_pton(): Unrecognized address in %s on line %d +bool(false) + +Warning: inet_pton(): Unrecognized address -1 in %s on line %d +bool(false) + +Warning: inet_pton(): Unrecognized address abra in %s on line %d +bool(false) +string(4) "%s" +string(9) "127.0.0.1" +string(4) "%s" +string(14) "66.163.161.116" +string(4) "%s" +string(15) "255.255.255.255" +string(4) "%s" +string(7) "0.0.0.0" +Done diff --git a/ext/standard/tests/network/inet_ipv6.phpt b/ext/standard/tests/network/inet_ipv6.phpt new file mode 100644 index 000000000..3b280dfec --- /dev/null +++ b/ext/standard/tests/network/inet_ipv6.phpt @@ -0,0 +1,50 @@ +--TEST-- +inet_ntop() & inet_pton() IPv6 tests +--SKIPIF-- +<?php +if (!function_exists("inet_ntop")) die("skip no inet_ntop()"); +if (!function_exists("inet_pton")) die("skip no inet_pton()"); + +$packed = str_repeat(chr(0), 15) . chr(1); +if (@inet_ntop($packed) === false) { + die("skip no IPv6 support"); +} +if (stristr(PHP_OS, "darwin") !== false) die("skip MacOS has broken inet_*() funcs"); +?> +--FILE-- +<?php + +$a = array( + '::1', + '::2', + '::35', + '::255', + '::1024', + '', + '2001:0db8:85a3:08d3:1319:8a2e:0370:7344', + '2001:0db8:1234:0000:0000:0000:0000:0000', + '2001:0db8:1234:FFFF:FFFF:FFFF:FFFF:FFFF', +); + +foreach ($a as $address) { + $packed = inet_pton($address); + var_dump(inet_ntop($packed)); +} + +echo "Done\n"; +?> +--EXPECTF-- +string(3) "::1" +string(3) "::2" +string(4) "::35" +string(5) "::255" +string(6) "::1024" + +Warning: inet_pton(): Unrecognized address in %s on line %d + +Warning: inet_ntop(): Invalid in_addr value in %s on line %d +bool(false) +string(36) "2001:db8:85a3:8d3:1319:8a2e:370:7344" +string(15) "2001:db8:1234::" +string(38) "2001:db8:1234:ffff:ffff:ffff:ffff:ffff" +Done diff --git a/ext/standard/tests/network/ip.phpt b/ext/standard/tests/network/ip.phpt new file mode 100644 index 000000000..794c2d38c --- /dev/null +++ b/ext/standard/tests/network/ip.phpt @@ -0,0 +1,67 @@ +--TEST-- +ip2long() & long2ip() tests +--SKIPIF-- +<?php +if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only"); +?> +--FILE-- +<?php + +$array = array( + "127.0.0.1", + "10.0.0.1", + "255.255.255.255", + "255.255.255.0", + "0.0.0.0", + "66.163.161.116", +); + +foreach ($array as $ip) { + var_dump($long = ip2long($ip)); + var_dump(long2ip($long)); +} + +var_dump(ip2long()); +var_dump(ip2long("")); +var_dump(ip2long("777.777.777.777")); +var_dump(ip2long("111.111.111.111")); +var_dump(ip2long(array())); + +var_dump(long2ip()); +var_dump(long2ip(-110000)); +var_dump(long2ip("")); +var_dump(long2ip(array())); + +echo "Done\n"; +?> +--EXPECTF-- +int(2130706433) +string(9) "127.0.0.1" +int(167772161) +string(8) "10.0.0.1" +int(-1) +string(15) "255.255.255.255" +int(-256) +string(13) "255.255.255.0" +int(0) +string(7) "0.0.0.0" +int(1118019956) +string(14) "66.163.161.116" + +Warning: Wrong parameter count for ip2long() in %s on line %d +NULL +int(-1) +bool(false) +int(1869573999) + +Notice: Array to string conversion in %s on line %d +bool(false) + +Warning: Wrong parameter count for long2ip() in %s on line %d +NULL +string(13) "255.254.82.80" +string(7) "0.0.0.0" + +Notice: Array to string conversion in %s on line %d +string(7) "0.0.0.0" +Done diff --git a/ext/standard/tests/network/shutdown.phpt b/ext/standard/tests/network/shutdown.phpt new file mode 100755 index 000000000..f9ab66476 --- /dev/null +++ b/ext/standard/tests/network/shutdown.phpt @@ -0,0 +1,65 @@ +--TEST-- +stream_socket_shutdown() test on IPv4 TCP Loopback +--SKIPIF-- +<?php + function_exists('stream_socket_shutdown') or die('skip stream_socket_shutdown() is not supported.'); +?> +--FILE-- +<?php + /* Setup socket server */ + $server = stream_socket_server('tcp://127.0.0.1:31337'); + if (!$server) { + die('Unable to create AF_INET socket [server]'); + } + + /* Connect and send request 1 */ + $client1 = stream_socket_client('tcp://127.0.0.1:31337'); + if (!$client1) { + die('Unable to create AF_INET socket [client]'); + } + @fwrite($client1, "Client 1\n"); + stream_socket_shutdown($client1, STREAM_SHUT_WR); + @fwrite($client1, "Error 1\n"); + + /* Connect and send request 2 */ + $client2 = stream_socket_client('tcp://127.0.0.1:31337'); + if (!$client2) { + die('Unable to create AF_INET socket [client]'); + } + @fwrite($client2, "Client 2\n"); + stream_socket_shutdown($client2, STREAM_SHUT_WR); + @fwrite($client2, "Error 2\n"); + + /* Accept connection 1 */ + $socket = stream_socket_accept($server); + if (!$socket) { + die('Unable to accept connection'); + } + @fwrite($socket, fgets($socket)); + @fwrite($socket, fgets($socket)); + fclose($socket); + + /* Read Response 1 */ + echo fgets($client1); + echo fgets($client1); + + /* Accept connection 2 */ + $socket = stream_socket_accept($server); + if (!$socket) { + die('Unable to accept connection'); + } + @fwrite($socket, fgets($socket)); + @fwrite($socket, fgets($socket)); + fclose($socket); + + /* Read Response 2 */ + echo fgets($client2); + echo fgets($client2); + + fclose($client1); + fclose($client2); + fclose($server); +?> +--EXPECT-- +Client 1 +Client 2 diff --git a/ext/standard/tests/serialize/003.phpt b/ext/standard/tests/serialize/003.phpt index 173f57b72..edbcb1f0f 100644 --- a/ext/standard/tests/serialize/003.phpt +++ b/ext/standard/tests/serialize/003.phpt @@ -15,11 +15,11 @@ foreach(array(1e2, 5.2e25, 85.29e-23, 9e-9) AS $value) { d:100; float\(100\) -d:5\.2E\+25; +d:5[0-9]*; float\(5\.2E\+25\) d:8\.52[89][0-9]+E-22; float\(8\.529E-22\) -d:9\.[0-9]*E-9; +d:8\.[9]*[0-9]*E-9; float\(9\.0E-9\) diff --git a/ext/standard/tests/serialize/bug24063.phpt b/ext/standard/tests/serialize/bug24063.phpt index e1cdfecf5..3cca101cb 100644 --- a/ext/standard/tests/serialize/bug24063.phpt +++ b/ext/standard/tests/serialize/bug24063.phpt @@ -16,8 +16,8 @@ for ($i = 1; $i < 10; $i++) { 0.01 0.01 0.001 0.001 0.0001 0.0001 -1E-05 1E-05 -1E-06 1E-06 -1E-07 1E-07 -1E-08 1E-08 -1E-09 1E-09 +1.0E-5 1.0E-5 +1.0E-6 1.0E-6 +1.0E-7 1.0E-7 +1.0E-8 1.0E-8 +1.0E-9 1.0E-9 diff --git a/ext/standard/tests/serialize/bug31442.phpt b/ext/standard/tests/serialize/bug31442.phpt index f508d6b98..3fd069050 100755 --- a/ext/standard/tests/serialize/bug31442.phpt +++ b/ext/standard/tests/serialize/bug31442.phpt @@ -1,5 +1,7 @@ --TEST--
Bug #31442 (unserialize broken on 64-bit systems)
+--INI--
+precision=14
--FILE--
<?php
echo unserialize(serialize(2147483648));
diff --git a/ext/standard/tests/serialize/unserializeS.phpt b/ext/standard/tests/serialize/unserializeS.phpt new file mode 100755 index 000000000..633a07d21 --- /dev/null +++ b/ext/standard/tests/serialize/unserializeS.phpt @@ -0,0 +1,14 @@ +--TEST--
+Bug MOPB-29 (wrong length calculation for S)
+--INI--
+error_reporting=0
+--FILE--
+<?php
+$str = 'S:'.(100*3).':"'.str_repeat('\61', 100).'"';
+$arr = array(str_repeat('"', 200)."1"=>1,str_repeat('"', 200)."2"=>1);
+
+$data = unserialize($str);
+var_dump($data);
+
+--EXPECT--
+string(100) "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
diff --git a/ext/standard/tests/strings/bug22207.phpt b/ext/standard/tests/strings/bug22207.phpt index 688bb5b74..32a15d73c 100644 --- a/ext/standard/tests/strings/bug22207.phpt +++ b/ext/standard/tests/strings/bug22207.phpt @@ -6,6 +6,6 @@ Bug #22207 (missing 0 when using the e notation in *printf functions) var_dump(sprintf("%10.5e\n", 1.1)); ?> --EXPECT-- -1.1000e+0 -string(11) " 1.1000e+0 +1.10000e+0 +string(11) "1.10000e+0 " diff --git a/ext/standard/tests/strings/bug26819.phpt b/ext/standard/tests/strings/bug26819.phpt index 4a5353943..2d639a932 100644 --- a/ext/standard/tests/strings/bug26819.phpt +++ b/ext/standard/tests/strings/bug26819.phpt @@ -6,4 +6,4 @@ $a = array(); var_dump(http_build_query($a)); ?> --EXPECT-- -NULL +string(0) "" diff --git a/ext/standard/tests/strings/bug36392.phpt b/ext/standard/tests/strings/bug36392.phpt new file mode 100644 index 000000000..8e4cd16c6 --- /dev/null +++ b/ext/standard/tests/strings/bug36392.phpt @@ -0,0 +1,16 @@ +--TEST-- +Bug #36392 (wrong number of decimal digits with %e specifier in sprintf) +--FILE-- +<?php + echo sprintf("%e\n", 1.123456789); + echo sprintf("%.10e\n", 1.123456789); + echo sprintf("%.0e\n", 1.123456789); + echo sprintf("%.1e\n", 1.123456789); + echo sprintf("%5.1e\n", 1.123456789); +?> +--EXPECT-- +1.123457e+0 +1.1234567890e+0 +1e+0 +1.1e+0 +1.1e+0 diff --git a/ext/standard/tests/strings/bug38770.phpt b/ext/standard/tests/strings/bug38770.phpt new file mode 100644 index 000000000..2494a911b --- /dev/null +++ b/ext/standard/tests/strings/bug38770.phpt @@ -0,0 +1,25 @@ +--TEST-- +Bug #38770 (unpack() broken with longs on 64 bit machines) +--FILE-- +<?php + +foreach (array('N','I','l') as $v) { + print_r(unpack($v, pack($v, -30000))); +} + +echo "Done\n"; +?> +--EXPECT-- +Array +( + [1] => -30000 +) +Array +( + [1] => -30000 +) +Array +( + [1] => -30000 +) +Done diff --git a/ext/standard/tests/strings/bug39350.phpt b/ext/standard/tests/strings/bug39350.phpt new file mode 100644 index 000000000..53d58b709 --- /dev/null +++ b/ext/standard/tests/strings/bug39350.phpt @@ -0,0 +1,13 @@ +--TEST-- +Bug #39350 (implode/join() crash on empty input strings) +--FILE-- +<?php + +implode('', array(null)); +implode('', array(false)); +implode('', array("")); + +echo "Done\n"; +?> +--EXPECT-- +Done diff --git a/ext/standard/tests/strings/bug39621.phpt b/ext/standard/tests/strings/bug39621.phpt Binary files differnew file mode 100644 index 000000000..1a33147b6 --- /dev/null +++ b/ext/standard/tests/strings/bug39621.phpt diff --git a/ext/standard/tests/strings/bug39873.phpt b/ext/standard/tests/strings/bug39873.phpt new file mode 100644 index 000000000..e73f3c851 --- /dev/null +++ b/ext/standard/tests/strings/bug39873.phpt @@ -0,0 +1,17 @@ +--TEST-- +Bug #39873 (number_format() breaks with locale & decimal points) +--SKIPIF-- +<?php +if (!setlocale(LC_ALL, "ita","it","Italian","it_IT","it_IT.ISO8859-1","it_IT.ISO_8859-1")) { + die("skip locale needed for this test is not supported on this platform"); +} +?> +--FILE-- +<?php + setlocale(LC_ALL, "ita","it","Italian","it_IT","it_IT.ISO8859-1","it_IT.ISO_8859-1"); + $num = 0+"1234.56"; + echo number_format($num,2); + echo "\n"; +?> +--EXPECT-- +1,234.56 diff --git a/ext/standard/tests/strings/bug40432.phpt b/ext/standard/tests/strings/bug40432.phpt new file mode 100644 index 000000000..6db2e94e5 --- /dev/null +++ b/ext/standard/tests/strings/bug40432.phpt @@ -0,0 +1,8 @@ +--TEST-- +Bug #40432 (strip_tags() fails with greater than in attribute) +--FILE-- +<?php +echo strip_tags('<span title="test > all">this</span>') . "\n"; +?> +--EXPECT-- +this diff --git a/ext/standard/tests/strings/bug40637.phpt b/ext/standard/tests/strings/bug40637.phpt new file mode 100644 index 000000000..5669083aa --- /dev/null +++ b/ext/standard/tests/strings/bug40637.phpt @@ -0,0 +1,13 @@ +--TEST-- +Bug #40637 (strip_tags() does not handle single quotes correctly) +--FILE-- +<?php + +$html = '<span title="Bug \' Trigger">Text</span>'; +var_dump(strip_tags($html)); + +echo "Done\n"; +?> +--EXPECTF-- +string(4) "Text" +Done diff --git a/ext/standard/tests/strings/bug40704.phpt b/ext/standard/tests/strings/bug40704.phpt new file mode 100644 index 000000000..82e91b5c8 --- /dev/null +++ b/ext/standard/tests/strings/bug40704.phpt @@ -0,0 +1,13 @@ +--TEST-- +Bug #40704 (strip_tags() does not handle single quotes correctly) +--FILE-- +<?php + +$html = "<div>Bug ' Trigger</div> Missing Text"; +var_dump(strip_tags($html)); + +echo "Done\n"; +?> +--EXPECT-- +string(26) "Bug ' Trigger Missing Text" +Done diff --git a/ext/standard/tests/strings/bug40754.phpt b/ext/standard/tests/strings/bug40754.phpt new file mode 100644 index 000000000..23a459317 --- /dev/null +++ b/ext/standard/tests/strings/bug40754.phpt @@ -0,0 +1,63 @@ +--TEST-- +Bug #40754 (Overflow checks inside string functions) +--FILE-- +<?php + +$v = 2147483647; + +var_dump(substr("abcde", 1, $v)); +var_dump(substr_replace("abcde", "x", $v, $v)); + +var_dump(strspn("abcde", "abc", $v, $v)); +var_dump(strcspn("abcde", "abc", $v, $v)); + +var_dump(substr_count("abcde", "abc", $v, $v)); +var_dump(substr_compare("abcde", "abc", $v, $v)); + +var_dump(stripos("abcde", "abc", $v)); +var_dump(substr_count("abcde", "abc", $v, 1)); +var_dump(substr_count("abcde", "abc", 1, $v)); +var_dump(strpos("abcde", "abc", $v)); +var_dump(stripos("abcde", "abc", $v)); +var_dump(strrpos("abcde", "abc", $v)); +var_dump(strripos("abcde", "abc", $v)); +var_dump(strncmp("abcde", "abc", $v)); +var_dump(chunk_split("abcde", $v, "abc")); +var_dump(substr("abcde", $v, $v)); + +?> +--EXPECTF-- +string(4) "bcde" +bool(false) +bool(false) +bool(false) + +Warning: substr_count(): Offset value 2147483647 exceeds string length. in %s on line %d +bool(false) + +Warning: substr_compare(): The start position cannot exceed initial string length in %s on line %d +bool(false) + +Warning: stripos(): Offset not contained in string. in %s on line %d +bool(false) + +Warning: substr_count(): Offset value 2147483647 exceeds string length. in %s on line %d +bool(false) + +Warning: substr_count(): Length value 2147483647 exceeds string length. in %s on line %d +bool(false) + +Warning: strpos(): Offset not contained in string. in %s on line %d +bool(false) + +Warning: stripos(): Offset not contained in string. in %s on line %d +bool(false) + +Notice: strrpos(): Offset is greater than the length of haystack string in %s on line %d +bool(false) + +Notice: strripos(): Offset is greater than the length of haystack string in %s on line %d +bool(false) +int(2) +string(8) "abcdeabc" +bool(false) diff --git a/ext/standard/tests/strings/bug40915.phpt b/ext/standard/tests/strings/bug40915.phpt Binary files differnew file mode 100644 index 000000000..9b26896e7 --- /dev/null +++ b/ext/standard/tests/strings/bug40915.phpt diff --git a/ext/standard/tests/strings/convert_cyr_string.phpt b/ext/standard/tests/strings/convert_cyr_string.phpt new file mode 100644 index 000000000..a6f365731 --- /dev/null +++ b/ext/standard/tests/strings/convert_cyr_string.phpt @@ -0,0 +1,54 @@ +--TEST-- +basic convert_cyr_string() tests +--FILE-- +<?php + +var_dump(convert_cyr_string()); +var_dump(convert_cyr_string("")); +var_dump(convert_cyr_string("", "")); +var_dump(convert_cyr_string("", "", "")); +var_dump(convert_cyr_string(array(), array(), array())); + +var_dump(convert_cyr_string("[[[[[[", "q", "m")); +var_dump(convert_cyr_string("[[[[[[", "k", "w")); +var_dump(convert_cyr_string("[[[[[[", "m", "a")); +var_dump(convert_cyr_string("[[[[[[", "d", "i")); +var_dump(convert_cyr_string("[[[[[[", "w", "k")); +var_dump(convert_cyr_string("[[[[[[", "i", "q")); +var_dump(convert_cyr_string("", "d", "i")); + +echo "Done\n"; +?> +--EXPECTF-- +Warning: Wrong parameter count for convert_cyr_string() in %s on line %d +NULL + +Warning: Wrong parameter count for convert_cyr_string() in %s on line %d +NULL + +Warning: Wrong parameter count for convert_cyr_string() in %s on line %d +NULL + +Warning: convert_cyr_string(): Unknown source charset: in %s on line %d + +Warning: convert_cyr_string(): Unknown destination charset: in %s on line %d +string(0) "" + +Notice: Array to string conversion in %s on line %d + +Notice: Array to string conversion in %s on line %d + +Notice: Array to string conversion in %s on line %d +string(5) "Array" + +Warning: convert_cyr_string(): Unknown source charset: q in %s on line %d +string(6) "[[[[[[" +string(6) "[[[[[[" +string(6) "[[[[[[" +string(6) "[[[[[[" +string(6) "[[[[[[" + +Warning: convert_cyr_string(): Unknown destination charset: q in %s on line %d +string(6) "[[[[[[" +string(0) "" +Done diff --git a/ext/standard/tests/strings/crypt.phpt b/ext/standard/tests/strings/crypt.phpt index 5368178e1..ce178f684 100644 --- a/ext/standard/tests/strings/crypt.phpt +++ b/ext/standard/tests/strings/crypt.phpt @@ -24,9 +24,20 @@ echo (CRYPT_EXT_DES) ? ((crypt($str, $salt2) === $res_2) ? 'EXT' : 'EXT - ERROR echo (CRYPT_MD5) ? ((crypt($str, $salt3) === $res_3) ? 'MD5' : 'MD5 - ERROR') : 'MD5', "\n"; echo (CRYPT_BLOWFISH) ? ((crypt($str, $salt4) === $res_4) ? 'BLO' : 'BLO - ERROR') : 'BLO', "\n"; +var_dump(crypt($str)); +var_dump(crypt()); +var_dump(crypt("", "", "")); + ?> ---EXPECT-- +--EXPECTF-- STD EXT MD5 BLO +string(%d) "%s" + +Warning: crypt() expects at least 1 parameter, 0 given in %s on line %d +NULL + +Warning: crypt() expects at most 2 parameters, 3 given in %s on line %d +NULL diff --git a/ext/standard/tests/strings/get_meta_tags.phpt b/ext/standard/tests/strings/get_meta_tags.phpt new file mode 100644 index 000000000..f086b99b7 --- /dev/null +++ b/ext/standard/tests/strings/get_meta_tags.phpt @@ -0,0 +1,95 @@ +--TEST-- +get_meta_tags() tests +--FILE-- +<?php + +$filename = dirname(__FILE__)."/get_meta_tags.html"; + +$data = <<<DATA +<meta name="author" content="name"> +<meta name="keywords" content="php documentation"> +<meta name="DESCRIPTION" content="a php manual"> +<meta name="geo.position" content="49.33;-86.59"> +</head> <!-- parsing stops here --> +DATA; + +$data1 = <<<DATA +<html> + <head> + <meta name="author" content="name"> + <meta name="keywords" content="php documentation"> + <meta name="DESCRIPTION" content="a php manual"> + <meta name="geo.position" content="49.33;-86.59"> + </head> + <body> + <meta name="author" content="name1"> + <meta name="keywords" content="php documentation1"> + <meta name="DESCRIPTION" content="a php manual1"> + <meta name="geo.position" content="49.33;-86.591"> + </body> +</html> +DATA; + +$data2 = <<<DATA +<meta name="author" content="name" +<meta name="keywords" content="php documentation"> +DATA; + +$data3 = <<<DATA +<meta <meta name="keywords" content="php documentation"> +DATA; + +$data4 = <<<DATA +<meta name="author" content="name" +<meta name="keywords" content="php documentation" +DATA; + +$array = array($data, $data1, $data2, $data3, $data4, "", "<>", "<meta<<<<<"); + +foreach ($array as $html) { + file_put_contents($filename, $html); + var_dump(get_meta_tags($filename)); +} + +@unlink($filename); + +echo "Done\n"; +?> +--EXPECTF-- +array(4) { + ["author"]=> + string(4) "name" + ["keywords"]=> + string(17) "php documentation" + ["description"]=> + string(12) "a php manual" + ["geo_position"]=> + string(12) "49.33;-86.59" +} +array(4) { + ["author"]=> + string(4) "name" + ["keywords"]=> + string(17) "php documentation" + ["description"]=> + string(12) "a php manual" + ["geo_position"]=> + string(12) "49.33;-86.59" +} +array(1) { + ["keywords"]=> + string(17) "php documentation" +} +array(1) { + ["keywords"]=> + string(17) "php documentation" +} +array(0) { +} +array(0) { +} +array(0) { +} +array(0) { +} +Done diff --git a/ext/standard/tests/strings/highlight_file.phpt b/ext/standard/tests/strings/highlight_file.phpt new file mode 100644 index 000000000..2c83ee299 --- /dev/null +++ b/ext/standard/tests/strings/highlight_file.phpt @@ -0,0 +1,68 @@ +--TEST-- +highlight_file() tests +--INI-- +highlight.string=#DD0000 +highlight.comment=#FF9900 +highlight.keyword=#007700 +highlight.bg=#FFFFFF +highlight.default=#0000BB +highlight.html=#000000 +--FILE-- +<?php + +$filename = dirname(__FILE__)."/highlight_file.dat"; + +var_dump(highlight_file()); +var_dump(highlight_file($filename)); + +$data = <<<DATA +<?php echo "test"; ?> +DATA; + +file_put_contents($filename, $data); +var_dump(highlight_file($filename)); + +$data = <<<DATA +<?php echo "test ?> +DATA; + +file_put_contents($filename, $data); +var_dump(highlight_file($filename)); + +$data = ' +<?php + class test { + public $var = 1; + private function foo() { echo "foo"; } + public function bar() { var_dump(test::foo()); } + } +?>'; + +file_put_contents($filename, $data); +var_dump(highlight_file($filename)); + + +@unlink($filename); +echo "Done\n"; +?> +--EXPECTF-- +Warning: highlight_file() expects at least 1 parameter, 0 given in %s on line %d +bool(false) + +Warning: highlight_file(%shighlight_file.dat): failed to open stream: No such file or directory in %s on line %d + +Warning: highlight_file(): Failed opening '%shighlight_file.dat' for highlighting in %s on line %d +bool(false) +<code><span style="color: #000000"> +<span style="color: #0000BB"><?php </span><span style="color: #007700">echo </span><span style="color: #DD0000">"test"</span><span style="color: #007700">; </span><span style="color: #0000BB">?></span> +</span> +</code>bool(true) +<code><span style="color: #000000"> +<span style="color: #0000BB"><?php </span><span style="color: #007700">echo </span><span style="color: #DD0000">"test ?></span> +</span> +</code>bool(true) +<code><span style="color: #000000"> +<br /><span style="color: #0000BB"><?php <br /> </span><span style="color: #007700">class </span><span style="color: #0000BB">test </span><span style="color: #007700">{ <br /> public </span><span style="color: #0000BB">$var </span><span style="color: #007700">= </span><span style="color: #0000BB">1</span><span style="color: #007700">; <br /> private function </span><span style="color: #0000BB">foo</span><span style="color: #007700">() { echo </span><span style="color: #DD0000">"foo"</span><span style="color: #007700">; }<br /> public function </span><span style="color: #0000BB">bar</span><span style="color: #007700">() { </span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">test</span><span style="color: #007700">::</span><span style="color: #0000BB">foo</span><span style="color: #007700">()); }<br /> } <br /></span><span style="color: #0000BB">?></span> +</span> +</code>bool(true) +Done diff --git a/ext/standard/tests/strings/htmlentities02.phpt b/ext/standard/tests/strings/htmlentities02.phpt index 666c4f650..babec44b5 100644 --- a/ext/standard/tests/strings/htmlentities02.phpt +++ b/ext/standard/tests/strings/htmlentities02.phpt @@ -2,8 +2,8 @@ htmlentities() test 2 (setlocale / fr_FR.ISO-8859-15) --SKIPIF-- <?php -$result = (bool)setlocale(LC_CTYPE, "fr_FR.ISO-8859-15", "fr_FR.ISO8859-15"); -if (!$result || preg_match('/ISO/i', setlocale(LC_CTYPE, 0)) == 0) { +$result = (bool)setlocale(LC_CTYPE, "fr_FR.ISO-8859-15", "fr_FR.ISO8859-15", 'fr_FR@euro'); +if (!$result) { die("skip setlocale() failed\n"); } echo "warn possibly braindead libc\n"; @@ -14,7 +14,7 @@ default_charset= mbstring.internal_encoding=none --FILE-- <?php - setlocale( LC_CTYPE, "fr_FR.ISO-8859-15", "fr_FR.ISO8859-15" ); + setlocale(LC_CTYPE, "fr_FR.ISO-8859-15", "fr_FR.ISO8859-15", 'fr_FR@euro'); var_dump(htmlentities("\xbc\xbd\xbe", ENT_QUOTES, '')); ?> --EXPECT-- diff --git a/ext/standard/tests/strings/levenshtein.phpt b/ext/standard/tests/strings/levenshtein.phpt new file mode 100644 index 000000000..d7d5e7a44 --- /dev/null +++ b/ext/standard/tests/strings/levenshtein.phpt @@ -0,0 +1,88 @@ +--TEST-- +levenshtein() function test +--FILE-- +<?php + +function test_me($title,$expect,$text1,$text2,$cost1="",$cost2="",$cost3="") { + + if ($cost1=="") { + $result=levenshtein($text1,$text2); + } + elseif ($cost2=="") { + $result=levenshtein($text1,$text2,$cost1); + } + else { + $result=levenshtein($text1,$text2,$cost1,$cost2,$cost3); + } + if($result==$expect) return 0; + + echo "$title: result is $result instead of $expect "; + echo "for '$text1'/'$text2' "; + if($cost1) echo "($cost1:$cost2:$cost3)"; + echo "\n"; + + return 1; +} + +$n=0; + +$n += test_me("equal" , 0, "12345", "12345"); +$n += test_me("1st empty" , 3, "", "xzy"); +$n += test_me("2nd empty" , 3, "xzy", ""); +$n += test_me("both empty" , 0, "", ""); +$n += test_me("1 char" , 1, "1", "2"); +$n += test_me("2 char swap", 2, "12", "21"); + +$n += test_me("inexpensive delete", 2, "2121", "11", 2, 1, 1); +$n += test_me("expensive delete" , 10, "2121", "11", 2, 1, 5); +$n += test_me("inexpensive insert", 2, "11", "2121", 1, 1, 1); +$n += test_me("expensive insert" , 10, "11", "2121", 5, 1, 1); + +$n += test_me("expensive replace" , 3, "111", "121", 2, 3, 2); +$n += test_me("very expensive replace", 4, "111", "121", 2, 9, 2); + +$n += test_me("bug #7368", 2, "13458", "12345"); +$n += test_me("bug #7368", 2, "1345", "1234"); + +$n += test_me("bug #6562", 1, "debugg", "debug"); +$n += test_me("bug #6562", 1, "ddebug", "debug"); +$n += test_me("bug #6562", 2, "debbbug", "debug"); +$n += test_me("bug #6562", 1, "debugging", "debuging"); + +$n += test_me("bug #16473", 2, "a", "bc"); +$n += test_me("bug #16473", 2, "xa", "xbc"); +$n += test_me("bug #16473", 2, "xax", "xbcx"); +$n += test_me("bug #16473", 2, "ax", "bcx"); + +$n += test_me("custom", -1, "111", "121", "my_levcode"); +$n += test_me("lt maxlength1", 254, "AbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrtsuvwxyzAbcdefghijklmnopqrtsuvwxyzAbcdefghijklmnopqrtsuvwxyzAbcdefghijklmnopqrtsuvwxyzAbcdefghijklmnopqrtsuvwxyzAbcdefghijklmnopqrtsu", "A"); +$n += test_me("gt maxlength1", -1, "AbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrtsuvwxyzAbcdefghijklmnopqrtsuvwxyzAbcdefghijklmnopqrtsuvwxyzAbcdefghijklmnopqrtsuvwxyzAbcdefghijklmnopqrtsuvwxyzAbcdefghijklmnopqrtsuv", "A"); + +$n += test_me("lt maxlength2", 254, "A", "AbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrtsuvwxyzAbcdefghijklmnopqrtsuvwxyzAbcdefghijklmnopqrtsuvwxyzAbcdefghijklmnopqrtsuvwxyzAbcdefghijklmnopqrtsuvwxyzAbcdefghijklmnopqrtsu"); +$n += test_me("gt maxlength2", -1, "A", "AbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrtsuvwxyzAbcdefghijklmnopqrtsuvwxyzAbcdefghijklmnopqrtsuvwxyzAbcdefghijklmnopqrtsuvwxyzAbcdefghijklmnopqrtsuvwxyzAbcdefghijklmnopqrtsuv"); + +echo ($n==0)?"all passed\n":"$n failed\n"; + +var_dump(levenshtein(array(), array())); +var_dump(levenshtein("", "", -1, -1, -1)); +var_dump(levenshtein("", "", 10, 10, 10)); +var_dump(levenshtein("")); + +?> +--EXPECTF-- +Warning: levenshtein(): The general Levenshtein support is not there yet in %s on line %d + +Warning: levenshtein(): Argument string(s) too long in %s on line %d + +Warning: levenshtein(): Argument string(s) too long in %s on line %d +all passed + +Notice: Array to string conversion in %s on line %d + +Notice: Array to string conversion in %s on line %d +int(0) +int(0) +int(0) + +Warning: Wrong parameter count for levenshtein() in %s on line %d +NULL diff --git a/ext/standard/tests/strings/ltrim.phpt b/ext/standard/tests/strings/ltrim.phpt new file mode 100644 index 000000000..cb64b9cd3 --- /dev/null +++ b/ext/standard/tests/strings/ltrim.phpt @@ -0,0 +1,83 @@ +--TEST-- +Test ltrim() function +--FILE-- +<?php + +/* Testing for Error conditions */ + +/* Invalid Number of Arguments */ + + echo "\n *** Output for Error Conditions ***\n"; + + echo "\n *** Output for zero argument ***\n"; + var_dump( ltrim() ); + + echo "\n *** Output for more than valid number of arguments (Valid are 1 or 2 arguments) ***\n"; + var_dump( ltrim("", " ", 1) ); + +/* heredoc string */ +$str = <<<EOD +us +ing heredoc string +EOD; + +echo "\n *** Using heredoc string ***\n"; +var_dump( ltrim($str, "\nusi") ); + +/* Testing the Normal behaviour of ltrim() function */ + + echo "\n *** Output for Normal Behaviour ***\n"; + var_dump ( ltrim(" \t\0 ltrim test") ); /* without second Argument */ + var_dump ( ltrim(" ltrim test" , "") ); /* no characters in second Argument */ + var_dump ( ltrim(" ltrim test", NULL) ); /* with NULL as second Argument */ + var_dump ( ltrim(" ltrim test", true) ); /* with boolean value as second Argument */ + var_dump ( ltrim(" ltrim test", " ") ); /* with single space as second Argument */ + var_dump ( ltrim("\t\n\r\0\x0B ltrim test", "\t\n\r\0\x0B") ); /* with multiple escape sequences as second Argument */ + var_dump ( ltrim("ABCXYZltrim test", "A..Z") ); /* with characters range as second Argument */ + var_dump ( ltrim("0123456789ltrim test", "0..9") ); /* with numbers range as second Argument */ + var_dump ( ltrim("@$#ltrim test", "#@$") ); /* with some special characters as second Argument */ + + + echo "\n *** Output for scalar argument) ***\n"; + var_dump( ltrim( 12345 ) ); /* Scalar argument */ + + echo "\n *** Output for NULL argument) ***\n"; + var_dump( ltrim(NULL) ); /* NULL Argument */ + +echo "\nDone\n"; + +?> +--EXPECTF-- +*** Output for Error Conditions *** + + *** Output for zero argument *** + +Warning: Wrong parameter count for ltrim() in %s on line %d +NULL + + *** Output for more than valid number of arguments (Valid are 1 or 2 arguments) *** + +Warning: Wrong parameter count for ltrim() in %s on line %d +NULL + + *** Using heredoc string *** +string(17) "ng heredoc string" + + *** Output for Normal Behaviour *** +string(10) "ltrim test" +string(13) " ltrim test" +string(18) " ltrim test" +string(18) " ltrim test" +string(10) "ltrim test" +string(11) " ltrim test" +string(10) "ltrim test" +string(10) "ltrim test" +string(10) "ltrim test" + + *** Output for scalar argument) *** +string(5) "12345" + + *** Output for NULL argument) *** +string(0) "" + +Done diff --git a/ext/standard/tests/strings/metaphone.phpt b/ext/standard/tests/strings/metaphone.phpt new file mode 100644 index 000000000..d1aa9af54 --- /dev/null +++ b/ext/standard/tests/strings/metaphone.phpt @@ -0,0 +1,41 @@ +--TEST-- +metaphone() tests +--FILE-- +<?php + +var_dump(metaphone()); +var_dump(metaphone("")); +var_dump(metaphone(-1)); +var_dump(metaphone(-1, -1)); + +var_dump(metaphone("valid phrase", -1)); +var_dump(metaphone("valid phrase", 0)); +var_dump(metaphone("valid phrase", 10000)); + +$array = array( +"They fell forward, grovelling heedlessly on the cold earth.", +"But the shadow of horror wheeled and returned, passing lower now, right above them, sweeping the fen-reek with its ghastly wings.", +"And then it was gone, flying back to Mordor with the speed of the wrath of Sauron; and behind it the wind roared away, leaving the Dead Marshes bare and bleak.", +"The naked waste, as far as the eye could pierce, even to the distant menace of the mountains, was dappled with the fitful moonlight." +); + +foreach($array as $str) { + var_dump(metaphone($str)); +} + +echo "Done\n"; +?> +--EXPECTF-- +Warning: metaphone() expects at least 1 parameter, 0 given in %s on line %d +NULL +string(0) "" +string(0) "" +bool(false) +bool(false) +string(6) "FLTFRS" +string(6) "FLTFRS" +string(26) "0FLFRWRTKRFLNKHTLSLN0KLTR0" +string(56) "BT0XTFHRRHLTNTRTRNTPSNKLWRNRFTBF0MSWPNK0FNRKW0TSFSTLWNKS" +string(69) "ANT0NTWSKNFLYNKBKTMRTRW00SPTF0R0FSRNNTBHNTT0WNTRRTWLFNK0TTMRXSBRNTBLK" +string(56) "0NKTWSTSFRS0YKLTPRSFNT0TSTNTMNSF0MNTNSWSTPLTW00FTFLMNLFT" +Done diff --git a/ext/standard/tests/strings/pack.phpt b/ext/standard/tests/strings/pack.phpt new file mode 100644 index 000000000..b36eee1e5 --- /dev/null +++ b/ext/standard/tests/strings/pack.phpt @@ -0,0 +1,385 @@ +--TEST-- +Generic pack()/unpack() tests +--SKIPIF-- +<?php +if (PHP_INT_MAX > 2147483647) { + die("skip 32bit test only"); +} +?> +--FILE-- +<?php +print_r(unpack("A", pack("A", "hello world"))); +print_r(unpack("A*", pack("A*", "hello world"))); +echo '"'.pack("A9", "hello").'"'; +echo "\n"; + +print_r(unpack("C", pack("C", -127))); +print_r(unpack("C", pack("C", 127))); +print_r(unpack("C", pack("C", 255))); +print_r(unpack("C", pack("C", -129))); + +print_r(unpack("H", pack("H", 0x04))); + +print_r(unpack("I", pack("I", 65534))); +print_r(unpack("I", pack("I", 0))); +print_r(unpack("I", pack("I", -1000))); +print_r(unpack("I", pack("I", -64434))); +print_r(unpack("I", pack("I", 4294967296))); +print_r(unpack("I", pack("I", -4294967296))); + +print_r(unpack("L", pack("L", 65534))); +print_r(unpack("L", pack("L", 0))); +print_r(unpack("L", pack("L", 2147483650))); +print_r(unpack("L", pack("L", 4294967295))); +print_r(unpack("L", pack("L", -2147483648))); + +print_r(unpack("N", pack("N", 65534))); +print_r(unpack("N", pack("N", 0))); +print_r(unpack("N", pack("N", 2147483650))); +print_r(unpack("N", pack("N", 4294967296))); +print_r(unpack("N", pack("N", -2147483648))); +print_r(unpack("N", pack("N", -30000))); + +print_r(unpack("S", pack("S", 65534))); +print_r(unpack("S", pack("S", 65537))); +print_r(unpack("S", pack("S", 0))); +print_r(unpack("S", pack("S", -1000))); +print_r(unpack("S", pack("S", -64434))); +print_r(unpack("S", pack("S", -65535))); + +print_r(unpack("V", pack("V", 65534))); +print_r(unpack("V", pack("V", 0))); +print_r(unpack("V", pack("V", 2147483650))); +print_r(unpack("V", pack("V", 4294967296))); +print_r(unpack("V", pack("V", -2147483648))); + +print_r(unpack("a", pack("a", "hello world"))); +print_r(unpack("a*", pack("a*", "hello world"))); + +print_r(unpack("c", pack("c", -127))); +print_r(unpack("c", pack("c", 127))); +print_r(unpack("c", pack("c", 255))); +print_r(unpack("c", pack("c", -129))); + +print_r(unpack("h", pack("h", 3000000))); + +print_r(unpack("i", pack("i", 65534))); +print_r(unpack("i", pack("i", 0))); +print_r(unpack("i", pack("i", -1000))); +print_r(unpack("i", pack("i", -64434))); +print_r(unpack("i", pack("i", -65535))); +print_r(unpack("i", pack("i", -2147483647))); + +print_r(unpack("l", pack("l", 65534))); +print_r(unpack("l", pack("l", 0))); +print_r(unpack("l", pack("l", 2147483650))); +print_r(unpack("l", pack("l", 4294967296))); +print_r(unpack("l", pack("l", -2147483648))); + +print_r(unpack("n", pack("n", 65534))); +print_r(unpack("n", pack("n", 65537))); +print_r(unpack("n", pack("n", 0))); +print_r(unpack("n", pack("n", -1000))); +print_r(unpack("n", pack("n", -64434))); +print_r(unpack("n", pack("n", -65535))); + +print_r(unpack("s", pack("s", 32767))); +print_r(unpack("s", pack("s", 65535))); +print_r(unpack("s", pack("s", 0))); +print_r(unpack("s", pack("s", -1000))); +print_r(unpack("s", pack("s", -64434))); +print_r(unpack("s", pack("s", -65535))); + +print_r(unpack("v", pack("v", 65534))); +print_r(unpack("v", pack("v", 65537))); +print_r(unpack("v", pack("v", 0))); +print_r(unpack("v", pack("v", -1000))); +print_r(unpack("v", pack("v", -64434))); +print_r(unpack("v", pack("v", -65535))); +?> +--EXPECT-- +Array +( + [1] => h +) +Array +( + [1] => hello world +) +"hello " +Array +( + [1] => 129 +) +Array +( + [1] => 127 +) +Array +( + [1] => 255 +) +Array +( + [1] => 127 +) +Array +( + [1] => 4 +) +Array +( + [1] => 65534 +) +Array +( + [1] => 0 +) +Array +( + [1] => -1000 +) +Array +( + [1] => -64434 +) +Array +( + [1] => 0 +) +Array +( + [1] => -2147483648 +) +Array +( + [1] => 65534 +) +Array +( + [1] => 0 +) +Array +( + [1] => -2147483646 +) +Array +( + [1] => -1 +) +Array +( + [1] => -2147483648 +) +Array +( + [1] => 65534 +) +Array +( + [1] => 0 +) +Array +( + [1] => -2147483646 +) +Array +( + [1] => 0 +) +Array +( + [1] => -2147483648 +) +Array +( + [1] => -30000 +) +Array +( + [1] => 65534 +) +Array +( + [1] => 1 +) +Array +( + [1] => 0 +) +Array +( + [1] => 64536 +) +Array +( + [1] => 1102 +) +Array +( + [1] => 1 +) +Array +( + [1] => 65534 +) +Array +( + [1] => 0 +) +Array +( + [1] => -2147483646 +) +Array +( + [1] => 0 +) +Array +( + [1] => -2147483648 +) +Array +( + [1] => h +) +Array +( + [1] => hello world +) +Array +( + [1] => -127 +) +Array +( + [1] => 127 +) +Array +( + [1] => -1 +) +Array +( + [1] => 127 +) +Array +( + [1] => 3 +) +Array +( + [1] => 65534 +) +Array +( + [1] => 0 +) +Array +( + [1] => -1000 +) +Array +( + [1] => -64434 +) +Array +( + [1] => -65535 +) +Array +( + [1] => -2147483647 +) +Array +( + [1] => 65534 +) +Array +( + [1] => 0 +) +Array +( + [1] => -2147483646 +) +Array +( + [1] => 0 +) +Array +( + [1] => -2147483648 +) +Array +( + [1] => 65534 +) +Array +( + [1] => 1 +) +Array +( + [1] => 0 +) +Array +( + [1] => 64536 +) +Array +( + [1] => 1102 +) +Array +( + [1] => 1 +) +Array +( + [1] => 32767 +) +Array +( + [1] => -1 +) +Array +( + [1] => 0 +) +Array +( + [1] => -1000 +) +Array +( + [1] => 1102 +) +Array +( + [1] => 1 +) +Array +( + [1] => 65534 +) +Array +( + [1] => 1 +) +Array +( + [1] => 0 +) +Array +( + [1] => 64536 +) +Array +( + [1] => 1102 +) +Array +( + [1] => 1 +) diff --git a/ext/standard/tests/strings/pathinfo.phpt b/ext/standard/tests/strings/pathinfo.phpt index c1d58f05b..d9c3a2ed6 100644 --- a/ext/standard/tests/strings/pathinfo.phpt +++ b/ext/standard/tests/strings/pathinfo.phpt @@ -57,7 +57,7 @@ array(4) { } array(3) { ["dirname"]=> - string(1) "/" + string(1) "%e" ["basename"]=> string(0) "" ["filename"]=> @@ -75,7 +75,7 @@ array(4) { } array(4) { ["dirname"]=> - string(1) "/" + string(1) "%e" ["basename"]=> string(1) "." ["extension"]=> @@ -96,13 +96,13 @@ array(4) { string(12) "pathinfo.php" string(8) "pathinfo" string(3) "php" -string(%d) "%s/strings" -string(%d) "%s/strings" +string(%d) "%s%estrings" +string(%d) "%s%estrings" string(12) "pathinfo.php" string(3) "php" string(12) "pathinfo.php" -string(%d) "%s/strings" +string(%d) "%s%estrings" string(12) "pathinfo.php" -string(%d) "%s/strings" -string(%d) "%s/strings" +string(%d) "%s%estrings" +string(%d) "%s%estrings" Done diff --git a/ext/standard/tests/strings/php_strip_whitespace.phpt b/ext/standard/tests/strings/php_strip_whitespace.phpt new file mode 100644 index 000000000..4f7ef909e --- /dev/null +++ b/ext/standard/tests/strings/php_strip_whitespace.phpt @@ -0,0 +1,52 @@ +--TEST-- +php_strip_whitespace() tests +--FILE-- +<?php + +$filename = dirname(__FILE__)."/php_strip_whitespace.dat"; + +var_dump(php_strip_whitespace()); +var_dump(php_strip_whitespace($filename)); + +$data = '/* test comment */'; +file_put_contents($filename, $data); +var_dump(php_strip_whitespace($filename)); + +$data = '<?php /* test comment */ ?>'; +file_put_contents($filename, $data); +var_dump(php_strip_whitespace($filename)); + +$data = '<?php +/* test class */ +class test { + + /* function foo () */ + + function foo () /* {{{ */ + { + + + echo $var; //does not exist + } + /* }}} */ + +} +?>'; + +file_put_contents($filename, $data); +var_dump(php_strip_whitespace($filename)); + +@unlink($filename); +echo "Done\n"; +?> +--EXPECTF-- +Warning: php_strip_whitespace() expects exactly 1 parameter, 0 given in %s on line %d +bool(false) + +Warning: php_strip_whitespace(%sphp_strip_whitespace.dat): failed to open stream: No such file or directory in %s on line %d +string(0) "" +string(18) "/* test comment */" +string(9) "<?php ?>" +string(55) "<?php + class test { function foo () { echo $var; } } ?>" +Done diff --git a/ext/standard/tests/strings/printf.phpt b/ext/standard/tests/strings/printf.phpt new file mode 100755 index 000000000..13a8ed071 --- /dev/null +++ b/ext/standard/tests/strings/printf.phpt @@ -0,0 +1,697 @@ +--TEST-- +Test printf() function (32bit) +--INI-- +precision=14 +--SKIPIF-- +<?php +if (PHP_INT_MAX > 2147483647) { + die("skip 32bit test only"); +} +?> +--FILE-- +<?php + +/* Various input arrays for different format types */ + +$float_variation = array( "%f", "%-f", "%+f", "%7.2f", "%-7.2f", "%07.2f", "%-07.2f", "%'#7.2f" ); +$float_numbers = array( 0, 1, -1, 0.32, -0.32, 3.4. -3.4, 2.54, -2.54, 1.2345678e99, -1.2345678e99 ); + +$int_variation = array( "%d", "%-d", "%+d", "%7.2d", "%-7.2d", "%07.2d", "%-07.2d", "%'#7.2d" ); +$int_numbers = array( 0, 1, -1, 2.7, -2.7, 23333333, -23333333, "1234" ); + +$char_variation = array( 'a', "a", 67, -67, 99 ); + +$string_variation = array( "%5s", "%-5s", "%05s", "%'#5s" ); +$strings = array( NULL, "abc", 'aaa' ); + +/* Checking warning messages */ + +/* Zero argument */ +echo "\n*** Output for zero argument ***\n"; +printf(); + +/* Number of arguments not matching as specified in format field */ +echo "\n*** Output for insufficient number of arguments ***\n"; +$string = "dingy%sflem%dwombat"; +$nbr = 5; +$name = "voudras"; +printf("%d $string %s", $nbr, $name); + + +/* Scalar argument */ +echo "\n*** Output for scalar argument ***\n"; +printf(3); + +/* NULL argument */ +echo "\n*** Output for NULL as argument ***\n"; +printf(NULL); + + +/* Float type variations */ + +$counter = 1; +echo "\n\n*** Output for float type ***\n"; +echo "\n Input Float numbers variation array is:\n"; +print_r($float_numbers); + +foreach( $float_variation as $float_var ) +{ + echo "\n\nFloat Iteration $counter"; + foreach( $float_numbers as $float_num ) + { + echo "\n"; + printf( $float_var, $float_num ); + } + $counter++; +} + + +/* Integer type variations */ + +$counter = 1; +echo "\n\n*** Output for integer type ***\n"; +echo "\n Input Integer numbers variation array is:\n"; +print_r($int_numbers); + +foreach( $int_variation as $int_var ) +{ + echo "\n\nInteger Iteration $counter"; + foreach( $int_numbers as $int_num ) + { + echo "\n"; + printf( $int_var, $int_num ); + } + $counter++; +} + + +/* Binary type variations */ + +echo "\n\n*** Output for binary type ***\n"; +echo "\n Input numbers variation array is:\n"; +print_r($int_numbers); + + foreach( $int_numbers as $bin_num ) + { + echo "\n"; + printf( "%b", $bin_num ); + } + + +/* Chararter type variations */ +echo "\n\n*** Output for char type ***\n"; +echo "\n Input Characters variation array is:\n"; +print_r($char_variation); + +foreach( $char_variation as $char ) +{ + echo "\n"; + printf( "%c", $char ); +} + +/* Scientific type variations */ +echo "\n\n*** Output for scientific type ***\n"; +echo "\n Input numbers variation array is:\n"; +print_r($int_numbers); + +foreach( $int_numbers as $num ) +{ + echo "\n"; + printf( "%e", $num ); +} + +/* Unsigned Integer type variation */ +echo "\n\n*** Output for unsigned integer type ***\n"; +echo "\n Input Integer numbers variation array is:\n"; +print_r($int_numbers); + +foreach( $int_numbers as $unsig_num ) +{ + echo "\n"; + printf( "%u", $unsig_num ); +} + +/* Octal type variations */ +echo "\n\n*** Output for octal type ***\n"; +echo "\n Input numbers variation array is:\n"; +print_r($int_numbers); + +foreach( $int_numbers as $octal_num ) +{ + echo "\n"; + printf( "%o", $octal_num ); +} + +/* Hexadecimal type variations */ +echo "\n\n*** Output for hexadecimal type ***\n"; +echo "\n Input numbers variation array is:\n"; +print_r($int_numbers); + +foreach( $int_numbers as $hexa_num ) +{ + echo "\n"; + printf( "%x", $hexa_num ); +} + +/* String type variations */ +echo "\n\n*** Output for string type ***\n"; +echo "\n Input Strings format variation array is:\n"; +print_r($string_variation); +echo "\n Input strings variation array is:\n"; +print_r($strings); + +foreach( $string_variation as $string_var ) +{ + foreach( $strings as $str ) + { + echo "\n"; + printf( $string_var, $str ); + } +} + + +/* variations of %g type */ +$format_g = array("%g", "%.0g", "%+g", "%-g", "%-1.2g", "%+1.2g", "%G", "%.0G", "%+G", "%-G", "%-1.2G", "%+1.2G"); + +echo "\n\n*** Output for '%g' type ***\n"; +echo "\n Input format variation array is:\n"; +print_r($format_g); + +foreach( $format_g as $formatg ) +{ + printf("\n$formatg",123456); + printf("\n$formatg",-123456); +} + + +/* Some more typical cases */ + +$tempnum = 12345; +$tempstring = "abcdefghjklmnpqrstuvwxyz"; + +echo"\n\n*** Output for '%%%.2f' as the format parameter ***\n"; +printf("%%%.2f",1.23456789e10); + +echo"\n\n*** Output for '%%' as the format parameter ***\n"; +printf("%%",1.23456789e10); + +echo"\n\n*** Output for precision value more than maximum ***\n"; +printf("%.988f",1.23456789e10); + +echo"\n\n*** Output for invalid width(-15) specifier ***\n"; +printf("%030.-15s", $tempstring); + +echo"\n\n*** Output for '%F' as the format parameter ***\n"; +printf("%F",1.23456789e10); + +echo"\n\n*** Output for '%X' as the format parameter ***\n"; +printf("%X",12); + +echo"\n\n*** Output with no format parameter ***\n"; +printf($tempnum); + +echo"\n\n*** Output for multiple format parameters ***\n"; +printf("%d %s %d\n", $tempnum, $tempstring, $tempnum); + +echo"\n\n*** Output for excess of mixed type arguments ***\n"; +printf("%s", $tempstring, $tempstring, $tempstring); + +echo"\n\n*** Output for string format parameter and integer type argument ***\n"; +printf("%s", $tempnum); + +echo"\n\n*** Output for integer format parameter and string type argument ***\n"; +printf("%d", $tempstring); + + +?> +--EXPECTF-- +*** Output for zero argument *** + +Warning: Wrong parameter count for printf() in %s on line %d + +*** Output for insufficient number of arguments *** + +Warning: printf(): Too few arguments in %s on line %d + +*** Output for scalar argument *** +3 +*** Output for NULL as argument *** + + +*** Output for float type *** + + Input Float numbers variation array is: +Array +( + [0] => 0 + [1] => 1 + [2] => -1 + [3] => 0.32 + [4] => -0.32 + [5] => 3.4-3.4 + [6] => 2.54 + [7] => -2.54 + [8] => 1.2345678E+99 + [9] => -1.2345678E+99 +) + + +Float Iteration 1 +0.000000 +1.000000 +-1.000000 +0.320000 +-0.320000 +3.400000 +2.540000 +-2.540000 +1234567%d.000000 +-1234567%d.000000 + +Float Iteration 2 +0.000000 +1.000000 +-1.000000 +0.320000 +-0.320000 +3.400000 +2.540000 +-2.540000 +1234567%d.000000 +-1234567%d.000000 + +Float Iteration 3 ++0.000000 ++1.000000 +-1.000000 ++0.320000 +-0.320000 ++3.400000 ++2.540000 +-2.540000 ++1234567%d.000000 +-1234567%d.000000 + +Float Iteration 4 + 0.00 + 1.00 + -1.00 + 0.32 + -0.32 + 3.40 + 2.54 + -2.54 +1234567%d.00 +-1234567%d.00 + +Float Iteration 5 +0.00 +1.00 +-1.00 +0.32 +-0.32 +3.40 +2.54 +-2.54 +1234567%d.00 +-1234567%d.00 + +Float Iteration 6 +0000.00 +0001.00 +-001.00 +0000.32 +-000.32 +0003.40 +0002.54 +-002.54 +1234567%d.00 +-1234567%d.00 + +Float Iteration 7 +0.00000 +1.00000 +-1.0000 +0.32000 +-0.3200 +3.40000 +2.54000 +-2.5400 +1234567%d.00 +-1234567%d.00 + +Float Iteration 8 +###0.00 +###1.00 +##-1.00 +###0.32 +##-0.32 +###3.40 +###2.54 +##-2.54 +1234567%d.00 +-1234567%d.00 + +*** Output for integer type *** + + Input Integer numbers variation array is: +Array +( + [0] => 0 + [1] => 1 + [2] => -1 + [3] => 2.7 + [4] => -2.7 + [5] => 23333333 + [6] => -23333333 + [7] => 1234 +) + + +Integer Iteration 1 +0 +1 +-1 +2 +-2 +23333333 +-23333333 +1234 + +Integer Iteration 2 +0 +1 +-1 +2 +-2 +23333333 +-23333333 +1234 + +Integer Iteration 3 ++0 ++1 +-1 ++2 +-2 ++23333333 +-23333333 ++1234 + +Integer Iteration 4 + 0 + 1 + -1 + 2 + -2 +23333333 +-23333333 + 1234 + +Integer Iteration 5 +0 +1 +-1 +2 +-2 +23333333 +-23333333 +1234 + +Integer Iteration 6 +0000000 +0000001 +-000001 +0000002 +-000002 +23333333 +-23333333 +0001234 + +Integer Iteration 7 +0 +1 +-1 +2 +-2 +23333333 +-23333333 +1234 + +Integer Iteration 8 +######0 +######1 +#####-1 +######2 +#####-2 +23333333 +-23333333 +###1234 + +*** Output for binary type *** + + Input numbers variation array is: +Array +( + [0] => 0 + [1] => 1 + [2] => -1 + [3] => 2.7 + [4] => -2.7 + [5] => 23333333 + [6] => -23333333 + [7] => 1234 +) + +0 +1 +11111111111111111111111111111111 +10 +11111111111111111111111111111110 +1011001000000100111010101 +11111110100110111111011000101011 +10011010010 + +*** Output for char type *** + + Input Characters variation array is: +Array +( + [0] => a + [1] => a + [2] => 67 + [3] => -67 + [4] => 99 +) + + + +C +½ +c + +*** Output for scientific type *** + + Input numbers variation array is: +Array +( + [0] => 0 + [1] => 1 + [2] => -1 + [3] => 2.7 + [4] => -2.7 + [5] => 23333333 + [6] => -23333333 + [7] => 1234 +) + +0.000000e+0 +1.000000e+0 +-1.000000e+0 +2.700000e+0 +-2.700000e+0 +2.333333e+7 +-2.333333e+7 +1.234000e+3 + +*** Output for unsigned integer type *** + + Input Integer numbers variation array is: +Array +( + [0] => 0 + [1] => 1 + [2] => -1 + [3] => 2.7 + [4] => -2.7 + [5] => 23333333 + [6] => -23333333 + [7] => 1234 +) + +0 +1 +4294967295 +2 +4294967294 +23333333 +4271633963 +1234 + +*** Output for octal type *** + + Input numbers variation array is: +Array +( + [0] => 0 + [1] => 1 + [2] => -1 + [3] => 2.7 + [4] => -2.7 + [5] => 23333333 + [6] => -23333333 + [7] => 1234 +) + +0 +1 +37777777777 +2 +37777777776 +131004725 +37646773053 +2322 + +*** Output for hexadecimal type *** + + Input numbers variation array is: +Array +( + [0] => 0 + [1] => 1 + [2] => -1 + [3] => 2.7 + [4] => -2.7 + [5] => 23333333 + [6] => -23333333 + [7] => 1234 +) + +0 +1 +ffffffff +2 +fffffffe +16409d5 +fe9bf62b +4d2 + +*** Output for string type *** + + Input Strings format variation array is: +Array +( + [0] => %5s + [1] => %-5s + [2] => %05s + [3] => %'#5s +) + + Input strings variation array is: +Array +( + [0] => + [1] => abc + [2] => aaa +) + + + abc + aaa + +abc +aaa +00000 +00abc +00aaa +##### +##abc +##aaa + +*** Output for '%g' type *** + + Input format variation array is: +Array +( + [0] => %g + [1] => %.0g + [2] => %+g + [3] => %-g + [4] => %-1.2g + [5] => %+1.2g + [6] => %G + [7] => %.0G + [8] => %+G + [9] => %-G + [10] => %-1.2G + [11] => %+1.2G +) + +123456 +-123456 +1.0e+5 +-1.0e+5 ++123456 +-123456 +123456 +-123456 +120000 +-120000 ++120000 +-120000 +123456 +-123456 +1.0E+5 +-1.0E+5 ++123456 +-123456 +123456 +-123456 +120000 +-120000 ++120000 +-120000 + +*** Output for '%%%.2f' as the format parameter *** +%12345678900.00 + +*** Output for '%%' as the format parameter *** +% + +*** Output for precision value more than maximum *** +12345678900.0000000000000000000000000000000000000000 + +*** Output for invalid width(-15) specifier *** +15s + +*** Output for '%F' as the format parameter *** +12345678900.000000 + +*** Output for '%X' as the format parameter *** +C + +*** Output with no format parameter *** +12345 + +*** Output for multiple format parameters *** +12345 abcdefghjklmnpqrstuvwxyz 12345 + + +*** Output for excess of mixed type arguments *** +abcdefghjklmnpqrstuvwxyz + +*** Output for string format parameter and integer type argument *** +12345 + +*** Output for integer format parameter and string type argument *** +0 diff --git a/ext/standard/tests/strings/printf_64bit.phpt b/ext/standard/tests/strings/printf_64bit.phpt new file mode 100755 index 000000000..01ba34182 --- /dev/null +++ b/ext/standard/tests/strings/printf_64bit.phpt @@ -0,0 +1,695 @@ +--TEST-- +Test printf() function (64bit) +--SKIPIF-- +<?php +if (!(PHP_INT_MAX > 2147483647)) { + die("skip 64bit test only"); +} +?> +--FILE-- +<?php + +/* Various input arrays for different format types */ + +$float_variation = array( "%f", "%-f", "%+f", "%7.2f", "%-7.2f", "%07.2f", "%-07.2f", "%'#7.2f" ); +$float_numbers = array( 0, 1, -1, 0.32, -0.32, 3.4. -3.4, 2.54, -2.54, 1.2345678e99, -1.2345678e99 ); + +$int_variation = array( "%d", "%-d", "%+d", "%7.2d", "%-7.2d", "%07.2d", "%-07.2d", "%'#7.2d" ); +$int_numbers = array( 0, 1, -1, 2.7, -2.7, 23333333, -23333333, "1234" ); + +$char_variation = array( 'a', "a", 67, -67, 99 ); + +$string_variation = array( "%5s", "%-5s", "%05s", "%'#5s" ); +$strings = array( NULL, "abc", 'aaa' ); + +/* Checking warning messages */ + +/* Zero argument */ +echo "\n*** Output for zero argument ***\n"; +printf(); + +/* Number of arguments not matching as specified in format field */ +echo "\n*** Output for insufficient number of arguments ***\n"; +$string = "dingy%sflem%dwombat"; +$nbr = 5; +$name = "voudras"; +printf("%d $string %s", $nbr, $name); + + +/* Scalar argument */ +echo "\n*** Output for scalar argument ***\n"; +printf(3); + +/* NULL argument */ +echo "\n*** Output for NULL as argument ***\n"; +printf(NULL); + + +/* Float type variations */ + +$counter = 1; +echo "\n\n*** Output for float type ***\n"; +echo "\n Input Float numbers variation array is:\n"; +print_r($float_numbers); + +foreach( $float_variation as $float_var ) +{ + echo "\n\nFloat Iteration $counter"; + foreach( $float_numbers as $float_num ) + { + echo "\n"; + printf( $float_var, $float_num ); + } + $counter++; +} + + +/* Integer type variations */ + +$counter = 1; +echo "\n\n*** Output for integer type ***\n"; +echo "\n Input Integer numbers variation array is:\n"; +print_r($int_numbers); + +foreach( $int_variation as $int_var ) +{ + echo "\n\nInteger Iteration $counter"; + foreach( $int_numbers as $int_num ) + { + echo "\n"; + printf( $int_var, $int_num ); + } + $counter++; +} + + +/* Binary type variations */ + +echo "\n\n*** Output for binary type ***\n"; +echo "\n Input numbers variation array is:\n"; +print_r($int_numbers); + + foreach( $int_numbers as $bin_num ) + { + echo "\n"; + printf( "%b", $bin_num ); + } + + +/* Chararter type variations */ +echo "\n\n*** Output for char type ***\n"; +echo "\n Input Characters variation array is:\n"; +print_r($char_variation); + +foreach( $char_variation as $char ) +{ + echo "\n"; + printf( "%c", $char ); +} + +/* Scientific type variations */ +echo "\n\n*** Output for scientific type ***\n"; +echo "\n Input numbers variation array is:\n"; +print_r($int_numbers); + +foreach( $int_numbers as $num ) +{ + echo "\n"; + printf( "%e", $num ); +} + +/* Unsigned Integer type variation */ +echo "\n\n*** Output for unsigned integer type ***\n"; +echo "\n Input Integer numbers variation array is:\n"; +print_r($int_numbers); + +foreach( $int_numbers as $unsig_num ) +{ + echo "\n"; + printf( "%u", $unsig_num ); +} + +/* Octal type variations */ +echo "\n\n*** Output for octal type ***\n"; +echo "\n Input numbers variation array is:\n"; +print_r($int_numbers); + +foreach( $int_numbers as $octal_num ) +{ + echo "\n"; + printf( "%o", $octal_num ); +} + +/* Hexadecimal type variations */ +echo "\n\n*** Output for hexadecimal type ***\n"; +echo "\n Input numbers variation array is:\n"; +print_r($int_numbers); + +foreach( $int_numbers as $hexa_num ) +{ + echo "\n"; + printf( "%x", $hexa_num ); +} + +/* String type variations */ +echo "\n\n*** Output for string type ***\n"; +echo "\n Input Strings format variation array is:\n"; +print_r($string_variation); +echo "\n Input strings variation array is:\n"; +print_r($strings); + +foreach( $string_variation as $string_var ) +{ + foreach( $strings as $str ) + { + echo "\n"; + printf( $string_var, $str ); + } +} + + +/* variations of %g type */ +$format_g = array("%g", "%.0g", "%+g", "%-g", "%-1.2g", "%+1.2g", "%G", "%.0G", "%+G", "%-G", "%-1.2G", "%+1.2G"); + +echo "\n\n*** Output for '%g' type ***\n"; +echo "\n Input format variation array is:\n"; +print_r($format_g); + +foreach( $format_g as $formatg ) +{ + printf("\n$formatg",123456); + printf("\n$formatg",-123456); +} + + +/* Some more typical cases */ + +$tempnum = 12345; +$tempstring = "abcdefghjklmnpqrstuvwxyz"; + +echo"\n\n*** Output for '%%%.2f' as the format parameter ***\n"; +printf("%%%.2f",1.23456789e10); + +echo"\n\n*** Output for '%%' as the format parameter ***\n"; +printf("%%",1.23456789e10); + +echo"\n\n*** Output for precision value more than maximum ***\n"; +printf("%.988f",1.23456789e10); + +echo"\n\n*** Output for invalid width(-15) specifier ***\n"; +printf("%030.-15s", $tempstring); + +echo"\n\n*** Output for '%F' as the format parameter ***\n"; +printf("%F",1.23456789e10); + +echo"\n\n*** Output for '%X' as the format parameter ***\n"; +printf("%X",12); + +echo"\n\n*** Output with no format parameter ***\n"; +printf($tempnum); + +echo"\n\n*** Output for multiple format parameters ***\n"; +printf("%d %s %d\n", $tempnum, $tempstring, $tempnum); + +echo"\n\n*** Output for excess of mixed type arguments ***\n"; +printf("%s", $tempstring, $tempstring, $tempstring); + +echo"\n\n*** Output for string format parameter and integer type argument ***\n"; +printf("%s", $tempnum); + +echo"\n\n*** Output for integer format parameter and string type argument ***\n"; +printf("%d", $tempstring); + + +?> +--EXPECTF-- +*** Output for zero argument *** + +Warning: Wrong parameter count for printf() in %s on line %d + +*** Output for insufficient number of arguments *** + +Warning: printf(): Too few arguments in %s on line %d + +*** Output for scalar argument *** +3 +*** Output for NULL as argument *** + + +*** Output for float type *** + + Input Float numbers variation array is: +Array +( + [0] => 0 + [1] => 1 + [2] => -1 + [3] => 0.32 + [4] => -0.32 + [5] => 3.4-3.4 + [6] => 2.54 + [7] => -2.54 + [8] => 1.2345678E+99 + [9] => -1.2345678E+99 +) + + +Float Iteration 1 +0.000000 +1.000000 +-1.000000 +0.320000 +-0.320000 +3.400000 +2.540000 +-2.540000 +1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.000000 +-1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.000000 + +Float Iteration 2 +0.000000 +1.000000 +-1.000000 +0.320000 +-0.320000 +3.400000 +2.540000 +-2.540000 +1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.000000 +-1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.000000 + +Float Iteration 3 ++0.000000 ++1.000000 +-1.000000 ++0.320000 +-0.320000 ++3.400000 ++2.540000 +-2.540000 ++1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.000000 +-1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.000000 + +Float Iteration 4 + 0.00 + 1.00 + -1.00 + 0.32 + -0.32 + 3.40 + 2.54 + -2.54 +1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.00 +-1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.00 + +Float Iteration 5 +0.00 +1.00 +-1.00 +0.32 +-0.32 +3.40 +2.54 +-2.54 +1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.00 +-1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.00 + +Float Iteration 6 +0000.00 +0001.00 +-001.00 +0000.32 +-000.32 +0003.40 +0002.54 +-002.54 +1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.00 +-1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.00 + +Float Iteration 7 +0.00000 +1.00000 +-1.0000 +0.32000 +-0.3200 +3.40000 +2.54000 +-2.5400 +1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.00 +-1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.00 + +Float Iteration 8 +###0.00 +###1.00 +##-1.00 +###0.32 +##-0.32 +###3.40 +###2.54 +##-2.54 +1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.00 +-1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.00 + +*** Output for integer type *** + + Input Integer numbers variation array is: +Array +( + [0] => 0 + [1] => 1 + [2] => -1 + [3] => 2.7 + [4] => -2.7 + [5] => 23333333 + [6] => -23333333 + [7] => 1234 +) + + +Integer Iteration 1 +0 +1 +-1 +2 +-2 +23333333 +-23333333 +1234 + +Integer Iteration 2 +0 +1 +-1 +2 +-2 +23333333 +-23333333 +1234 + +Integer Iteration 3 ++0 ++1 +-1 ++2 +-2 ++23333333 +-23333333 ++1234 + +Integer Iteration 4 + 0 + 1 + -1 + 2 + -2 +23333333 +-23333333 + 1234 + +Integer Iteration 5 +0 +1 +-1 +2 +-2 +23333333 +-23333333 +1234 + +Integer Iteration 6 +0000000 +0000001 +-000001 +0000002 +-000002 +23333333 +-23333333 +0001234 + +Integer Iteration 7 +0 +1 +-1 +2 +-2 +23333333 +-23333333 +1234 + +Integer Iteration 8 +######0 +######1 +#####-1 +######2 +#####-2 +23333333 +-23333333 +###1234 + +*** Output for binary type *** + + Input numbers variation array is: +Array +( + [0] => 0 + [1] => 1 + [2] => -1 + [3] => 2.7 + [4] => -2.7 + [5] => 23333333 + [6] => -23333333 + [7] => 1234 +) + +0 +1 +1111111111111111111111111111111111111111111111111111111111111111 +10 +1111111111111111111111111111111111111111111111111111111111111110 +1011001000000100111010101 +1111111111111111111111111111111111111110100110111111011000101011 +10011010010 + +*** Output for char type *** + + Input Characters variation array is: +Array +( + [0] => a + [1] => a + [2] => 67 + [3] => -67 + [4] => 99 +) + + + +C +½ +c + +*** Output for scientific type *** + + Input numbers variation array is: +Array +( + [0] => 0 + [1] => 1 + [2] => -1 + [3] => 2.7 + [4] => -2.7 + [5] => 23333333 + [6] => -23333333 + [7] => 1234 +) + +0.000000e+0 +1.000000e+0 +-1.000000e+0 +2.700000e+0 +-2.700000e+0 +2.333333e+7 +-2.333333e+7 +1.234000e+3 + +*** Output for unsigned integer type *** + + Input Integer numbers variation array is: +Array +( + [0] => 0 + [1] => 1 + [2] => -1 + [3] => 2.7 + [4] => -2.7 + [5] => 23333333 + [6] => -23333333 + [7] => 1234 +) + +0 +1 +4294967295 +2 +4294967294 +23333333 +4271633963 +1234 + +*** Output for octal type *** + + Input numbers variation array is: +Array +( + [0] => 0 + [1] => 1 + [2] => -1 + [3] => 2.7 + [4] => -2.7 + [5] => 23333333 + [6] => -23333333 + [7] => 1234 +) + +0 +1 +1777777777777777777777 +2 +1777777777777777777776 +131004725 +1777777777777646773053 +2322 + +*** Output for hexadecimal type *** + + Input numbers variation array is: +Array +( + [0] => 0 + [1] => 1 + [2] => -1 + [3] => 2.7 + [4] => -2.7 + [5] => 23333333 + [6] => -23333333 + [7] => 1234 +) + +0 +1 +ffffffffffffffff +2 +fffffffffffffffe +16409d5 +fffffffffe9bf62b +4d2 + +*** Output for string type *** + + Input Strings format variation array is: +Array +( + [0] => %5s + [1] => %-5s + [2] => %05s + [3] => %'#5s +) + + Input strings variation array is: +Array +( + [0] => + [1] => abc + [2] => aaa +) + + + abc + aaa + +abc +aaa +00000 +00abc +00aaa +##### +##abc +##aaa + +*** Output for '%g' type *** + + Input format variation array is: +Array +( + [0] => %g + [1] => %.0g + [2] => %+g + [3] => %-g + [4] => %-1.2g + [5] => %+1.2g + [6] => %G + [7] => %.0G + [8] => %+G + [9] => %-G + [10] => %-1.2G + [11] => %+1.2G +) + +123456 +-123456 +1.0e+5 +-1.0e+5 ++123456 +-123456 +123456 +-123456 +120000 +-120000 ++120000 +-120000 +123456 +-123456 +1.0E+5 +-1.0E+5 ++123456 +-123456 +123456 +-123456 +120000 +-120000 ++120000 +-120000 + +*** Output for '%%%.2f' as the format parameter *** +%12345678900.00 + +*** Output for '%%' as the format parameter *** +% + +*** Output for precision value more than maximum *** +12345678900.0000000000000000000000000000000000000000 + +*** Output for invalid width(-15) specifier *** +15s + +*** Output for '%F' as the format parameter *** +12345678900.000000 + +*** Output for '%X' as the format parameter *** +C + +*** Output with no format parameter *** +12345 + +*** Output for multiple format parameters *** +12345 abcdefghjklmnpqrstuvwxyz 12345 + + +*** Output for excess of mixed type arguments *** +abcdefghjklmnpqrstuvwxyz + +*** Output for string format parameter and integer type argument *** +12345 + +*** Output for integer format parameter and string type argument *** +0 diff --git a/ext/standard/tests/strings/rtrim.phpt b/ext/standard/tests/strings/rtrim.phpt Binary files differnew file mode 100644 index 000000000..329ead420 --- /dev/null +++ b/ext/standard/tests/strings/rtrim.phpt diff --git a/ext/standard/tests/strings/sha1.phpt b/ext/standard/tests/strings/sha1.phpt index c405eedde..ed8f47457 100644 --- a/ext/standard/tests/strings/sha1.phpt +++ b/ext/standard/tests/strings/sha1.phpt @@ -2,13 +2,50 @@ sha1() with ASCII output --FILE-- <?php -echo sha1("abc")."\n"; -echo sha1("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq")."\n"; -echo sha1("a")."\n"; -echo sha1("0123456701234567012345670123456701234567012345670123456701234567")."\n"; + +$filename = dirname(__FILE__)."/sha1.dat"; +$a = array( + "abc", + "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", + "a", + "0123456701234567012345670123456701234567012345670123456701234567", + "" +); + +foreach ($a as $str) { + var_dump($val1 = sha1($str)); + file_put_contents($filename, $str); + var_dump($val2 = sha1_file($filename)); + var_dump($val1 === $val2); +} + +var_dump(sha1($str, true)); +var_dump(sha1_file($filename, true)); + +@unlink($filename); + +sha1_file($filename); + +echo "Done\n"; ?> ---EXPECT-- -a9993e364706816aba3e25717850c26c9cd0d89d -84983e441c3bd26ebaae4aa1f95129e5e54670f1 -86f7e437faa5a7fce15d1ddcb9eaeaea377667b8 -e0c094e867ef46c350ef54a7f59dd60bed92ae83 +--EXPECTF-- +string(40) "a9993e364706816aba3e25717850c26c9cd0d89d" +string(40) "a9993e364706816aba3e25717850c26c9cd0d89d" +bool(true) +string(40) "84983e441c3bd26ebaae4aa1f95129e5e54670f1" +string(40) "84983e441c3bd26ebaae4aa1f95129e5e54670f1" +bool(true) +string(40) "86f7e437faa5a7fce15d1ddcb9eaeaea377667b8" +string(40) "86f7e437faa5a7fce15d1ddcb9eaeaea377667b8" +bool(true) +string(40) "e0c094e867ef46c350ef54a7f59dd60bed92ae83" +string(40) "e0c094e867ef46c350ef54a7f59dd60bed92ae83" +bool(true) +string(40) "da39a3ee5e6b4b0d3255bfef95601890afd80709" +string(40) "da39a3ee5e6b4b0d3255bfef95601890afd80709" +bool(true) +string(20) "%s" +string(20) "%s" + +Warning: sha1_file(%ssha1.dat): failed to open stream: No such file or directory in %s on line %d +Done diff --git a/ext/standard/tests/strings/soundex.phpt b/ext/standard/tests/strings/soundex.phpt new file mode 100644 index 000000000..55769ad57 --- /dev/null +++ b/ext/standard/tests/strings/soundex.phpt @@ -0,0 +1,55 @@ +--TEST-- +soundex() tests +--FILE-- +<?php + +var_dump(soundex("")); +var_dump(soundex(-1)); +var_dump(soundex(array())); + +$array = array( +"From", +"that", +"time", +"on", +"Sam", +"thought", +"that", +"he", +"sensed", +"a", +"change", +"in", +"Gollum", +"again.", +"He was more fawning and would-be friendly; but Sam surprised some strange looks in his eyes at times, especially towards Frodo." +); + +foreach ($array as $str) { + var_dump(soundex($str)); +} + +echo "Done\n"; +?> +--EXPECTF-- +bool(false) +string(4) "0000" + +Warning: soundex() expects parameter 1 to be string, array given in %s on line %d +NULL +string(4) "F650" +string(4) "T300" +string(4) "T500" +string(4) "O500" +string(4) "S500" +string(4) "T230" +string(4) "T300" +string(4) "H000" +string(4) "S523" +string(4) "A000" +string(4) "C520" +string(4) "I500" +string(4) "G450" +string(4) "A250" +string(4) "H256" +Done diff --git a/ext/standard/tests/strings/sprintf_f.phpt b/ext/standard/tests/strings/sprintf_f.phpt index 6135270d2..6cba6d10b 100755 --- a/ext/standard/tests/strings/sprintf_f.phpt +++ b/ext/standard/tests/strings/sprintf_f.phpt @@ -37,4 +37,4 @@ string(7) "-5.60 " string(7) "-005.60" string(7) "-5.6000" -string(105) "12345678%d00000000000000000000000000000000000000000000000000.0000"
\ No newline at end of file +string(105) "1234567%d.0000" diff --git a/ext/standard/tests/strings/sprintf_f_2.phpt b/ext/standard/tests/strings/sprintf_f_2.phpt new file mode 100755 index 000000000..d6006356f --- /dev/null +++ b/ext/standard/tests/strings/sprintf_f_2.phpt @@ -0,0 +1,114 @@ +--TEST-- +sprintf %f #2 +--FILE-- +<?php +var_dump(sprintf("%.3F", 100.426)); +var_dump(sprintf("%.2F", 100.426)); +var_dump(sprintf("%d", 100.426)); +var_dump(sprintf("%d", 100.9)); +var_dump(sprintf("%o", 100.426)); +var_dump(sprintf("%o", 100.9)); + +/* copy & paste from the docs */ + +/* example#1: Argument swapping */ +$num = 100.1; +$location = "world"; + +$format = 'There are %d monkeys in the %s'; +var_dump(sprintf($format, $num, $location)); + +/* example#2: Argument swapping */ +$format = 'The %s contains %d monkeys'; +var_dump(sprintf($format, $num, $location)); + +/* example#3: Argument swapping */ +$format = 'The %2$s contains %1$d monkeys'; +var_dump(sprintf($format, $num, $location)); + +/* example#4: Argument swapping */ +$format = 'The %2$s contains %1$d monkeys. + That\'s a nice %2$s full of %1$d monkeys.'; +var_dump(sprintf($format, $num, $location)); + +/* example#5: various examples */ +$n = 43951789; +$u = -43951789; +$c = 65; // ASCII 65 is 'A' + +// notice the double %%, this prints a literal '%' character +var_dump(sprintf("%%b = '%b'", $n)); // binary representation +var_dump(sprintf("%%c = '%c'", $c)); // print the ascii character, same as chr() function +var_dump(sprintf("%%d = '%d'", $n)); // standard integer representation +var_dump(sprintf("%%e = '%e'", $n)); // scientific notation +var_dump(sprintf("%%u = '%u'", $n)); // unsigned integer representation of a positive integer +var_dump(sprintf("%%u = '%u'", $u)); // unsigned integer representation of a negative integer +var_dump(sprintf("%%f = '%f'", $n)); // floating point representation +var_dump(sprintf("%%o = '%o'", $n)); // octal representation +var_dump(sprintf("%%s = '%s'", $n)); // string representation +var_dump(sprintf("%%x = '%x'", $n)); // hexadecimal representation (lower-case) +var_dump(sprintf("%%X = '%X'", $n)); // hexadecimal representation (upper-case) + +var_dump(sprintf("%%+d = '%+d'", $n)); // sign specifier on a positive integer +var_dump(sprintf("%%+d = '%+d'", $u)); // sign specifier on a negative integer + + +/* example#6: string specifiers */ +$s = 'monkey'; +$t = 'many monkeys'; + +var_dump(sprintf("[%s]", $s)); // standard string output +var_dump(sprintf("[%10s]", $s)); // right-justification with spaces +var_dump(sprintf("[%-10s]", $s)); // left-justification with spaces +var_dump(sprintf("[%010s]", $s)); // zero-padding works on strings too +var_dump(sprintf("[%'#10s]", $s)); // use the custom padding character '#' +var_dump(sprintf("[%10.10s]", $t)); // left-justification but with a cutoff of 10 characters + +/* example#7: zero-padded integers */ +var_dump(sprintf("%04d-%02d-%02d", 2006, 12, 18)); + +/* example#8: formatting currency */ +$money1 = 68.75; +$money2 = 54.35; +$money = $money1 + $money2; +var_dump(sprintf("%01.2f", $money)); // output "123.10" + +/* example#9: scientific notation */ +$number = 362525200; + +var_dump(sprintf("%.3e", $number)); // outputs 3.63e+8 +?> +--EXPECT-- +string(7) "100.426" +string(6) "100.43" +string(3) "100" +string(3) "100" +string(3) "144" +string(3) "144" +string(34) "There are 100 monkeys in the world" +string(28) "The 100.1 contains 0 monkeys" +string(30) "The world contains 100 monkeys" +string(76) "The world contains 100 monkeys. + That's a nice world full of 100 monkeys." +string(33) "%b = '10100111101010011010101101'" +string(8) "%c = 'A'" +string(15) "%d = '43951789'" +string(18) "%e = '4.395179e+7'" +string(15) "%u = '43951789'" +string(17) "%u = '4251015507'" +string(22) "%f = '43951789.000000'" +string(16) "%o = '247523255'" +string(15) "%s = '43951789'" +string(14) "%x = '29ea6ad'" +string(14) "%X = '29EA6AD'" +string(17) "%+d = '+43951789'" +string(17) "%+d = '-43951789'" +string(8) "[monkey]" +string(12) "[ monkey]" +string(12) "[monkey ]" +string(12) "[0000monkey]" +string(12) "[####monkey]" +string(12) "[many monke]" +string(10) "2006-12-18" +string(6) "123.10" +string(8) "3.625e+8" diff --git a/ext/standard/tests/strings/sprintf_f_3.phpt b/ext/standard/tests/strings/sprintf_f_3.phpt new file mode 100755 index 000000000..0cf123998 --- /dev/null +++ b/ext/standard/tests/strings/sprintf_f_3.phpt @@ -0,0 +1,23 @@ +--TEST-- +sprintf %f #3 +--SKIPIF-- +<?php if(false == setlocale(LC_NUMERIC, "is_IS", "is_IS.UTF-8")) print "skip icelandic locale not supported"; ?> +--FILE-- +<?php +setlocale(LC_NUMERIC, "is_IS", "is_IS.UTF-8"); +var_dump(sprintf("%.3f", 100.426)); +var_dump(sprintf("%.2f", 100.426)); +var_dump(sprintf("%f'", 100.426)); + +$money1 = 68.75; +$money2 = 54.35; +$money = $money1 + $money2; +var_dump(sprintf("%01.2f", $money)); +var_dump(sprintf("%.3e", $money)); +?> +--EXPECT-- +string(7) "100,426" +string(6) "100,43" +string(11) "100,426000'" +string(6) "123,10" +string(8) "1.231e+2" diff --git a/ext/standard/tests/strings/str_ireplace.phpt b/ext/standard/tests/strings/str_ireplace.phpt new file mode 100644 index 000000000..4d4fee8f9 --- /dev/null +++ b/ext/standard/tests/strings/str_ireplace.phpt @@ -0,0 +1,101 @@ +--TEST-- +str_ireplace() tests +--FILE-- +<?php + +var_dump(str_ireplace()); +var_dump(str_ireplace("")); +var_dump(str_ireplace("", "")); +var_dump(str_ireplace("", "", "")); + +var_dump(str_ireplace("tt", "a", "ttttTttttttttTT")); +var_dump(str_ireplace("tt", "a", "ttttTttttttttTT", $count)); +var_dump($count); + +var_dump(str_ireplace("tt", "aa", "ttttTttttttttTT")); +var_dump(str_ireplace("tt", "aa", "ttttTttttttttTT", $count)); +var_dump($count); + +var_dump(str_ireplace("tt", "aaa", "ttttTttttttttTT")); +var_dump(str_ireplace("tt", "aaa", "ttttTttttttttTT", $count)); +var_dump($count); + +var_dump(str_ireplace("tt", "aaa", "ttttTttttttttTT")); +var_dump(str_ireplace("tt", "aaa", "ttttTttttttttTT", $count)); +var_dump($count); + +var_dump(str_ireplace(array("tt", "tt"), "aaa", "ttttTttttttttTT")); +var_dump(str_ireplace(array("tt", "tt"), array("aaa"), "ttttTttttttttTT")); +var_dump(str_ireplace(array("tt", "y"), array("aaa", "bbb"), "ttttTttttttttTT")); + +var_dump(str_ireplace(array("tt", "tt"), "aaa", "ttttTttttttttTT")); +var_dump(str_ireplace(array("tt", "tt"), array("aaa"), "ttttTttttttttTT")); +var_dump(str_ireplace(array("tt", "y"), array("aaa", "bbb"), "ttttTttttttttTT")); + +var_dump(str_ireplace(array("tt", "y"), array("aaa", "bbb"), array("ttttTttttttttTT", "aayyaayasdayYahsdYYY"))); +var_dump(str_ireplace(array("tt", "y"), array("aaa", "bbb"), array("key"=>"ttttTttttttttTT", "test"=>"aayyaayasdayYahsdYYY"))); +var_dump(str_ireplace(array("t"=>"tt", "y"=>"y"), array("a"=>"aaa", "b"=>"bbb"), array("key"=>"ttttTttttttttTT", "test"=>"aayyaayasdayYahsdYYY"))); + +/* separate testcase for str_ireplace() off-by-one */ + +$Data = "Change tracking and management software designed to watch + for abnormal system behavior.\nSuggest features, report bugs, or ask + questions here."; +var_dump($Data = str_ireplace("\r\n", "<br>", $Data)); +var_dump($Data = str_ireplace("\n", "<br>", $Data)); + + +echo "Done\n"; +?> +--EXPECTF-- +Warning: Wrong parameter count for str_ireplace() in %s on line %d +NULL + +Warning: Wrong parameter count for str_ireplace() in %s on line %d +NULL + +Warning: Wrong parameter count for str_ireplace() in %s on line %d +NULL +string(0) "" +string(8) "aaaaaaaT" +string(8) "aaaaaaaT" +int(7) +string(15) "aaaaaaaaaaaaaaT" +string(15) "aaaaaaaaaaaaaaT" +int(7) +string(22) "aaaaaaaaaaaaaaaaaaaaaT" +string(22) "aaaaaaaaaaaaaaaaaaaaaT" +int(7) +string(22) "aaaaaaaaaaaaaaaaaaaaaT" +string(22) "aaaaaaaaaaaaaaaaaaaaaT" +int(7) +string(22) "aaaaaaaaaaaaaaaaaaaaaT" +string(22) "aaaaaaaaaaaaaaaaaaaaaT" +string(22) "aaaaaaaaaaaaaaaaaaaaaT" +string(22) "aaaaaaaaaaaaaaaaaaaaaT" +string(22) "aaaaaaaaaaaaaaaaaaaaaT" +string(22) "aaaaaaaaaaaaaaaaaaaaaT" +array(2) { + [0]=> + string(22) "aaaaaaaaaaaaaaaaaaaaaT" + [1]=> + string(36) "aabbbbbbaabbbasdabbbbbbahsdbbbbbbbbb" +} +array(2) { + ["key"]=> + string(22) "aaaaaaaaaaaaaaaaaaaaaT" + ["test"]=> + string(36) "aabbbbbbaabbbasdabbbbbbahsdbbbbbbbbb" +} +array(2) { + ["key"]=> + string(22) "aaaaaaaaaaaaaaaaaaaaaT" + ["test"]=> + string(36) "aabbbbbbaabbbasdabbbbbbahsdbbbbbbbbb" +} +string(143) "Change tracking and management software designed to watch + for abnormal system behavior. +Suggest features, report bugs, or ask + questions here." +string(152) "Change tracking and management software designed to watch<br> for abnormal system behavior.<br>Suggest features, report bugs, or ask<br> questions here." +Done diff --git a/ext/standard/tests/strings/str_pad.phpt b/ext/standard/tests/strings/str_pad.phpt Binary files differnew file mode 100644 index 000000000..d6111b034 --- /dev/null +++ b/ext/standard/tests/strings/str_pad.phpt diff --git a/ext/standard/tests/strings/strcasecmp.phpt b/ext/standard/tests/strings/strcasecmp.phpt Binary files differnew file mode 100644 index 000000000..ee9799864 --- /dev/null +++ b/ext/standard/tests/strings/strcasecmp.phpt diff --git a/ext/standard/tests/strings/strcmp.phpt b/ext/standard/tests/strings/strcmp.phpt Binary files differnew file mode 100644 index 000000000..b27da6c37 --- /dev/null +++ b/ext/standard/tests/strings/strcmp.phpt diff --git a/ext/standard/tests/strings/stristr.phpt b/ext/standard/tests/strings/stristr.phpt new file mode 100644 index 000000000..5c617a20d --- /dev/null +++ b/ext/standard/tests/strings/stristr.phpt @@ -0,0 +1,43 @@ +--TEST-- +stristr() function +--FILE-- +<?php + var_dump(stristr()); + var_dump(stristr(array(), "")); + var_dump(stristr("", array())); + var_dump(stristr(array(), array())); + var_dump(stristr("tEsT sTrInG", "tEsT")); + var_dump(stristr("tEsT sTrInG", "stRiNg")); + var_dump(stristr("tEsT sTrInG", "stRiN")); + var_dump(stristr("tEsT sTrInG", "t S")); + var_dump(stristr("tEsT sTrInG", "g")); + var_dump(md5(stristr("te".chr(0)."st", chr(0)))); + var_dump(@stristr("", "")); + var_dump(@stristr("a", "")); + var_dump(@stristr("", "a")); + var_dump(md5(@stristr("\\\\a\\", "\\a"))); + var_dump(stristr("tEsT sTrInG", " ")); +?> +--EXPECTF-- +Warning: Wrong parameter count for stristr() in %s on line %d +NULL + +Notice: Array to string conversion in %s on line %d + +Warning: stristr(): Empty delimiter. in %s on line %d +bool(false) +bool(false) + +Notice: Array to string conversion in %s on line %d +bool(false) +string(11) "tEsT sTrInG" +string(6) "sTrInG" +string(6) "sTrInG" +string(8) "T sTrInG" +string(1) "G" +string(32) "7272696018bdeb2c9a3f8d01fc2a9273" +bool(false) +bool(false) +bool(false) +string(32) "6ec19f52f0766c463f3bb240f4396913" +string(7) " sTrInG" diff --git a/ext/standard/tests/strings/strlen.phpt b/ext/standard/tests/strings/strlen.phpt Binary files differnew file mode 100644 index 000000000..41529b39f --- /dev/null +++ b/ext/standard/tests/strings/strlen.phpt diff --git a/ext/standard/tests/strings/substr_compare.phpt b/ext/standard/tests/strings/substr_compare.phpt index 594aed173..66a82a878 100644 --- a/ext/standard/tests/strings/substr_compare.phpt +++ b/ext/standard/tests/strings/substr_compare.phpt @@ -24,7 +24,7 @@ int(0) int(1) int(-1) -Warning: substr_compare(): The start position cannot exceed initial string length in %s on line %d +Warning: substr_compare(): The length cannot exceed initial string length in %s on line %d bool(false) Warning: substr_compare() expects parameter 5 to be boolean, object given in %s on line %d diff --git a/ext/standard/tests/strings/ucfirst.phpt b/ext/standard/tests/strings/ucfirst.phpt Binary files differnew file mode 100644 index 000000000..eebc4cc9c --- /dev/null +++ b/ext/standard/tests/strings/ucfirst.phpt diff --git a/ext/standard/tests/strings/uuencode.phpt b/ext/standard/tests/strings/uuencode.phpt new file mode 100644 index 000000000..9c77a5072 --- /dev/null +++ b/ext/standard/tests/strings/uuencode.phpt @@ -0,0 +1,40 @@ +--TEST-- +uuencode family tests +--FILE-- +<?php + +var_dump(convert_uuencode(array())); +var_dump(convert_uudecode(array())); + +var_dump(convert_uuencode("")); +var_dump(convert_uudecode("")); +var_dump($enc = convert_uuencode("~!@#$%^&*()_}{POIUYTREWQQSDFGHJKL:<MNBVCXZ")); +var_dump(convert_uudecode("!@#$%^YUGFDFGHJKLUYTFBNMLOYT")); +var_dump(convert_uudecode($enc)); +var_dump($enc = convert_uuencode("not very sophisticated")); +var_dump(convert_uudecode($enc)); +var_dump(convert_uudecode(substr($enc, 0, -10))); + +echo "Done\n"; +?> +--EXPECTF-- +Warning: convert_uuencode() expects parameter 1 to be string, array given in %s on line %d +bool(false) + +Warning: convert_uudecode() expects parameter 1 to be string, array given in %s on line %d +bool(false) +bool(false) +bool(false) +string(60) "J?B%`(R0E7B8J*"E??7M03TE5651215=145-$1D=(2DM,.CQ-3D)60UA: +` +" +string(1) "%s" +string(42) "~!@#$%^&*()_}{POIUYTREWQQSDFGHJKL:<MNBVCXZ" +string(36) "6;F]T('9E<GD@<V]P:&ES=&EC871E9``` +` +" +string(22) "not very sophisticated" + +Warning: convert_uudecode(): The given parameter is not a valid uuencoded string. in %s on line %d +bool(false) +Done diff --git a/ext/standard/tests/time/bug38524.phpt b/ext/standard/tests/time/bug38524.phpt index e9ccaaf38..77d0f4f23 100755 --- a/ext/standard/tests/time/bug38524.phpt +++ b/ext/standard/tests/time/bug38524.phpt @@ -1,5 +1,7 @@ --TEST-- Bug #38524 (strptime() does not initialize the internal date storage structure) +--SKIPIF-- +<?php if (!function_exists('strptime')) echo "SKIP"; ?> --FILE-- <?php var_dump(strptime('2006-08-20', '%Y-%m-%d')); diff --git a/ext/standard/type.c b/ext/standard/type.c index aa11dd9b5..536f0a673 100644 --- a/ext/standard/type.c +++ b/ext/standard/type.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: type.c,v 1.30.2.2 2006/01/01 12:50:15 sniper Exp $ */ +/* $Id: type.c,v 1.30.2.2.2.3 2007/02/24 02:17:27 helly Exp $ */ #include "php.h" #include "php_incomplete_class.h" @@ -64,8 +64,7 @@ PHP_FUNCTION(gettype) int res_len; res_len = sizeof("object of type ")-1 + Z_OBJCE_P(arg)->name_length; - result = (char *) emalloc(res_len+1); - sprintf(result, "object of type %s", Z_OBJCE_P(arg)->name); + spprintf(&result, 0, "object of type %s", Z_OBJCE_P(arg)->name); RETVAL_STRINGL(result, res_len, 0); } */ @@ -305,7 +304,6 @@ PHP_FUNCTION(is_object) PHP_FUNCTION(is_numeric) { zval **arg; - int result; if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg) == FAILURE) { WRONG_PARAM_COUNT; @@ -318,8 +316,7 @@ PHP_FUNCTION(is_numeric) break; case IS_STRING: - result = is_numeric_string(Z_STRVAL_PP(arg), Z_STRLEN_PP(arg), NULL, NULL, 0); - if (result == IS_LONG || result == IS_DOUBLE) { + if (is_numeric_string(Z_STRVAL_PP(arg), Z_STRLEN_PP(arg), NULL, NULL, 0)) { RETURN_TRUE; } else { RETURN_FALSE; diff --git a/ext/standard/uniqid.c b/ext/standard/uniqid.c index d7a45f3a9..93279d30f 100644 --- a/ext/standard/uniqid.c +++ b/ext/standard/uniqid.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: uniqid.c,v 1.41.2.2 2006/01/01 12:50:15 sniper Exp $ */ +/* $Id: uniqid.c,v 1.41.2.2.2.2 2007/01/05 15:06:55 iliaa Exp $ */ #include "php.h" @@ -76,7 +76,7 @@ PHP_FUNCTION(uniqid) * digits for usecs. */ if (more_entropy) { - spprintf(&uniqid, 0, "%s%08x%05x%.8f", prefix, sec, usec, php_combined_lcg(TSRMLS_C) * 10); + spprintf(&uniqid, 0, "%s%08x%05x%.8F", prefix, sec, usec, php_combined_lcg(TSRMLS_C) * 10); } else { spprintf(&uniqid, 0, "%s%08x%05x", prefix, sec, usec); } diff --git a/ext/standard/uniqid.h b/ext/standard/uniqid.h index 0f0e83b57..c2ed14fcf 100644 --- a/ext/standard/uniqid.h +++ b/ext/standard/uniqid.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: uniqid.h,v 1.13.2.1 2006/01/01 12:50:15 sniper Exp $ */ +/* $Id: uniqid.h,v 1.13.2.1.2.1 2007/01/01 09:36:09 sebastian Exp $ */ #ifndef UNIQID_H #define UNIQID_H diff --git a/ext/standard/url.c b/ext/standard/url.c index 26662b2cb..4fe68f21f 100644 --- a/ext/standard/url.c +++ b/ext/standard/url.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -15,7 +15,7 @@ | Author: Jim Winstead <jimw@php.net> | +----------------------------------------------------------------------+ */ -/* $Id: url.c,v 1.86.2.5.2.6 2006/09/28 14:52:30 iliaa Exp $ */ +/* $Id: url.c,v 1.86.2.5.2.7 2007/01/01 09:36:09 sebastian Exp $ */ #include <stdlib.h> #include <string.h> diff --git a/ext/standard/url.h b/ext/standard/url.h index 7dd48cad8..7e52d68d8 100644 --- a/ext/standard/url.h +++ b/ext/standard/url.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -15,7 +15,7 @@ | Author: Jim Winstead <jimw@php.net> | +----------------------------------------------------------------------+ */ -/* $Id: url.h,v 1.20.2.2 2006/01/01 12:50:15 sniper Exp $ */ +/* $Id: url.h,v 1.20.2.2.2.1 2007/01/01 09:36:09 sebastian Exp $ */ #ifndef URL_H #define URL_H diff --git a/ext/standard/url_scanner.c b/ext/standard/url_scanner.c index b1a8dded1..0b402c45d 100644 --- a/ext/standard/url_scanner.c +++ b/ext/standard/url_scanner.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -15,7 +15,7 @@ | Author: Hartmut Holzgraefe <hholzgra@php.net> | +----------------------------------------------------------------------+ */ -/* $Id: url_scanner.c,v 1.44.2.1 2006/01/01 12:50:15 sniper Exp $ */ +/* $Id: url_scanner.c,v 1.44.2.1.2.3 2007/02/22 00:44:08 iliaa Exp $ */ #include "php.h" @@ -50,35 +50,24 @@ int php_url_scanner_deactivate(TSRMLS_D) static char *url_attr_addon(const char *tag,const char *attr,const char *val,const char *buf) { int flag = 0; - TSRMLS_FETCH(); - if(!strcasecmp(tag,"a") && !strcasecmp(attr,"href")) { + if (!strcasecmp(tag,"a") && !strcasecmp(attr,"href")) { flag = 1; - } else if(!strcasecmp(tag,"area" ) && !strcasecmp(attr,"href" )) { + } else if (!strcasecmp(tag,"area" ) && !strcasecmp(attr,"href" )) { flag = 1; - } else if(!strcasecmp(tag,"form" ) && !strcasecmp(attr,"action" )) { + } else if (!strcasecmp(tag,"form" ) && !strcasecmp(attr,"action" )) { flag = 1; - } else if(!strcasecmp(tag,"frame") && !strcasecmp(attr,"source" )) { + } else if (!strcasecmp(tag,"frame") && !strcasecmp(attr,"source" )) { flag = 1; - } else if(!strcasecmp(tag,"img" ) && !strcasecmp(attr,"action" )) { + } else if (!strcasecmp(tag,"img" ) && !strcasecmp(attr,"action" )) { flag = 1; } - if(flag) { - if(!strstr(val,buf)&&!strchr(val,':')) - { - char *result = (char *)emalloc(strlen(buf)+strlen(PG(arg_separator).output)+1); - int n; + if(flag && !strstr(val,buf) && !strchr(val,':')) { + char *result; + TSRMLS_FETCH(); - if(strchr(val,'?')) { - strcpy(result,PG(arg_separator).output); - n=strlen(PG(arg_separator).output); - } else { - *result='?'; - n=1; - } - strcpy(result+n,buf); - return result; - } + spprintf(&result, 0, "%s%s", (strchr(val,'?') ? PG(arg_separator).output : "?"), buf); + return result; } return NULL; } @@ -214,7 +203,7 @@ char *url_adapt(const char *src, size_t srclen, const char *data, size_t *newlen maxl+=l; out=realloc(out,maxl); outp=out+*newlen; - strcpy(outp,p); + strlcpy(outp,p,maxl); outp+=l; *newlen+=l; efree(p); @@ -230,7 +219,7 @@ char *url_adapt(const char *src, size_t srclen, const char *data, size_t *newlen maxl+=l; out=realloc(out,maxl); outp=out+*newlen; - strcpy(outp,p); + strlcpy(outp, p, maxl); outp+=l; *newlen+=l; efree(p); @@ -265,7 +254,7 @@ char *url_adapt(const char *src, size_t srclen, const char *data, size_t *newlen maxl+=l; out=realloc(out,maxl); outp=out+*newlen; - strcpy(outp,p); + strlcpy(outp,p,maxl); outp+=l; *newlen+=l; efree(p); @@ -282,7 +271,7 @@ char *url_adapt(const char *src, size_t srclen, const char *data, size_t *newlen maxl+=l; out=realloc(out,maxl); outp=out+*newlen; - strcpy(outp,p); + strlcpy(outp,p,maxl); outp+=l; *newlen+=l; efree(p); @@ -329,7 +318,7 @@ char *url_adapt(const char *src, size_t srclen, const char *data, size_t *newlen maxl+=l; out=realloc(out,maxl); outp=out+*newlen; - strcpy(outp,p); + strlcpy(outp,p,maxl); outp+=l; *newlen+=l; efree(p); @@ -346,7 +335,7 @@ char *url_adapt(const char *src, size_t srclen, const char *data, size_t *newlen maxl+=l; out=realloc(out,maxl); outp=out+*newlen; - strcpy(outp,p); + strlcpy(outp,p,maxl); outp+=l; *newlen+=l; efree(p); diff --git a/ext/standard/url_scanner.h b/ext/standard/url_scanner.h index d061ade6a..86cca80e6 100644 --- a/ext/standard/url_scanner.h +++ b/ext/standard/url_scanner.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -15,7 +15,7 @@ | Author: Sascha Schumann <sascha@schumann.cx> | +----------------------------------------------------------------------+ */ -/* $Id: url_scanner.h,v 1.16.2.1 2006/01/01 12:50:15 sniper Exp $ */ +/* $Id: url_scanner.h,v 1.16.2.1.2.1 2007/01/01 09:36:09 sebastian Exp $ */ #ifndef URI_SCANNER_H #define URI_SCANNER_H diff --git a/ext/standard/url_scanner_ex.c b/ext/standard/url_scanner_ex.c index fdfcc6ee4..21723f96d 100644 --- a/ext/standard/url_scanner_ex.c +++ b/ext/standard/url_scanner_ex.c @@ -3,7 +3,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: url_scanner_ex.c,v 1.95.2.4 2006/02/28 14:45:18 iliaa Exp $ */ +/* $Id: url_scanner_ex.c,v 1.95.2.4.2.1 2007/01/01 09:36:09 sebastian Exp $ */ #include "php.h" diff --git a/ext/standard/url_scanner_ex.c.orig b/ext/standard/url_scanner_ex.c.orig index 083340973..3a181536a 100644 --- a/ext/standard/url_scanner_ex.c.orig +++ b/ext/standard/url_scanner_ex.c.orig @@ -4,7 +4,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: url_scanner_ex.c,v 1.95.2.4 2006/02/28 14:45:18 iliaa Exp $ */ +/* $Id: url_scanner_ex.c,v 1.95.2.4.2.1 2007/01/01 09:36:09 sebastian Exp $ */ #include "php.h" diff --git a/ext/standard/url_scanner_ex.h b/ext/standard/url_scanner_ex.h index 54405ca28..020c04078 100644 --- a/ext/standard/url_scanner_ex.h +++ b/ext/standard/url_scanner_ex.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: url_scanner_ex.h,v 1.26.2.1 2006/01/01 12:50:15 sniper Exp $ */ +/* $Id: url_scanner_ex.h,v 1.26.2.1.2.1 2007/01/01 09:36:09 sebastian Exp $ */ #ifndef URL_SCANNER_EX_H #define URL_SCANNER_EX_H diff --git a/ext/standard/user_filters.c b/ext/standard/user_filters.c index 8304168c9..30c47543b 100644 --- a/ext/standard/user_filters.c +++ b/ext/standard/user_filters.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: user_filters.c,v 1.31.2.4.2.2 2006/10/11 14:46:40 tony2001 Exp $ */ +/* $Id: user_filters.c,v 1.31.2.4.2.8 2007/02/01 14:21:01 tony2001 Exp $ */ #include "php.h" #include "php_globals.h" @@ -256,6 +256,7 @@ static php_stream_filter *user_filter_factory_create(const char *filtername, zval *obj, *zfilter; zval func_name; zval *retval = NULL; + int len; /* some sanity checks */ if (persistent) { @@ -264,9 +265,10 @@ static php_stream_filter *user_filter_factory_create(const char *filtername, return NULL; } + len = strlen(filtername); + /* determine the classname/class entry */ - if (FAILURE == zend_hash_find(BG(user_filter_map), (char*)filtername, - strlen(filtername), (void**)&fdat)) { + if (FAILURE == zend_hash_find(BG(user_filter_map), (char*)filtername, len + 1, (void**)&fdat)) { char *period; /* Userspace Filters using ambiguous wildcards could cause problems. @@ -275,15 +277,15 @@ static php_stream_filter *user_filter_factory_create(const char *filtername, TODO: Allow failed userfilter creations to continue scanning through the list */ if ((period = strrchr(filtername, '.'))) { - char *wildcard; + char *wildcard = emalloc(len + 3); /* Search for wildcard matches instead */ - wildcard = estrdup(filtername); + memcpy(wildcard, filtername, len + 1); /* copy \0 */ period = wildcard + (period - filtername); while (period) { *period = '\0'; strcat(wildcard, ".*"); - if (SUCCESS == zend_hash_find(BG(user_filter_map), wildcard, strlen(wildcard), (void**)&fdat)) { + if (SUCCESS == zend_hash_find(BG(user_filter_map), wildcard, strlen(wildcard) + 1, (void**)&fdat)) { period = NULL; } else { *period = '\0'; @@ -494,6 +496,10 @@ PHP_FUNCTION(stream_bucket_new) memcpy(pbuffer, buffer, buffer_len); bucket = php_stream_bucket_new(stream, pbuffer, buffer_len, 1, php_stream_is_persistent(stream) TSRMLS_CC); + + if (bucket == NULL) { + RETURN_FALSE; + } ALLOC_INIT_ZVAL(zbucket); ZEND_REGISTER_RESOURCE(zbucket, bucket, le_bucket); @@ -527,8 +533,9 @@ PHP_FUNCTION(stream_get_filters) for(zend_hash_internal_pointer_reset(filters_hash); (key_flags = zend_hash_get_current_key_ex(filters_hash, &filter_name, &filter_name_len, &num_key, 0, NULL)) != HASH_KEY_NON_EXISTANT; zend_hash_move_forward(filters_hash)) - if (key_flags == HASH_KEY_IS_STRING) - add_next_index_stringl(return_value, filter_name, filter_name_len, 1); + if (key_flags == HASH_KEY_IS_STRING) { + add_next_index_stringl(return_value, filter_name, filter_name_len - 1, 1); + } } /* It's okay to return an empty array if no filters are registered */ } @@ -567,7 +574,7 @@ PHP_FUNCTION(stream_filter_register) fdat = ecalloc(1, sizeof(*fdat) + classname_len); memcpy(fdat->classname, classname, classname_len); - if (zend_hash_add(BG(user_filter_map), filtername, filtername_len, (void*)fdat, + if (zend_hash_add(BG(user_filter_map), filtername, filtername_len + 1, (void*)fdat, sizeof(*fdat) + classname_len, NULL) == SUCCESS && php_stream_filter_register_factory_volatile(filtername, &user_filter_factory TSRMLS_CC) == SUCCESS) { RETVAL_TRUE; diff --git a/ext/standard/uuencode.c b/ext/standard/uuencode.c index 12db49c7c..98fcc5f6c 100644 --- a/ext/standard/uuencode.c +++ b/ext/standard/uuencode.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: uuencode.c,v 1.5.2.1.2.1 2006/06/26 18:48:56 bjori Exp $ */ +/* $Id: uuencode.c,v 1.5.2.1.2.4 2007/03/12 20:55:15 tony2001 Exp $ */ /* * Portions of this code are based on Berkeley's uuencode/uudecode @@ -65,13 +65,13 @@ #define PHP_UU_DEC(c) (((c) - ' ') & 077) -PHPAPI int php_uuencode(char *src, int src_len, char **dest) +PHPAPI int php_uuencode(char *src, int src_len, char **dest) /* {{{ */ { int len = 45; char *p, *s, *e, *ee; /* encoded length is ~ 38% greater then the original */ - p = *dest = emalloc((ceil(src_len * 1.38) + 45 + 1)); + p = *dest = safe_emalloc(ceil(src_len * 1.38), 1, 46); s = src; e = src + src_len; @@ -122,13 +122,14 @@ PHPAPI int php_uuencode(char *src, int src_len, char **dest) return (p - *dest); } +/* }}} */ -PHPAPI int php_uudecode(char *src, int src_len, char **dest) +PHPAPI int php_uudecode(char *src, int src_len, char **dest) /* {{{ */ { int len, total_len=0; char *s, *e, *p, *ee; - p = *dest = emalloc(ceil(src_len * 0.75) + 1); + p = *dest = safe_emalloc(ceil(src_len * 0.75), 1, 1); s = src; e = src + src_len; @@ -182,6 +183,7 @@ err: efree(*dest); return -1; } +/* }}} */ /* {{{ proto string convert_uuencode(string data) uuencode a string */ @@ -220,3 +222,12 @@ PHP_FUNCTION(convert_uudecode) RETURN_STRINGL(dst, dst_len, 0); } /* }}} */ + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * End: + * vim600: noet sw=4 ts=4 fdm=marker + * vim<600: noet sw=4 ts=4 + */ diff --git a/ext/standard/var.c b/ext/standard/var.c index 8369b6ea7..8957530f9 100644 --- a/ext/standard/var.c +++ b/ext/standard/var.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: var.c,v 1.203.2.7.2.8 2006/10/09 18:08:34 iliaa Exp $ */ +/* $Id: var.c,v 1.203.2.7.2.16 2007/04/23 09:56:56 dmitry Exp $ */ @@ -51,12 +51,6 @@ static int php_array_element_dump(zval **zv, int num_args, va_list args, zend_ha if (hash_key->nKeyLength==0) { /* numeric key */ php_printf("%*c[%ld]=>\n", level + 1, ' ', hash_key->h); } else { /* string key */ - if (va_arg(args, int) && hash_key->arKey[0] == '\0') { - /* XXX: perhaps when we are inside the class we should permit access to - * private & protected values - */ - return 0; - } php_printf("%*c[\"", level + 1, ' '); PHPWRITE(hash_key->arKey, hash_key->nKeyLength - 1); php_printf("\"]=>\n"); @@ -149,7 +143,7 @@ PHPAPI void php_var_dump(zval **struc, int level TSRMLS_DC) php_element_dump_func = php_object_property_dump; head_done: if (myht) { - zend_hash_apply_with_arguments(myht, (apply_func_args_t) php_element_dump_func, 1, level, (Z_TYPE_PP(struc) == IS_ARRAY ? 0 : 1)); + zend_hash_apply_with_arguments(myht, (apply_func_args_t) php_element_dump_func, 1, level); } if (level > 1) { php_printf("%*c", level-1, ' '); @@ -487,7 +481,7 @@ PHP_FUNCTION(var_export) /* {{{ php_var_serialize */ -static void php_var_serialize_intern(smart_str *buf, zval **struc, HashTable *var_hash TSRMLS_DC); +static void php_var_serialize_intern(smart_str *buf, zval *struc, HashTable *var_hash TSRMLS_DC); static inline int php_add_var_hash(HashTable *var_hash, zval *var, void *var_old TSRMLS_DC) { @@ -500,8 +494,8 @@ static inline int php_add_var_hash(HashTable *var_hash, zval *var, void *var_old by its object handle and the class entry since 5.0. */ if ((Z_TYPE_P(var) == IS_OBJECT) && Z_OBJ_HT_P(var)->get_class_entry) { p = smart_str_print_long(id + sizeof(id) - 1, - (((unsigned long)Z_OBJCE_P(var) << 5) - | ((unsigned long)Z_OBJCE_P(var) >> (sizeof(long) * 8 - 5))) + (((size_t)Z_OBJCE_P(var) << 5) + | ((size_t)Z_OBJCE_P(var) >> (sizeof(long) * 8 - 5))) + (long) Z_OBJ_HANDLE_P(var)); *(--p) = 'O'; len = id + sizeof(id) - 1 - p; @@ -542,11 +536,11 @@ static inline void php_var_serialize_string(smart_str *buf, char *str, int len) smart_str_appendl(buf, "\";", 2); } -static inline zend_bool php_var_serialize_class_name(smart_str *buf, zval **struc TSRMLS_DC) +static inline zend_bool php_var_serialize_class_name(smart_str *buf, zval *struc TSRMLS_DC) { PHP_CLASS_ATTRIBUTES; - PHP_SET_CLASS_ATTRIBUTES(*struc); + PHP_SET_CLASS_ATTRIBUTES(struc); smart_str_appendl(buf, "O:", 2); smart_str_append_long(buf, name_len); smart_str_appendl(buf, ":\"", 2); @@ -556,7 +550,7 @@ static inline zend_bool php_var_serialize_class_name(smart_str *buf, zval **stru return incomplete_class; } -static void php_var_serialize_class(smart_str *buf, zval **struc, zval *retval_ptr, HashTable *var_hash TSRMLS_DC) +static void php_var_serialize_class(smart_str *buf, zval *struc, zval *retval_ptr, HashTable *var_hash TSRMLS_DC) { int count; zend_bool incomplete_class; @@ -606,13 +600,13 @@ static void php_var_serialize_class(smart_str *buf, zval **struc, zval *retval_p smart_str_appendl(buf,"N;", 2); continue; } - if (zend_hash_find(Z_OBJPROP_PP(struc), Z_STRVAL_PP(name), + if (zend_hash_find(Z_OBJPROP_P(struc), Z_STRVAL_PP(name), Z_STRLEN_PP(name) + 1, (void *) &d) == SUCCESS) { php_var_serialize_string(buf, Z_STRVAL_PP(name), Z_STRLEN_PP(name)); - php_var_serialize_intern(buf, d, var_hash TSRMLS_CC); + php_var_serialize_intern(buf, *d, var_hash TSRMLS_CC); } else { zend_class_entry *ce; - ce = zend_get_class_entry(*struc TSRMLS_CC); + ce = zend_get_class_entry(struc TSRMLS_CC); if (ce) { char *prot_name, *priv_name; int prop_name_length; @@ -620,29 +614,29 @@ static void php_var_serialize_class(smart_str *buf, zval **struc, zval *retval_p do { zend_mangle_property_name(&priv_name, &prop_name_length, ce->name, ce->name_length, Z_STRVAL_PP(name), Z_STRLEN_PP(name), ce->type & ZEND_INTERNAL_CLASS); - if (zend_hash_find(Z_OBJPROP_PP(struc), priv_name, prop_name_length+1, (void *) &d) == SUCCESS) { + if (zend_hash_find(Z_OBJPROP_P(struc), priv_name, prop_name_length+1, (void *) &d) == SUCCESS) { php_var_serialize_string(buf, priv_name, prop_name_length); efree(priv_name); - php_var_serialize_intern(buf, d, var_hash TSRMLS_CC); + php_var_serialize_intern(buf, *d, var_hash TSRMLS_CC); break; } efree(priv_name); zend_mangle_property_name(&prot_name, &prop_name_length, "*", 1, Z_STRVAL_PP(name), Z_STRLEN_PP(name), ce->type & ZEND_INTERNAL_CLASS); - if (zend_hash_find(Z_OBJPROP_PP(struc), prot_name, prop_name_length+1, (void *) &d) == SUCCESS) { + if (zend_hash_find(Z_OBJPROP_P(struc), prot_name, prop_name_length+1, (void *) &d) == SUCCESS) { php_var_serialize_string(buf, prot_name, prop_name_length); efree(prot_name); - php_var_serialize_intern(buf, d, var_hash TSRMLS_CC); + php_var_serialize_intern(buf, *d, var_hash TSRMLS_CC); break; } efree(prot_name); php_error_docref(NULL TSRMLS_CC, E_NOTICE, "\"%s\" returned as member variable from __sleep() but does not exist", Z_STRVAL_PP(name)); php_var_serialize_string(buf, Z_STRVAL_PP(name), Z_STRLEN_PP(name)); - php_var_serialize_intern(buf, &nvalp, var_hash TSRMLS_CC); + php_var_serialize_intern(buf, nvalp, var_hash TSRMLS_CC); } while (0); } else { php_var_serialize_string(buf, Z_STRVAL_PP(name), Z_STRLEN_PP(name)); - php_var_serialize_intern(buf, &nvalp, var_hash TSRMLS_CC); + php_var_serialize_intern(buf, nvalp, var_hash TSRMLS_CC); } } } @@ -651,20 +645,20 @@ static void php_var_serialize_class(smart_str *buf, zval **struc, zval *retval_p } -static void php_var_serialize_intern(smart_str *buf, zval **struc, HashTable *var_hash TSRMLS_DC) +static void php_var_serialize_intern(smart_str *buf, zval *struc, HashTable *var_hash TSRMLS_DC) { int i; ulong *var_already; HashTable *myht; if (var_hash - && php_add_var_hash(var_hash, *struc, (void *) &var_already TSRMLS_CC) == FAILURE) { - if((*struc)->is_ref) { + && php_add_var_hash(var_hash, struc, (void *) &var_already TSRMLS_CC) == FAILURE) { + if(struc->is_ref) { smart_str_appendl(buf, "R:", 2); smart_str_append_long(buf, *var_already); smart_str_appendc(buf, ';'); return; - } else if(Z_TYPE_PP(struc) == IS_OBJECT) { + } else if(Z_TYPE_P(struc) == IS_OBJECT) { smart_str_appendl(buf, "r:", 2); smart_str_append_long(buf, *var_already); smart_str_appendc(buf, ';'); @@ -672,10 +666,10 @@ static void php_var_serialize_intern(smart_str *buf, zval **struc, HashTable *va } } - switch (Z_TYPE_PP(struc)) { + switch (Z_TYPE_P(struc)) { case IS_BOOL: smart_str_appendl(buf, "b:", 2); - smart_str_append_long(buf, Z_LVAL_PP(struc)); + smart_str_append_long(buf, Z_LVAL_P(struc)); smart_str_appendc(buf, ';'); return; @@ -684,21 +678,23 @@ static void php_var_serialize_intern(smart_str *buf, zval **struc, HashTable *va return; case IS_LONG: - php_var_serialize_long(buf, Z_LVAL_PP(struc)); + php_var_serialize_long(buf, Z_LVAL_P(struc)); return; case IS_DOUBLE: { char *s; - ulong slen; - slen = spprintf(&s, 0, "d:%.*G;", (int) PG(serialize_precision), Z_DVAL_PP(struc)); - smart_str_appendl(buf, s, slen); + smart_str_appendl(buf, "d:", 2); + s = (char *) safe_emalloc(PG(serialize_precision), 1, MAX_LENGTH_OF_DOUBLE + 1); + php_gcvt(Z_DVAL_P(struc), PG(serialize_precision), '.', 'E', s); + smart_str_appends(buf, s); + smart_str_appendc(buf, ';'); efree(s); return; } case IS_STRING: - php_var_serialize_string(buf, Z_STRVAL_PP(struc), Z_STRLEN_PP(struc)); + php_var_serialize_string(buf, Z_STRVAL_P(struc), Z_STRLEN_P(struc)); return; case IS_OBJECT: { @@ -707,8 +703,8 @@ static void php_var_serialize_intern(smart_str *buf, zval **struc, HashTable *va int res; zend_class_entry *ce = NULL; - if(Z_OBJ_HT_PP(struc)->get_class_entry) { - ce = Z_OBJCE_PP(struc); + if(Z_OBJ_HT_P(struc)->get_class_entry) { + ce = Z_OBJCE_P(struc); } if(ce && ce->serialize != NULL) { @@ -716,11 +712,11 @@ static void php_var_serialize_intern(smart_str *buf, zval **struc, HashTable *va unsigned char *serialized_data = NULL; zend_uint serialized_length; - if(ce->serialize(*struc, &serialized_data, &serialized_length, (zend_serialize_data *)var_hash TSRMLS_CC) == SUCCESS) { + if(ce->serialize(struc, &serialized_data, &serialized_length, (zend_serialize_data *)var_hash TSRMLS_CC) == SUCCESS) { smart_str_appendl(buf, "C:", 2); - smart_str_append_long(buf, Z_OBJCE_PP(struc)->name_length); + smart_str_append_long(buf, Z_OBJCE_P(struc)->name_length); smart_str_appendl(buf, ":\"", 2); - smart_str_appendl(buf, Z_OBJCE_PP(struc)->name, Z_OBJCE_PP(struc)->name_length); + smart_str_appendl(buf, Z_OBJCE_P(struc)->name, Z_OBJCE_P(struc)->name_length); smart_str_appendl(buf, "\":", 2); smart_str_append_long(buf, serialized_length); @@ -740,7 +736,7 @@ static void php_var_serialize_intern(smart_str *buf, zval **struc, HashTable *va zend_hash_exists(&ce->function_table, "__sleep", sizeof("__sleep"))) { INIT_PZVAL(&fname); ZVAL_STRINGL(&fname, "__sleep", sizeof("__sleep") - 1, 0); - res = call_user_function_ex(CG(function_table), struc, &fname, + res = call_user_function_ex(CG(function_table), &struc, &fname, &retval_ptr, 0, 0, 1, NULL TSRMLS_CC); if (res == SUCCESS && !EG(exception)) { @@ -769,12 +765,12 @@ static void php_var_serialize_intern(smart_str *buf, zval **struc, HashTable *va } case IS_ARRAY: { zend_bool incomplete_class = 0; - if (Z_TYPE_PP(struc) == IS_ARRAY) { + if (Z_TYPE_P(struc) == IS_ARRAY) { smart_str_appendl(buf, "a:", 2); - myht = HASH_OF(*struc); + myht = HASH_OF(struc); } else { incomplete_class = php_var_serialize_class_name(buf, struc TSRMLS_CC); - myht = Z_OBJPROP_PP(struc); + myht = Z_OBJPROP_P(struc); } /* count after serializing name, since php_var_serialize_class_name changes the count if the variable is incomplete class */ @@ -816,7 +812,7 @@ static void php_var_serialize_intern(smart_str *buf, zval **struc, HashTable *va if (zend_hash_get_current_data_ex(myht, (void **) &data, &pos) != SUCCESS || !data - || data == struc + || data == &struc || (Z_TYPE_PP(data) == IS_ARRAY && Z_ARRVAL_PP(data)->nApplyCount > 1) ) { smart_str_appendl(buf, "N;", 2); @@ -824,7 +820,7 @@ static void php_var_serialize_intern(smart_str *buf, zval **struc, HashTable *va if (Z_TYPE_PP(data) == IS_ARRAY) { Z_ARRVAL_PP(data)->nApplyCount++; } - php_var_serialize_intern(buf, data, var_hash TSRMLS_CC); + php_var_serialize_intern(buf, *data, var_hash TSRMLS_CC); if (Z_TYPE_PP(data) == IS_ARRAY) { Z_ARRVAL_PP(data)->nApplyCount--; } @@ -842,7 +838,7 @@ static void php_var_serialize_intern(smart_str *buf, zval **struc, HashTable *va PHPAPI void php_var_serialize(smart_str *buf, zval **struc, HashTable *var_hash TSRMLS_DC) { - php_var_serialize_intern(buf, struc, var_hash TSRMLS_CC); + php_var_serialize_intern(buf, *struc, var_hash TSRMLS_CC); smart_str_0(buf); } @@ -908,7 +904,6 @@ PHP_FUNCTION(unserialize) /* }}} */ -#if MEMORY_LIMIT /* {{{ proto int memory_get_usage([real_usage]) Returns the allocated by PHP memory */ PHP_FUNCTION(memory_get_usage) { @@ -921,6 +916,7 @@ PHP_FUNCTION(memory_get_usage) { RETURN_LONG(zend_memory_usage(real_usage TSRMLS_CC)); } /* }}} */ + /* {{{ proto int memory_get_peak_usage([real_usage]) Returns the peak allocated by PHP memory */ PHP_FUNCTION(memory_get_peak_usage) { @@ -933,7 +929,6 @@ PHP_FUNCTION(memory_get_peak_usage) { RETURN_LONG(zend_memory_peak_usage(real_usage TSRMLS_CC)); } /* }}} */ -#endif /* * Local variables: diff --git a/ext/standard/var_unserializer.c b/ext/standard/var_unserializer.c index b0f0303ad..13aacbc73 100644 --- a/ext/standard/var_unserializer.c +++ b/ext/standard/var_unserializer.c @@ -1,4 +1,4 @@ -/* Generated by re2c 0.9.11 on Sun Jan 1 14:39:32 2006 */ +/* Generated by re2c 0.11.2 on Tue Mar 27 13:17:43 2007 */ /* +----------------------------------------------------------------------+ | PHP Version 5 | @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: var_unserializer.c,v 1.70.2.4 2006/01/01 12:50:16 sniper Exp $ */ +/* $Id: var_unserializer.c,v 1.70.2.4.2.5 2007/03/27 09:29:10 tony2001 Exp $ */ #include "php.h" #include "ext/standard/php_var.h" @@ -139,6 +139,45 @@ PHPAPI void var_destroy(php_unserialize_data_t *var_hashx) /* }}} */ +static char *unserialize_str(const unsigned char **p, size_t *len) +{ + size_t i, j; + char *str = safe_emalloc(*len, 1, 1); + unsigned char *end = *(unsigned char **)p+*len; + + if(end < *p) { + efree(str); + return NULL; + } + + for (i = 0; i < *len && *p < end; i++) { + if (**p != '\\') { + str[i] = (char)**p; + } else { + unsigned char ch = 0; + + for (j = 0; j < 2; j++) { + (*p)++; + if (**p >= '0' && **p <= '9') { + ch = (ch << 4) + (**p -'0'); + } else if (**p >= 'a' && **p <= 'f') { + ch = (ch << 4) + (**p -'a'+10); + } else if (**p >= 'A' && **p <= 'F') { + ch = (ch << 4) + (**p -'A'+10); + } else { + efree(str); + return NULL; + } + } + str[i] = (char)ch; + } + (*p)++; + } + str[i] = 0; + *len = i; + return str; +} + #define YYFILL(n) do { } while (0) #define YYCTYPE unsigned char #define YYCURSOR cursor @@ -353,145 +392,144 @@ PHPAPI int php_var_unserialize(UNSERIALIZE_PARAMETER) { - static unsigned char yybm[] = { - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 128, 128, 128, 128, 128, 128, 128, 128, - 128, 128, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, + static const unsigned char yybm[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, }; -{ - YYCTYPE yych; - unsigned int yyaccept = 0; - goto yy0; - ++YYCURSOR; -yy0: - if((YYLIMIT - YYCURSOR) < 7) YYFILL(7); - yych = *YYCURSOR; - switch(yych){ - case 'C': case 'O': goto yy12; - case 'N': goto yy5; - case 'R': goto yy2; - case 'a': goto yy10; - case 'b': goto yy6; - case 'd': goto yy8; - case 'i': goto yy7; - case 'o': goto yy11; - case 'r': goto yy4; - case 's': goto yy9; - case '}': goto yy13; - default: goto yy15; - } -yy2: yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if(yych == ':') goto yy87; - goto yy3; + { + YYCTYPE yych; + + if((YYLIMIT - YYCURSOR) < 7) YYFILL(7); + yych = *YYCURSOR; + switch(yych) { + case 'C': + case 'O': goto yy13; + case 'N': goto yy5; + case 'R': goto yy2; + case 'S': goto yy10; + case 'a': goto yy11; + case 'b': goto yy6; + case 'd': goto yy8; + case 'i': goto yy7; + case 'o': goto yy12; + case 'r': goto yy4; + case 's': goto yy9; + case '}': goto yy14; + default: goto yy16; + } +yy2: + yych = *(YYMARKER = ++YYCURSOR); + if(yych == ':') goto yy95; yy3: -{ return 0; } -yy4: yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if(yych == ':') goto yy81; - goto yy3; -yy5: yych = *++YYCURSOR; - if(yych == ';') goto yy79; - goto yy3; -yy6: yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if(yych == ':') goto yy75; - goto yy3; -yy7: yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if(yych == ':') goto yy69; - goto yy3; -yy8: yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if(yych == ':') goto yy45; - goto yy3; -yy9: yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if(yych == ':') goto yy38; - goto yy3; -yy10: yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if(yych == ':') goto yy31; - goto yy3; -yy11: yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if(yych == ':') goto yy24; - goto yy3; -yy12: yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if(yych == ':') goto yy16; - goto yy3; -yy13: ++YYCURSOR; - goto yy14; + { return 0; } +yy4: + yych = *(YYMARKER = ++YYCURSOR); + if(yych == ':') goto yy89; + goto yy3; +yy5: + yych = *++YYCURSOR; + if(yych == ';') goto yy87; + goto yy3; +yy6: + yych = *(YYMARKER = ++YYCURSOR); + if(yych == ':') goto yy83; + goto yy3; +yy7: + yych = *(YYMARKER = ++YYCURSOR); + if(yych == ':') goto yy77; + goto yy3; +yy8: + yych = *(YYMARKER = ++YYCURSOR); + if(yych == ':') goto yy53; + goto yy3; +yy9: + yych = *(YYMARKER = ++YYCURSOR); + if(yych == ':') goto yy46; + goto yy3; +yy10: + yych = *(YYMARKER = ++YYCURSOR); + if(yych == ':') goto yy39; + goto yy3; +yy11: + yych = *(YYMARKER = ++YYCURSOR); + if(yych == ':') goto yy32; + goto yy3; +yy12: + yych = *(YYMARKER = ++YYCURSOR); + if(yych == ':') goto yy25; + goto yy3; +yy13: + yych = *(YYMARKER = ++YYCURSOR); + if(yych == ':') goto yy17; + goto yy3; yy14: -{ + ++YYCURSOR; + { /* this is the case where we have less data than planned */ php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Unexpected end of serialized data"); return 0; /* not sure if it should be 0 or 1 here? */ } -yy15: yych = *++YYCURSOR; - goto yy3; -yy16: yych = *++YYCURSOR; - if(yybm[0+yych] & 128) { - goto yy19; - } - if(yych == '+') goto yy18; - goto yy17; -yy17: YYCURSOR = YYMARKER; - switch(yyaccept){ - case 0: goto yy3; - } -yy18: yych = *++YYCURSOR; - if(yybm[0+yych] & 128) { - goto yy19; - } - goto yy17; -yy19: ++YYCURSOR; - if((YYLIMIT - YYCURSOR) < 2) YYFILL(2); - yych = *YYCURSOR; - goto yy20; -yy20: if(yybm[0+yych] & 128) { - goto yy19; - } - if(yych != ':') goto yy17; - goto yy21; -yy21: yych = *++YYCURSOR; - if(yych != '"') goto yy17; - goto yy22; -yy22: ++YYCURSOR; - goto yy23; -yy23: -{ +yy16: + yych = *++YYCURSOR; + goto yy3; +yy17: + yych = *++YYCURSOR; + if(yybm[0+yych] & 128) { + goto yy20; + } + if(yych == '+') goto yy19; +yy18: + YYCURSOR = YYMARKER; + goto yy3; +yy19: + yych = *++YYCURSOR; + if(yybm[0+yych] & 128) { + goto yy20; + } + goto yy18; +yy20: + ++YYCURSOR; + if((YYLIMIT - YYCURSOR) < 2) YYFILL(2); + yych = *YYCURSOR; + if(yybm[0+yych] & 128) { + goto yy20; + } + if(yych != ':') goto yy18; + yych = *++YYCURSOR; + if(yych != '"') goto yy18; + ++YYCURSOR; + { size_t len, len2, len3, maxlen; long elements; char *class_name; @@ -602,65 +640,58 @@ yy23: return object_common2(UNSERIALIZE_PASSTHRU, elements); } -yy24: yych = *++YYCURSOR; - if(yych <= ','){ - if(yych != '+') goto yy17; - goto yy25; - } else { - if(yych <= '-') goto yy25; - if(yych <= '/') goto yy17; - if(yych <= '9') goto yy26; - goto yy17; - } -yy25: yych = *++YYCURSOR; - if(yych <= '/') goto yy17; - if(yych >= ':') goto yy17; - goto yy26; -yy26: ++YYCURSOR; - if((YYLIMIT - YYCURSOR) < 2) YYFILL(2); - yych = *YYCURSOR; - goto yy27; -yy27: if(yych <= '/') goto yy17; - if(yych <= '9') goto yy26; - if(yych >= ';') goto yy17; - goto yy28; -yy28: yych = *++YYCURSOR; - if(yych != '"') goto yy17; - goto yy29; -yy29: ++YYCURSOR; - goto yy30; -yy30: -{ +yy25: + yych = *++YYCURSOR; + if(yych <= ',') { + if(yych != '+') goto yy18; + } else { + if(yych <= '-') goto yy26; + if(yych <= '/') goto yy18; + if(yych <= '9') goto yy27; + goto yy18; + } +yy26: + yych = *++YYCURSOR; + if(yych <= '/') goto yy18; + if(yych >= ':') goto yy18; +yy27: + ++YYCURSOR; + if((YYLIMIT - YYCURSOR) < 2) YYFILL(2); + yych = *YYCURSOR; + if(yych <= '/') goto yy18; + if(yych <= '9') goto yy27; + if(yych >= ';') goto yy18; + yych = *++YYCURSOR; + if(yych != '"') goto yy18; + ++YYCURSOR; + { INIT_PZVAL(*rval); return object_common2(UNSERIALIZE_PASSTHRU, object_common1(UNSERIALIZE_PASSTHRU, ZEND_STANDARD_CLASS_DEF_PTR)); } -yy31: yych = *++YYCURSOR; - if(yych == '+') goto yy32; - if(yych <= '/') goto yy17; - if(yych <= '9') goto yy33; - goto yy17; -yy32: yych = *++YYCURSOR; - if(yych <= '/') goto yy17; - if(yych >= ':') goto yy17; - goto yy33; -yy33: ++YYCURSOR; - if((YYLIMIT - YYCURSOR) < 2) YYFILL(2); - yych = *YYCURSOR; - goto yy34; -yy34: if(yych <= '/') goto yy17; - if(yych <= '9') goto yy33; - if(yych >= ';') goto yy17; - goto yy35; -yy35: yych = *++YYCURSOR; - if(yych != '{') goto yy17; - goto yy36; -yy36: ++YYCURSOR; - goto yy37; -yy37: -{ +yy32: + yych = *++YYCURSOR; + if(yych == '+') goto yy33; + if(yych <= '/') goto yy18; + if(yych <= '9') goto yy34; + goto yy18; +yy33: + yych = *++YYCURSOR; + if(yych <= '/') goto yy18; + if(yych >= ':') goto yy18; +yy34: + ++YYCURSOR; + if((YYLIMIT - YYCURSOR) < 2) YYFILL(2); + yych = *YYCURSOR; + if(yych <= '/') goto yy18; + if(yych <= '9') goto yy34; + if(yych >= ';') goto yy18; + yych = *++YYCURSOR; + if(yych != '{') goto yy18; + ++YYCURSOR; + { long elements = parse_iv(start + 2); /* use iv() not uiv() in order to check data range */ *p = YYCURSOR; @@ -681,30 +712,75 @@ yy37: return finish_nested_data(UNSERIALIZE_PASSTHRU); } -yy38: yych = *++YYCURSOR; - if(yych == '+') goto yy39; - if(yych <= '/') goto yy17; - if(yych <= '9') goto yy40; - goto yy17; -yy39: yych = *++YYCURSOR; - if(yych <= '/') goto yy17; - if(yych >= ':') goto yy17; - goto yy40; -yy40: ++YYCURSOR; - if((YYLIMIT - YYCURSOR) < 2) YYFILL(2); - yych = *YYCURSOR; - goto yy41; -yy41: if(yych <= '/') goto yy17; - if(yych <= '9') goto yy40; - if(yych >= ';') goto yy17; - goto yy42; -yy42: yych = *++YYCURSOR; - if(yych != '"') goto yy17; - goto yy43; -yy43: ++YYCURSOR; - goto yy44; -yy44: -{ +yy39: + yych = *++YYCURSOR; + if(yych == '+') goto yy40; + if(yych <= '/') goto yy18; + if(yych <= '9') goto yy41; + goto yy18; +yy40: + yych = *++YYCURSOR; + if(yych <= '/') goto yy18; + if(yych >= ':') goto yy18; +yy41: + ++YYCURSOR; + if((YYLIMIT - YYCURSOR) < 2) YYFILL(2); + yych = *YYCURSOR; + if(yych <= '/') goto yy18; + if(yych <= '9') goto yy41; + if(yych >= ';') goto yy18; + yych = *++YYCURSOR; + if(yych != '"') goto yy18; + ++YYCURSOR; + { + size_t len, maxlen; + char *str; + + len = parse_uiv(start + 2); + maxlen = max - YYCURSOR; + if (maxlen < len) { + *p = start + 2; + return 0; + } + + if ((str = unserialize_str(&YYCURSOR, &len)) == NULL) { + return 0; + } + + if (*(YYCURSOR) != '"') { + efree(str); + *p = YYCURSOR; + return 0; + } + + YYCURSOR += 2; + *p = YYCURSOR; + + INIT_PZVAL(*rval); + ZVAL_STRINGL(*rval, str, len, 0); + return 1; +} +yy46: + yych = *++YYCURSOR; + if(yych == '+') goto yy47; + if(yych <= '/') goto yy18; + if(yych <= '9') goto yy48; + goto yy18; +yy47: + yych = *++YYCURSOR; + if(yych <= '/') goto yy18; + if(yych >= ':') goto yy18; +yy48: + ++YYCURSOR; + if((YYLIMIT - YYCURSOR) < 2) YYFILL(2); + yych = *YYCURSOR; + if(yych <= '/') goto yy18; + if(yych <= '9') goto yy48; + if(yych >= ';') goto yy18; + yych = *++YYCURSOR; + if(yych != '"') goto yy18; + ++YYCURSOR; + { size_t len, maxlen; char *str; @@ -731,160 +807,158 @@ yy44: ZVAL_STRINGL(*rval, str, len, 1); return 1; } -yy45: yych = *++YYCURSOR; - if(yych <= '/'){ - if(yych <= ','){ - if(yych == '+') goto yy49; - goto yy17; - } else { - if(yych <= '-') goto yy47; - if(yych <= '.') goto yy52; - goto yy17; - } - } else { - if(yych <= 'I'){ - if(yych <= '9') goto yy50; - if(yych <= 'H') goto yy17; - goto yy48; +yy53: + yych = *++YYCURSOR; + if(yych <= '/') { + if(yych <= ',') { + if(yych == '+') goto yy57; + goto yy18; + } else { + if(yych <= '-') goto yy55; + if(yych <= '.') goto yy60; + goto yy18; + } } else { - if(yych != 'N') goto yy17; - goto yy46; + if(yych <= 'I') { + if(yych <= '9') goto yy58; + if(yych <= 'H') goto yy18; + goto yy56; + } else { + if(yych != 'N') goto yy18; + } } - } -yy46: yych = *++YYCURSOR; - if(yych == 'A') goto yy68; - goto yy17; -yy47: yych = *++YYCURSOR; - if(yych <= '/'){ - if(yych == '.') goto yy52; - goto yy17; - } else { - if(yych <= '9') goto yy50; - if(yych != 'I') goto yy17; - goto yy48; - } -yy48: yych = *++YYCURSOR; - if(yych == 'N') goto yy64; - goto yy17; -yy49: yych = *++YYCURSOR; - if(yych == '.') goto yy52; - if(yych <= '/') goto yy17; - if(yych >= ':') goto yy17; - goto yy50; -yy50: ++YYCURSOR; - if((YYLIMIT - YYCURSOR) < 4) YYFILL(4); - yych = *YYCURSOR; - goto yy51; -yy51: if(yych <= ':'){ - if(yych <= '.'){ - if(yych <= '-') goto yy17; - goto yy62; + yych = *++YYCURSOR; + if(yych == 'A') goto yy76; + goto yy18; +yy55: + yych = *++YYCURSOR; + if(yych <= '/') { + if(yych == '.') goto yy60; + goto yy18; } else { - if(yych <= '/') goto yy17; - if(yych <= '9') goto yy50; - goto yy17; + if(yych <= '9') goto yy58; + if(yych != 'I') goto yy18; } - } else { - if(yych <= 'E'){ - if(yych <= ';') goto yy55; - if(yych <= 'D') goto yy17; - goto yy57; +yy56: + yych = *++YYCURSOR; + if(yych == 'N') goto yy72; + goto yy18; +yy57: + yych = *++YYCURSOR; + if(yych == '.') goto yy60; + if(yych <= '/') goto yy18; + if(yych >= ':') goto yy18; +yy58: + ++YYCURSOR; + if((YYLIMIT - YYCURSOR) < 4) YYFILL(4); + yych = *YYCURSOR; + if(yych <= ':') { + if(yych <= '.') { + if(yych <= '-') goto yy18; + goto yy70; + } else { + if(yych <= '/') goto yy18; + if(yych <= '9') goto yy58; + goto yy18; + } } else { - if(yych == 'e') goto yy57; - goto yy17; + if(yych <= 'E') { + if(yych <= ';') goto yy63; + if(yych <= 'D') goto yy18; + goto yy65; + } else { + if(yych == 'e') goto yy65; + goto yy18; + } } - } -yy52: yych = *++YYCURSOR; - if(yych <= '/') goto yy17; - if(yych >= ':') goto yy17; - goto yy53; -yy53: ++YYCURSOR; - if((YYLIMIT - YYCURSOR) < 4) YYFILL(4); - yych = *YYCURSOR; - goto yy54; -yy54: if(yych <= ';'){ - if(yych <= '/') goto yy17; - if(yych <= '9') goto yy53; - if(yych <= ':') goto yy17; - goto yy55; - } else { - if(yych <= 'E'){ - if(yych <= 'D') goto yy17; - goto yy57; +yy60: + yych = *++YYCURSOR; + if(yych <= '/') goto yy18; + if(yych >= ':') goto yy18; +yy61: + ++YYCURSOR; + if((YYLIMIT - YYCURSOR) < 4) YYFILL(4); + yych = *YYCURSOR; + if(yych <= ';') { + if(yych <= '/') goto yy18; + if(yych <= '9') goto yy61; + if(yych <= ':') goto yy18; } else { - if(yych == 'e') goto yy57; - goto yy17; + if(yych <= 'E') { + if(yych <= 'D') goto yy18; + goto yy65; + } else { + if(yych == 'e') goto yy65; + goto yy18; + } } - } -yy55: ++YYCURSOR; - goto yy56; -yy56: -{ +yy63: + ++YYCURSOR; + { *p = YYCURSOR; INIT_PZVAL(*rval); ZVAL_DOUBLE(*rval, zend_strtod((const char *)start + 2, NULL)); return 1; } -yy57: yych = *++YYCURSOR; - if(yych <= ','){ - if(yych != '+') goto yy17; - goto yy58; - } else { - if(yych <= '-') goto yy58; - if(yych <= '/') goto yy17; - if(yych <= '9') goto yy59; - goto yy17; - } -yy58: yych = *++YYCURSOR; - if(yych <= ','){ - if(yych == '+') goto yy61; - goto yy17; - } else { - if(yych <= '-') goto yy61; - if(yych <= '/') goto yy17; - if(yych >= ':') goto yy17; - goto yy59; - } -yy59: ++YYCURSOR; - if(YYLIMIT == YYCURSOR) YYFILL(1); - yych = *YYCURSOR; - goto yy60; -yy60: if(yych <= '/') goto yy17; - if(yych <= '9') goto yy59; - if(yych == ';') goto yy55; - goto yy17; -yy61: yych = *++YYCURSOR; - if(yych <= '/') goto yy17; - if(yych <= '9') goto yy59; - goto yy17; -yy62: ++YYCURSOR; - if((YYLIMIT - YYCURSOR) < 4) YYFILL(4); - yych = *YYCURSOR; - goto yy63; -yy63: if(yych <= ';'){ - if(yych <= '/') goto yy17; - if(yych <= '9') goto yy62; - if(yych <= ':') goto yy17; - goto yy55; - } else { - if(yych <= 'E'){ - if(yych <= 'D') goto yy17; - goto yy57; +yy65: + yych = *++YYCURSOR; + if(yych <= ',') { + if(yych != '+') goto yy18; } else { - if(yych == 'e') goto yy57; - goto yy17; + if(yych <= '-') goto yy66; + if(yych <= '/') goto yy18; + if(yych <= '9') goto yy67; + goto yy18; + } +yy66: + yych = *++YYCURSOR; + if(yych <= ',') { + if(yych == '+') goto yy69; + goto yy18; + } else { + if(yych <= '-') goto yy69; + if(yych <= '/') goto yy18; + if(yych >= ':') goto yy18; } - } -yy64: yych = *++YYCURSOR; - if(yych != 'F') goto yy17; - goto yy65; -yy65: yych = *++YYCURSOR; - if(yych != ';') goto yy17; - goto yy66; -yy66: ++YYCURSOR; - goto yy67; yy67: -{ + ++YYCURSOR; + if(YYLIMIT == YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if(yych <= '/') goto yy18; + if(yych <= '9') goto yy67; + if(yych == ';') goto yy63; + goto yy18; +yy69: + yych = *++YYCURSOR; + if(yych <= '/') goto yy18; + if(yych <= '9') goto yy67; + goto yy18; +yy70: + ++YYCURSOR; + if((YYLIMIT - YYCURSOR) < 4) YYFILL(4); + yych = *YYCURSOR; + if(yych <= ';') { + if(yych <= '/') goto yy18; + if(yych <= '9') goto yy70; + if(yych <= ':') goto yy18; + goto yy63; + } else { + if(yych <= 'E') { + if(yych <= 'D') goto yy18; + goto yy65; + } else { + if(yych == 'e') goto yy65; + goto yy18; + } + } +yy72: + yych = *++YYCURSOR; + if(yych != 'F') goto yy18; +yy73: + yych = *++YYCURSOR; + if(yych != ';') goto yy18; + ++YYCURSOR; + { *p = YYCURSOR; INIT_PZVAL(*rval); @@ -898,91 +972,82 @@ yy67: return 1; } -yy68: yych = *++YYCURSOR; - if(yych == 'N') goto yy65; - goto yy17; -yy69: yych = *++YYCURSOR; - if(yych <= ','){ - if(yych != '+') goto yy17; - goto yy70; - } else { - if(yych <= '-') goto yy70; - if(yych <= '/') goto yy17; - if(yych <= '9') goto yy71; - goto yy17; - } -yy70: yych = *++YYCURSOR; - if(yych <= '/') goto yy17; - if(yych >= ':') goto yy17; - goto yy71; -yy71: ++YYCURSOR; - if(YYLIMIT == YYCURSOR) YYFILL(1); - yych = *YYCURSOR; - goto yy72; -yy72: if(yych <= '/') goto yy17; - if(yych <= '9') goto yy71; - if(yych != ';') goto yy17; - goto yy73; -yy73: ++YYCURSOR; - goto yy74; -yy74: -{ +yy76: + yych = *++YYCURSOR; + if(yych == 'N') goto yy73; + goto yy18; +yy77: + yych = *++YYCURSOR; + if(yych <= ',') { + if(yych != '+') goto yy18; + } else { + if(yych <= '-') goto yy78; + if(yych <= '/') goto yy18; + if(yych <= '9') goto yy79; + goto yy18; + } +yy78: + yych = *++YYCURSOR; + if(yych <= '/') goto yy18; + if(yych >= ':') goto yy18; +yy79: + ++YYCURSOR; + if(YYLIMIT == YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if(yych <= '/') goto yy18; + if(yych <= '9') goto yy79; + if(yych != ';') goto yy18; + ++YYCURSOR; + { *p = YYCURSOR; INIT_PZVAL(*rval); ZVAL_LONG(*rval, parse_iv(start + 2)); return 1; } -yy75: yych = *++YYCURSOR; - if(yych <= '/') goto yy17; - if(yych >= '2') goto yy17; - goto yy76; -yy76: yych = *++YYCURSOR; - if(yych != ';') goto yy17; - goto yy77; -yy77: ++YYCURSOR; - goto yy78; -yy78: -{ +yy83: + yych = *++YYCURSOR; + if(yych <= '/') goto yy18; + if(yych >= '2') goto yy18; + yych = *++YYCURSOR; + if(yych != ';') goto yy18; + ++YYCURSOR; + { *p = YYCURSOR; INIT_PZVAL(*rval); ZVAL_BOOL(*rval, parse_iv(start + 2)); return 1; } -yy79: ++YYCURSOR; - goto yy80; -yy80: -{ +yy87: + ++YYCURSOR; + { *p = YYCURSOR; INIT_PZVAL(*rval); ZVAL_NULL(*rval); return 1; } -yy81: yych = *++YYCURSOR; - if(yych <= ','){ - if(yych != '+') goto yy17; - goto yy82; - } else { - if(yych <= '-') goto yy82; - if(yych <= '/') goto yy17; - if(yych <= '9') goto yy83; - goto yy17; - } -yy82: yych = *++YYCURSOR; - if(yych <= '/') goto yy17; - if(yych >= ':') goto yy17; - goto yy83; -yy83: ++YYCURSOR; - if(YYLIMIT == YYCURSOR) YYFILL(1); - yych = *YYCURSOR; - goto yy84; -yy84: if(yych <= '/') goto yy17; - if(yych <= '9') goto yy83; - if(yych != ';') goto yy17; - goto yy85; -yy85: ++YYCURSOR; - goto yy86; -yy86: -{ +yy89: + yych = *++YYCURSOR; + if(yych <= ',') { + if(yych != '+') goto yy18; + } else { + if(yych <= '-') goto yy90; + if(yych <= '/') goto yy18; + if(yych <= '9') goto yy91; + goto yy18; + } +yy90: + yych = *++YYCURSOR; + if(yych <= '/') goto yy18; + if(yych >= ':') goto yy18; +yy91: + ++YYCURSOR; + if(YYLIMIT == YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if(yych <= '/') goto yy18; + if(yych <= '9') goto yy91; + if(yych != ';') goto yy18; + ++YYCURSOR; + { long id; *p = YYCURSOR; @@ -1004,32 +1069,29 @@ yy86: return 1; } -yy87: yych = *++YYCURSOR; - if(yych <= ','){ - if(yych != '+') goto yy17; - goto yy88; - } else { - if(yych <= '-') goto yy88; - if(yych <= '/') goto yy17; - if(yych <= '9') goto yy89; - goto yy17; - } -yy88: yych = *++YYCURSOR; - if(yych <= '/') goto yy17; - if(yych >= ':') goto yy17; - goto yy89; -yy89: ++YYCURSOR; - if(YYLIMIT == YYCURSOR) YYFILL(1); - yych = *YYCURSOR; - goto yy90; -yy90: if(yych <= '/') goto yy17; - if(yych <= '9') goto yy89; - if(yych != ';') goto yy17; - goto yy91; -yy91: ++YYCURSOR; - goto yy92; -yy92: -{ +yy95: + yych = *++YYCURSOR; + if(yych <= ',') { + if(yych != '+') goto yy18; + } else { + if(yych <= '-') goto yy96; + if(yych <= '/') goto yy18; + if(yych <= '9') goto yy97; + goto yy18; + } +yy96: + yych = *++YYCURSOR; + if(yych <= '/') goto yy18; + if(yych >= ':') goto yy18; +yy97: + ++YYCURSOR; + if(YYLIMIT == YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if(yych <= '/') goto yy18; + if(yych <= '9') goto yy97; + if(yych != ';') goto yy18; + ++YYCURSOR; + { long id; *p = YYCURSOR; @@ -1049,7 +1111,7 @@ yy92: return 1; } -} + } } diff --git a/ext/standard/var_unserializer.c.orig b/ext/standard/var_unserializer.c.orig index 266b31dc5..8ee07f6e9 100644 --- a/ext/standard/var_unserializer.c.orig +++ b/ext/standard/var_unserializer.c.orig @@ -1,4 +1,4 @@ -/* Generated by re2c 0.9.11 on Sun Jan 1 14:39:32 2006 */ +/* Generated by re2c 0.11.2 on Tue Mar 27 13:17:43 2007 */ #line 1 "ext/standard/var_unserializer.re" /* +----------------------------------------------------------------------+ @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: var_unserializer.c,v 1.70.2.4 2006/01/01 12:50:16 sniper Exp $ */ +/* $Id: var_unserializer.c,v 1.70.2.4.2.5 2007/03/27 09:29:10 tony2001 Exp $ */ #include "php.h" #include "ext/standard/php_var.h" @@ -140,6 +140,45 @@ PHPAPI void var_destroy(php_unserialize_data_t *var_hashx) /* }}} */ +static char *unserialize_str(const unsigned char **p, size_t *len) +{ + size_t i, j; + char *str = safe_emalloc(*len, 1, 1); + unsigned char *end = *(unsigned char **)p+*len; + + if(end < *p) { + efree(str); + return NULL; + } + + for (i = 0; i < *len && *p < end; i++) { + if (**p != '\\') { + str[i] = (char)**p; + } else { + unsigned char ch = 0; + + for (j = 0; j < 2; j++) { + (*p)++; + if (**p >= '0' && **p <= '9') { + ch = (ch << 4) + (**p -'0'); + } else if (**p >= 'a' && **p <= 'f') { + ch = (ch << 4) + (**p -'a'+10); + } else if (**p >= 'A' && **p <= 'F') { + ch = (ch << 4) + (**p -'A'+10); + } else { + efree(str); + return NULL; + } + } + str[i] = (char)ch; + } + (*p)++; + } + str[i] = 0; + *len = i; + return str; +} + #define YYFILL(n) do { } while (0) #define YYCTYPE unsigned char #define YYCURSOR cursor @@ -147,7 +186,7 @@ PHPAPI void var_destroy(php_unserialize_data_t *var_hashx) #define YYMARKER marker -#line 155 "ext/standard/var_unserializer.re" +#line 194 "ext/standard/var_unserializer.re" @@ -355,151 +394,150 @@ PHPAPI int php_var_unserialize(UNSERIALIZE_PARAMETER) { - static unsigned char yybm[] = { - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 128, 128, 128, 128, 128, 128, 128, 128, - 128, 128, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, + static const unsigned char yybm[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, }; -#line 394 "ext/standard/var_unserializer.c" -{ - YYCTYPE yych; - unsigned int yyaccept = 0; - goto yy0; - ++YYCURSOR; -yy0: - if((YYLIMIT - YYCURSOR) < 7) YYFILL(7); - yych = *YYCURSOR; - switch(yych){ - case 'C': case 'O': goto yy12; - case 'N': goto yy5; - case 'R': goto yy2; - case 'a': goto yy10; - case 'b': goto yy6; - case 'd': goto yy8; - case 'i': goto yy7; - case 'o': goto yy11; - case 'r': goto yy4; - case 's': goto yy9; - case '}': goto yy13; - default: goto yy15; - } -yy2: yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if(yych == ':') goto yy87; - goto yy3; +#line 433 "ext/standard/var_unserializer.c" + { + YYCTYPE yych; + + if((YYLIMIT - YYCURSOR) < 7) YYFILL(7); + yych = *YYCURSOR; + switch(yych) { + case 'C': + case 'O': goto yy13; + case 'N': goto yy5; + case 'R': goto yy2; + case 'S': goto yy10; + case 'a': goto yy11; + case 'b': goto yy6; + case 'd': goto yy8; + case 'i': goto yy7; + case 'o': goto yy12; + case 'r': goto yy4; + case 's': goto yy9; + case '}': goto yy14; + default: goto yy16; + } +yy2: + yych = *(YYMARKER = ++YYCURSOR); + if(yych == ':') goto yy95; yy3: -#line 626 "ext/standard/var_unserializer.re" -{ return 0; } -#line 424 "ext/standard/var_unserializer.c" -yy4: yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if(yych == ':') goto yy81; - goto yy3; -yy5: yych = *++YYCURSOR; - if(yych == ';') goto yy79; - goto yy3; -yy6: yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if(yych == ':') goto yy75; - goto yy3; -yy7: yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if(yych == ':') goto yy69; - goto yy3; -yy8: yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if(yych == ':') goto yy45; - goto yy3; -yy9: yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if(yych == ':') goto yy38; - goto yy3; -yy10: yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if(yych == ':') goto yy31; - goto yy3; -yy11: yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if(yych == ':') goto yy24; - goto yy3; -yy12: yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if(yych == ':') goto yy16; - goto yy3; -yy13: ++YYCURSOR; - goto yy14; +#line 694 "ext/standard/var_unserializer.re" + { return 0; } +#line 461 "ext/standard/var_unserializer.c" +yy4: + yych = *(YYMARKER = ++YYCURSOR); + if(yych == ':') goto yy89; + goto yy3; +yy5: + yych = *++YYCURSOR; + if(yych == ';') goto yy87; + goto yy3; +yy6: + yych = *(YYMARKER = ++YYCURSOR); + if(yych == ':') goto yy83; + goto yy3; +yy7: + yych = *(YYMARKER = ++YYCURSOR); + if(yych == ':') goto yy77; + goto yy3; +yy8: + yych = *(YYMARKER = ++YYCURSOR); + if(yych == ':') goto yy53; + goto yy3; +yy9: + yych = *(YYMARKER = ++YYCURSOR); + if(yych == ':') goto yy46; + goto yy3; +yy10: + yych = *(YYMARKER = ++YYCURSOR); + if(yych == ':') goto yy39; + goto yy3; +yy11: + yych = *(YYMARKER = ++YYCURSOR); + if(yych == ':') goto yy32; + goto yy3; +yy12: + yych = *(YYMARKER = ++YYCURSOR); + if(yych == ':') goto yy25; + goto yy3; +yy13: + yych = *(YYMARKER = ++YYCURSOR); + if(yych == ':') goto yy17; + goto yy3; yy14: -#line 620 "ext/standard/var_unserializer.re" -{ + ++YYCURSOR; +#line 688 "ext/standard/var_unserializer.re" + { /* this is the case where we have less data than planned */ php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Unexpected end of serialized data"); return 0; /* not sure if it should be 0 or 1 here? */ } -#line 469 "ext/standard/var_unserializer.c" -yy15: yych = *++YYCURSOR; - goto yy3; -yy16: yych = *++YYCURSOR; - if(yybm[0+yych] & 128) { - goto yy19; - } - if(yych == '+') goto yy18; - goto yy17; -yy17: YYCURSOR = YYMARKER; - switch(yyaccept){ - case 0: goto yy3; - } -yy18: yych = *++YYCURSOR; - if(yybm[0+yych] & 128) { - goto yy19; - } - goto yy17; -yy19: ++YYCURSOR; - if((YYLIMIT - YYCURSOR) < 2) YYFILL(2); - yych = *YYCURSOR; - goto yy20; -yy20: if(yybm[0+yych] & 128) { - goto yy19; - } - if(yych != ':') goto yy17; - goto yy21; -yy21: yych = *++YYCURSOR; - if(yych != '"') goto yy17; - goto yy22; -yy22: ++YYCURSOR; - goto yy23; -yy23: -#line 508 "ext/standard/var_unserializer.re" -{ +#line 510 "ext/standard/var_unserializer.c" +yy16: + yych = *++YYCURSOR; + goto yy3; +yy17: + yych = *++YYCURSOR; + if(yybm[0+yych] & 128) { + goto yy20; + } + if(yych == '+') goto yy19; +yy18: + YYCURSOR = YYMARKER; + goto yy3; +yy19: + yych = *++YYCURSOR; + if(yybm[0+yych] & 128) { + goto yy20; + } + goto yy18; +yy20: + ++YYCURSOR; + if((YYLIMIT - YYCURSOR) < 2) YYFILL(2); + yych = *YYCURSOR; + if(yybm[0+yych] & 128) { + goto yy20; + } + if(yych != ':') goto yy18; + yych = *++YYCURSOR; + if(yych != '"') goto yy18; + ++YYCURSOR; +#line 576 "ext/standard/var_unserializer.re" + { size_t len, len2, len3, maxlen; long elements; char *class_name; @@ -610,69 +648,62 @@ yy23: return object_common2(UNSERIALIZE_PASSTHRU, elements); } -#line 614 "ext/standard/var_unserializer.c" -yy24: yych = *++YYCURSOR; - if(yych <= ','){ - if(yych != '+') goto yy17; - goto yy25; - } else { - if(yych <= '-') goto yy25; - if(yych <= '/') goto yy17; - if(yych <= '9') goto yy26; - goto yy17; - } -yy25: yych = *++YYCURSOR; - if(yych <= '/') goto yy17; - if(yych >= ':') goto yy17; - goto yy26; -yy26: ++YYCURSOR; - if((YYLIMIT - YYCURSOR) < 2) YYFILL(2); - yych = *YYCURSOR; - goto yy27; -yy27: if(yych <= '/') goto yy17; - if(yych <= '9') goto yy26; - if(yych >= ';') goto yy17; - goto yy28; -yy28: yych = *++YYCURSOR; - if(yych != '"') goto yy17; - goto yy29; -yy29: ++YYCURSOR; - goto yy30; -yy30: -#line 500 "ext/standard/var_unserializer.re" -{ +#line 652 "ext/standard/var_unserializer.c" +yy25: + yych = *++YYCURSOR; + if(yych <= ',') { + if(yych != '+') goto yy18; + } else { + if(yych <= '-') goto yy26; + if(yych <= '/') goto yy18; + if(yych <= '9') goto yy27; + goto yy18; + } +yy26: + yych = *++YYCURSOR; + if(yych <= '/') goto yy18; + if(yych >= ':') goto yy18; +yy27: + ++YYCURSOR; + if((YYLIMIT - YYCURSOR) < 2) YYFILL(2); + yych = *YYCURSOR; + if(yych <= '/') goto yy18; + if(yych <= '9') goto yy27; + if(yych >= ';') goto yy18; + yych = *++YYCURSOR; + if(yych != '"') goto yy18; + ++YYCURSOR; +#line 568 "ext/standard/var_unserializer.re" + { INIT_PZVAL(*rval); return object_common2(UNSERIALIZE_PASSTHRU, object_common1(UNSERIALIZE_PASSTHRU, ZEND_STANDARD_CLASS_DEF_PTR)); } -#line 651 "ext/standard/var_unserializer.c" -yy31: yych = *++YYCURSOR; - if(yych == '+') goto yy32; - if(yych <= '/') goto yy17; - if(yych <= '9') goto yy33; - goto yy17; -yy32: yych = *++YYCURSOR; - if(yych <= '/') goto yy17; - if(yych >= ':') goto yy17; - goto yy33; -yy33: ++YYCURSOR; - if((YYLIMIT - YYCURSOR) < 2) YYFILL(2); - yych = *YYCURSOR; - goto yy34; -yy34: if(yych <= '/') goto yy17; - if(yych <= '9') goto yy33; - if(yych >= ';') goto yy17; - goto yy35; -yy35: yych = *++YYCURSOR; - if(yych != '{') goto yy17; - goto yy36; -yy36: ++YYCURSOR; - goto yy37; -yy37: -#line 478 "ext/standard/var_unserializer.re" -{ +#line 685 "ext/standard/var_unserializer.c" +yy32: + yych = *++YYCURSOR; + if(yych == '+') goto yy33; + if(yych <= '/') goto yy18; + if(yych <= '9') goto yy34; + goto yy18; +yy33: + yych = *++YYCURSOR; + if(yych <= '/') goto yy18; + if(yych >= ':') goto yy18; +yy34: + ++YYCURSOR; + if((YYLIMIT - YYCURSOR) < 2) YYFILL(2); + yych = *YYCURSOR; + if(yych <= '/') goto yy18; + if(yych <= '9') goto yy34; + if(yych >= ';') goto yy18; + yych = *++YYCURSOR; + if(yych != '{') goto yy18; + ++YYCURSOR; +#line 546 "ext/standard/var_unserializer.re" + { long elements = parse_iv(start + 2); /* use iv() not uiv() in order to check data range */ *p = YYCURSOR; @@ -693,32 +724,79 @@ yy37: return finish_nested_data(UNSERIALIZE_PASSTHRU); } -#line 697 "ext/standard/var_unserializer.c" -yy38: yych = *++YYCURSOR; - if(yych == '+') goto yy39; - if(yych <= '/') goto yy17; - if(yych <= '9') goto yy40; - goto yy17; -yy39: yych = *++YYCURSOR; - if(yych <= '/') goto yy17; - if(yych >= ':') goto yy17; - goto yy40; -yy40: ++YYCURSOR; - if((YYLIMIT - YYCURSOR) < 2) YYFILL(2); - yych = *YYCURSOR; - goto yy41; -yy41: if(yych <= '/') goto yy17; - if(yych <= '9') goto yy40; - if(yych >= ';') goto yy17; - goto yy42; -yy42: yych = *++YYCURSOR; - if(yych != '"') goto yy17; - goto yy43; -yy43: ++YYCURSOR; - goto yy44; -yy44: -#line 450 "ext/standard/var_unserializer.re" -{ +#line 728 "ext/standard/var_unserializer.c" +yy39: + yych = *++YYCURSOR; + if(yych == '+') goto yy40; + if(yych <= '/') goto yy18; + if(yych <= '9') goto yy41; + goto yy18; +yy40: + yych = *++YYCURSOR; + if(yych <= '/') goto yy18; + if(yych >= ':') goto yy18; +yy41: + ++YYCURSOR; + if((YYLIMIT - YYCURSOR) < 2) YYFILL(2); + yych = *YYCURSOR; + if(yych <= '/') goto yy18; + if(yych <= '9') goto yy41; + if(yych >= ';') goto yy18; + yych = *++YYCURSOR; + if(yych != '"') goto yy18; + ++YYCURSOR; +#line 517 "ext/standard/var_unserializer.re" + { + size_t len, maxlen; + char *str; + + len = parse_uiv(start + 2); + maxlen = max - YYCURSOR; + if (maxlen < len) { + *p = start + 2; + return 0; + } + + if ((str = unserialize_str(&YYCURSOR, &len)) == NULL) { + return 0; + } + + if (*(YYCURSOR) != '"') { + efree(str); + *p = YYCURSOR; + return 0; + } + + YYCURSOR += 2; + *p = YYCURSOR; + + INIT_PZVAL(*rval); + ZVAL_STRINGL(*rval, str, len, 0); + return 1; +} +#line 778 "ext/standard/var_unserializer.c" +yy46: + yych = *++YYCURSOR; + if(yych == '+') goto yy47; + if(yych <= '/') goto yy18; + if(yych <= '9') goto yy48; + goto yy18; +yy47: + yych = *++YYCURSOR; + if(yych <= '/') goto yy18; + if(yych >= ':') goto yy18; +yy48: + ++YYCURSOR; + if((YYLIMIT - YYCURSOR) < 2) YYFILL(2); + yych = *YYCURSOR; + if(yych <= '/') goto yy18; + if(yych <= '9') goto yy48; + if(yych >= ';') goto yy18; + yych = *++YYCURSOR; + if(yych != '"') goto yy18; + ++YYCURSOR; +#line 489 "ext/standard/var_unserializer.re" + { size_t len, maxlen; char *str; @@ -745,164 +823,162 @@ yy44: ZVAL_STRINGL(*rval, str, len, 1); return 1; } -#line 749 "ext/standard/var_unserializer.c" -yy45: yych = *++YYCURSOR; - if(yych <= '/'){ - if(yych <= ','){ - if(yych == '+') goto yy49; - goto yy17; - } else { - if(yych <= '-') goto yy47; - if(yych <= '.') goto yy52; - goto yy17; - } - } else { - if(yych <= 'I'){ - if(yych <= '9') goto yy50; - if(yych <= 'H') goto yy17; - goto yy48; +#line 827 "ext/standard/var_unserializer.c" +yy53: + yych = *++YYCURSOR; + if(yych <= '/') { + if(yych <= ',') { + if(yych == '+') goto yy57; + goto yy18; + } else { + if(yych <= '-') goto yy55; + if(yych <= '.') goto yy60; + goto yy18; + } } else { - if(yych != 'N') goto yy17; - goto yy46; + if(yych <= 'I') { + if(yych <= '9') goto yy58; + if(yych <= 'H') goto yy18; + goto yy56; + } else { + if(yych != 'N') goto yy18; + } } - } -yy46: yych = *++YYCURSOR; - if(yych == 'A') goto yy68; - goto yy17; -yy47: yych = *++YYCURSOR; - if(yych <= '/'){ - if(yych == '.') goto yy52; - goto yy17; - } else { - if(yych <= '9') goto yy50; - if(yych != 'I') goto yy17; - goto yy48; - } -yy48: yych = *++YYCURSOR; - if(yych == 'N') goto yy64; - goto yy17; -yy49: yych = *++YYCURSOR; - if(yych == '.') goto yy52; - if(yych <= '/') goto yy17; - if(yych >= ':') goto yy17; - goto yy50; -yy50: ++YYCURSOR; - if((YYLIMIT - YYCURSOR) < 4) YYFILL(4); - yych = *YYCURSOR; - goto yy51; -yy51: if(yych <= ':'){ - if(yych <= '.'){ - if(yych <= '-') goto yy17; - goto yy62; + yych = *++YYCURSOR; + if(yych == 'A') goto yy76; + goto yy18; +yy55: + yych = *++YYCURSOR; + if(yych <= '/') { + if(yych == '.') goto yy60; + goto yy18; } else { - if(yych <= '/') goto yy17; - if(yych <= '9') goto yy50; - goto yy17; + if(yych <= '9') goto yy58; + if(yych != 'I') goto yy18; } - } else { - if(yych <= 'E'){ - if(yych <= ';') goto yy55; - if(yych <= 'D') goto yy17; - goto yy57; +yy56: + yych = *++YYCURSOR; + if(yych == 'N') goto yy72; + goto yy18; +yy57: + yych = *++YYCURSOR; + if(yych == '.') goto yy60; + if(yych <= '/') goto yy18; + if(yych >= ':') goto yy18; +yy58: + ++YYCURSOR; + if((YYLIMIT - YYCURSOR) < 4) YYFILL(4); + yych = *YYCURSOR; + if(yych <= ':') { + if(yych <= '.') { + if(yych <= '-') goto yy18; + goto yy70; + } else { + if(yych <= '/') goto yy18; + if(yych <= '9') goto yy58; + goto yy18; + } } else { - if(yych == 'e') goto yy57; - goto yy17; + if(yych <= 'E') { + if(yych <= ';') goto yy63; + if(yych <= 'D') goto yy18; + goto yy65; + } else { + if(yych == 'e') goto yy65; + goto yy18; + } } - } -yy52: yych = *++YYCURSOR; - if(yych <= '/') goto yy17; - if(yych >= ':') goto yy17; - goto yy53; -yy53: ++YYCURSOR; - if((YYLIMIT - YYCURSOR) < 4) YYFILL(4); - yych = *YYCURSOR; - goto yy54; -yy54: if(yych <= ';'){ - if(yych <= '/') goto yy17; - if(yych <= '9') goto yy53; - if(yych <= ':') goto yy17; - goto yy55; - } else { - if(yych <= 'E'){ - if(yych <= 'D') goto yy17; - goto yy57; +yy60: + yych = *++YYCURSOR; + if(yych <= '/') goto yy18; + if(yych >= ':') goto yy18; +yy61: + ++YYCURSOR; + if((YYLIMIT - YYCURSOR) < 4) YYFILL(4); + yych = *YYCURSOR; + if(yych <= ';') { + if(yych <= '/') goto yy18; + if(yych <= '9') goto yy61; + if(yych <= ':') goto yy18; } else { - if(yych == 'e') goto yy57; - goto yy17; + if(yych <= 'E') { + if(yych <= 'D') goto yy18; + goto yy65; + } else { + if(yych == 'e') goto yy65; + goto yy18; + } } - } -yy55: ++YYCURSOR; - goto yy56; -yy56: -#line 443 "ext/standard/var_unserializer.re" -{ +yy63: + ++YYCURSOR; +#line 482 "ext/standard/var_unserializer.re" + { *p = YYCURSOR; INIT_PZVAL(*rval); ZVAL_DOUBLE(*rval, zend_strtod((const char *)start + 2, NULL)); return 1; } -#line 845 "ext/standard/var_unserializer.c" -yy57: yych = *++YYCURSOR; - if(yych <= ','){ - if(yych != '+') goto yy17; - goto yy58; - } else { - if(yych <= '-') goto yy58; - if(yych <= '/') goto yy17; - if(yych <= '9') goto yy59; - goto yy17; - } -yy58: yych = *++YYCURSOR; - if(yych <= ','){ - if(yych == '+') goto yy61; - goto yy17; - } else { - if(yych <= '-') goto yy61; - if(yych <= '/') goto yy17; - if(yych >= ':') goto yy17; - goto yy59; - } -yy59: ++YYCURSOR; - if(YYLIMIT == YYCURSOR) YYFILL(1); - yych = *YYCURSOR; - goto yy60; -yy60: if(yych <= '/') goto yy17; - if(yych <= '9') goto yy59; - if(yych == ';') goto yy55; - goto yy17; -yy61: yych = *++YYCURSOR; - if(yych <= '/') goto yy17; - if(yych <= '9') goto yy59; - goto yy17; -yy62: ++YYCURSOR; - if((YYLIMIT - YYCURSOR) < 4) YYFILL(4); - yych = *YYCURSOR; - goto yy63; -yy63: if(yych <= ';'){ - if(yych <= '/') goto yy17; - if(yych <= '9') goto yy62; - if(yych <= ':') goto yy17; - goto yy55; - } else { - if(yych <= 'E'){ - if(yych <= 'D') goto yy17; - goto yy57; +#line 922 "ext/standard/var_unserializer.c" +yy65: + yych = *++YYCURSOR; + if(yych <= ',') { + if(yych != '+') goto yy18; } else { - if(yych == 'e') goto yy57; - goto yy17; + if(yych <= '-') goto yy66; + if(yych <= '/') goto yy18; + if(yych <= '9') goto yy67; + goto yy18; + } +yy66: + yych = *++YYCURSOR; + if(yych <= ',') { + if(yych == '+') goto yy69; + goto yy18; + } else { + if(yych <= '-') goto yy69; + if(yych <= '/') goto yy18; + if(yych >= ':') goto yy18; } - } -yy64: yych = *++YYCURSOR; - if(yych != 'F') goto yy17; - goto yy65; -yy65: yych = *++YYCURSOR; - if(yych != ';') goto yy17; - goto yy66; -yy66: ++YYCURSOR; - goto yy67; yy67: -#line 428 "ext/standard/var_unserializer.re" -{ + ++YYCURSOR; + if(YYLIMIT == YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if(yych <= '/') goto yy18; + if(yych <= '9') goto yy67; + if(yych == ';') goto yy63; + goto yy18; +yy69: + yych = *++YYCURSOR; + if(yych <= '/') goto yy18; + if(yych <= '9') goto yy67; + goto yy18; +yy70: + ++YYCURSOR; + if((YYLIMIT - YYCURSOR) < 4) YYFILL(4); + yych = *YYCURSOR; + if(yych <= ';') { + if(yych <= '/') goto yy18; + if(yych <= '9') goto yy70; + if(yych <= ':') goto yy18; + goto yy63; + } else { + if(yych <= 'E') { + if(yych <= 'D') goto yy18; + goto yy65; + } else { + if(yych == 'e') goto yy65; + goto yy18; + } + } +yy72: + yych = *++YYCURSOR; + if(yych != 'F') goto yy18; +yy73: + yych = *++YYCURSOR; + if(yych != ';') goto yy18; + ++YYCURSOR; +#line 467 "ext/standard/var_unserializer.re" + { *p = YYCURSOR; INIT_PZVAL(*rval); @@ -916,99 +992,90 @@ yy67: return 1; } -#line 920 "ext/standard/var_unserializer.c" -yy68: yych = *++YYCURSOR; - if(yych == 'N') goto yy65; - goto yy17; -yy69: yych = *++YYCURSOR; - if(yych <= ','){ - if(yych != '+') goto yy17; - goto yy70; - } else { - if(yych <= '-') goto yy70; - if(yych <= '/') goto yy17; - if(yych <= '9') goto yy71; - goto yy17; - } -yy70: yych = *++YYCURSOR; - if(yych <= '/') goto yy17; - if(yych >= ':') goto yy17; - goto yy71; -yy71: ++YYCURSOR; - if(YYLIMIT == YYCURSOR) YYFILL(1); - yych = *YYCURSOR; - goto yy72; -yy72: if(yych <= '/') goto yy17; - if(yych <= '9') goto yy71; - if(yych != ';') goto yy17; - goto yy73; -yy73: ++YYCURSOR; - goto yy74; -yy74: -#line 421 "ext/standard/var_unserializer.re" -{ +#line 996 "ext/standard/var_unserializer.c" +yy76: + yych = *++YYCURSOR; + if(yych == 'N') goto yy73; + goto yy18; +yy77: + yych = *++YYCURSOR; + if(yych <= ',') { + if(yych != '+') goto yy18; + } else { + if(yych <= '-') goto yy78; + if(yych <= '/') goto yy18; + if(yych <= '9') goto yy79; + goto yy18; + } +yy78: + yych = *++YYCURSOR; + if(yych <= '/') goto yy18; + if(yych >= ':') goto yy18; +yy79: + ++YYCURSOR; + if(YYLIMIT == YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if(yych <= '/') goto yy18; + if(yych <= '9') goto yy79; + if(yych != ';') goto yy18; + ++YYCURSOR; +#line 460 "ext/standard/var_unserializer.re" + { *p = YYCURSOR; INIT_PZVAL(*rval); ZVAL_LONG(*rval, parse_iv(start + 2)); return 1; } -#line 956 "ext/standard/var_unserializer.c" -yy75: yych = *++YYCURSOR; - if(yych <= '/') goto yy17; - if(yych >= '2') goto yy17; - goto yy76; -yy76: yych = *++YYCURSOR; - if(yych != ';') goto yy17; - goto yy77; -yy77: ++YYCURSOR; - goto yy78; -yy78: -#line 414 "ext/standard/var_unserializer.re" -{ +#line 1030 "ext/standard/var_unserializer.c" +yy83: + yych = *++YYCURSOR; + if(yych <= '/') goto yy18; + if(yych >= '2') goto yy18; + yych = *++YYCURSOR; + if(yych != ';') goto yy18; + ++YYCURSOR; +#line 453 "ext/standard/var_unserializer.re" + { *p = YYCURSOR; INIT_PZVAL(*rval); ZVAL_BOOL(*rval, parse_iv(start + 2)); return 1; } -#line 974 "ext/standard/var_unserializer.c" -yy79: ++YYCURSOR; - goto yy80; -yy80: -#line 407 "ext/standard/var_unserializer.re" -{ +#line 1045 "ext/standard/var_unserializer.c" +yy87: + ++YYCURSOR; +#line 446 "ext/standard/var_unserializer.re" + { *p = YYCURSOR; INIT_PZVAL(*rval); ZVAL_NULL(*rval); return 1; } -#line 985 "ext/standard/var_unserializer.c" -yy81: yych = *++YYCURSOR; - if(yych <= ','){ - if(yych != '+') goto yy17; - goto yy82; - } else { - if(yych <= '-') goto yy82; - if(yych <= '/') goto yy17; - if(yych <= '9') goto yy83; - goto yy17; - } -yy82: yych = *++YYCURSOR; - if(yych <= '/') goto yy17; - if(yych >= ':') goto yy17; - goto yy83; -yy83: ++YYCURSOR; - if(YYLIMIT == YYCURSOR) YYFILL(1); - yych = *YYCURSOR; - goto yy84; -yy84: if(yych <= '/') goto yy17; - if(yych <= '9') goto yy83; - if(yych != ';') goto yy17; - goto yy85; -yy85: ++YYCURSOR; - goto yy86; -yy86: -#line 384 "ext/standard/var_unserializer.re" -{ +#line 1055 "ext/standard/var_unserializer.c" +yy89: + yych = *++YYCURSOR; + if(yych <= ',') { + if(yych != '+') goto yy18; + } else { + if(yych <= '-') goto yy90; + if(yych <= '/') goto yy18; + if(yych <= '9') goto yy91; + goto yy18; + } +yy90: + yych = *++YYCURSOR; + if(yych <= '/') goto yy18; + if(yych >= ':') goto yy18; +yy91: + ++YYCURSOR; + if(YYLIMIT == YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if(yych <= '/') goto yy18; + if(yych <= '9') goto yy91; + if(yych != ';') goto yy18; + ++YYCURSOR; +#line 423 "ext/standard/var_unserializer.re" + { long id; *p = YYCURSOR; @@ -1030,34 +1097,31 @@ yy86: return 1; } -#line 1034 "ext/standard/var_unserializer.c" -yy87: yych = *++YYCURSOR; - if(yych <= ','){ - if(yych != '+') goto yy17; - goto yy88; - } else { - if(yych <= '-') goto yy88; - if(yych <= '/') goto yy17; - if(yych <= '9') goto yy89; - goto yy17; - } -yy88: yych = *++YYCURSOR; - if(yych <= '/') goto yy17; - if(yych >= ':') goto yy17; - goto yy89; -yy89: ++YYCURSOR; - if(YYLIMIT == YYCURSOR) YYFILL(1); - yych = *YYCURSOR; - goto yy90; -yy90: if(yych <= '/') goto yy17; - if(yych <= '9') goto yy89; - if(yych != ';') goto yy17; - goto yy91; -yy91: ++YYCURSOR; - goto yy92; -yy92: -#line 363 "ext/standard/var_unserializer.re" -{ +#line 1101 "ext/standard/var_unserializer.c" +yy95: + yych = *++YYCURSOR; + if(yych <= ',') { + if(yych != '+') goto yy18; + } else { + if(yych <= '-') goto yy96; + if(yych <= '/') goto yy18; + if(yych <= '9') goto yy97; + goto yy18; + } +yy96: + yych = *++YYCURSOR; + if(yych <= '/') goto yy18; + if(yych >= ':') goto yy18; +yy97: + ++YYCURSOR; + if(YYLIMIT == YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if(yych <= '/') goto yy18; + if(yych <= '9') goto yy97; + if(yych != ';') goto yy18; + ++YYCURSOR; +#line 402 "ext/standard/var_unserializer.re" + { long id; *p = YYCURSOR; @@ -1077,10 +1141,10 @@ yy92: return 1; } -#line 1081 "ext/standard/var_unserializer.c" -} +#line 1145 "ext/standard/var_unserializer.c" + } } -#line 628 "ext/standard/var_unserializer.re" +#line 696 "ext/standard/var_unserializer.re" return 0; diff --git a/ext/standard/var_unserializer.re b/ext/standard/var_unserializer.re index 25be4a4f8..28b948304 100644 --- a/ext/standard/var_unserializer.re +++ b/ext/standard/var_unserializer.re @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: var_unserializer.re,v 1.52.2.2 2006/01/01 12:26:08 sniper Exp $ */ +/* $Id: var_unserializer.re,v 1.52.2.2.2.3 2007/03/27 09:29:10 tony2001 Exp $ */ #include "php.h" #include "ext/standard/php_var.h" @@ -138,6 +138,45 @@ PHPAPI void var_destroy(php_unserialize_data_t *var_hashx) /* }}} */ +static char *unserialize_str(const unsigned char **p, size_t *len) +{ + size_t i, j; + char *str = safe_emalloc(*len, 1, 1); + unsigned char *end = *(unsigned char **)p+*len; + + if(end < *p) { + efree(str); + return NULL; + } + + for (i = 0; i < *len && *p < end; i++) { + if (**p != '\\') { + str[i] = (char)**p; + } else { + unsigned char ch = 0; + + for (j = 0; j < 2; j++) { + (*p)++; + if (**p >= '0' && **p <= '9') { + ch = (ch << 4) + (**p -'0'); + } else if (**p >= 'a' && **p <= 'f') { + ch = (ch << 4) + (**p -'a'+10); + } else if (**p >= 'A' && **p <= 'F') { + ch = (ch << 4) + (**p -'A'+10); + } else { + efree(str); + return NULL; + } + } + str[i] = (char)ch; + } + (*p)++; + } + str[i] = 0; + *len = i; + return str; +} + #define YYFILL(n) do { } while (0) #define YYCTYPE unsigned char #define YYCURSOR cursor @@ -475,6 +514,35 @@ PHPAPI int php_var_unserialize(UNSERIALIZE_PARAMETER) return 1; } +"S:" uiv ":" ["] { + size_t len, maxlen; + char *str; + + len = parse_uiv(start + 2); + maxlen = max - YYCURSOR; + if (maxlen < len) { + *p = start + 2; + return 0; + } + + if ((str = unserialize_str(&YYCURSOR, &len)) == NULL) { + return 0; + } + + if (*(YYCURSOR) != '"') { + efree(str); + *p = YYCURSOR; + return 0; + } + + YYCURSOR += 2; + *p = YYCURSOR; + + INIT_PZVAL(*rval); + ZVAL_STRINGL(*rval, str, len, 0); + return 1; +} + "a:" uiv ":" "{" { long elements = parse_iv(start + 2); /* use iv() not uiv() in order to check data range */ diff --git a/ext/standard/versioning.c b/ext/standard/versioning.c index 2ebaedb66..6df85f1c0 100644 --- a/ext/standard/versioning.c +++ b/ext/standard/versioning.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | + | Copyright (c) 1997-2007 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: versioning.c,v 1.19.2.1.2.1 2006/06/26 18:48:56 bjori Exp $ */ +/* $Id: versioning.c,v 1.19.2.1.2.2 2007/01/01 09:36:09 sebastian Exp $ */ #include <stdio.h> #include <sys/types.h> |
