Compare commits

..
Author SHA1 Message Date
Christoph M. Becker dbca024404 Update version for PHP 7.3.0RC5 2018-11-06 10:18:43 +00:00
239 changed files with 195040 additions and 207442 deletions

No files matched your search

+1 -1
View File
@@ -16,7 +16,7 @@ environment:
PHP_BUILD_CACHE_BASE_DIR: c:\build-cache
PHP_BUILD_OBJ_DIR: c:\obj
PHP_BUILD_CACHE_SDK_DIR: c:\build-cache\sdk
PHP_BUILD_SDK_BRANCH: php-sdk-2.2.0beta1
PHP_BUILD_SDK_BRANCH: php-sdk-2.1.9beta1
PHP_BUILD_CRT: vc15
# ext and env setup for tests
#MYSQL_TEST_PASSWD: Password12!
-3
View File
@@ -1,6 +1,3 @@
git:
quiet: true
dist: trusty
language: c
sudo: required
-1
View File
@@ -387,7 +387,6 @@ SINCE: 5.5.0
EXTENSION: openssl
PRIMARY MAINTAINER: Wez Furlong <wez@php.net> (2001 - 2006)
Pierre-Alain Joye <pajoye@php.net> (2006 - 2011)
Jakub Zelenka <bukka@php.net> (2015 - 2019)
MAINTENANCE: Maintained
STATUS: Working
SINCE: 4.0.4
+461 -1263
View File
File diff suppressed because it is too large. Load diff
+6 -100
View File
@@ -53,7 +53,7 @@ Core:
case "baz":
continue;
// Warning: "continue" targeting switch is equivalent to
// "break". Did you mean to use "continue 2"?
"break". Did you mean to use "continue 2"?
}
}
@@ -112,12 +112,6 @@ BCMath:
. bcmul() and bcpow() now return numbers with the requested scale. Formerly,
the returned numbers may have omitted trailing decimal zeroes.
IMAP:
rsh/ssh logins are disabled by default. Use imap.enable_insecure_rsh if you want
to enable them. Note that the IMAP library does not filter mailbox names before
passing them to rsh/ssh command, thus passing untrusted data to this function
with rsh/ssh enabled is insecure.
MBString:
. Due to added support for named captures, mb_ereg_*() patterns using named
captures will behave differently. In particular named captures will be part
@@ -251,10 +245,6 @@ Standard:
PHP be linked against libargon2 reference library >= 20161029.
(RFC: https://wiki.php.net/rfc/argon2_password_hash_enhancements).
LDAP:
. Full support for LDAP Controls has been added to LDAP querying functions
and ldap_parse_result
========================================
3. Changes in SAPI modules
========================================
@@ -264,14 +254,6 @@ phpdbg:
PHPDBG_FUNC have been removed.
FPM:
. A new global option log_limit has been added. It can be used for setting
log limit for logged line which allows to log messages longer than 1024
characters without wrapping. It also fixes various wrapping issues.
. A new global option log_buffering has been added. It allows an experimental
logging without extra buffering.
. A new pool option decorate_workers_output has been added. It allows
disabling output decoration for workers output when catch_workers_output
enabled.
. The getallheaders() function is now also available.
========================================
@@ -327,7 +309,7 @@ Standard:
. Passing a non-string needle to string search functions is deprecated. In the
future the needle will be interpreted as a string instead of an ASCII codepoint.
Depending on the intended behavior, you should either explicitly cast the
needle to string or perform an explicit call to chr(). The following functions
needle to string or perform an explicit call to ord(). The following functions
are affected:
. strpos()
. strrpos()
@@ -373,16 +355,6 @@ Standard:
PCRE:
. preg_quote() now also escapes the '#' character.
LDAP:
. Added a serverctrls parameter to send controls to the server in ldap_add,
ldap_mod_replace, ldap_mod_add, ldap_mod_del, ldap_rename,
ldap_compare, ldap_delete, ldap_modify_batch,
ldap_search, ldap_list, ldap_read
. Added an out parameter to get controls from the server in ldap_parse_result
. Fixed support for LDAP_OPT_SERVER_CONTROLS and LDAP_OPT_CLIENT_CONTROLS in
ldap_get_option and ldap_set_option.
========================================
6. New Functions
========================================
@@ -397,8 +369,6 @@ Core:
are available under Linux, FreeBSD, Windows, Mac, SunOS, AIX and their
derivatives. If no required timers are provided by a corresponding
platform, the function returns false.
. Added net_get_interfaces() to retrieve an array of available network
interfaces including several details.
Date:
. Added the DateTime::createFromImmutable() method, which mirrors
@@ -428,10 +398,6 @@ Intl:
. Added Normalizer::getRawDecomposition() and normalizer_get_raw_decomposition(),
to retrieve the Decomposition_Mapping property of a character.
LDAP:
. Added ldap_exop_refresh() to conveniently perform a Refresh extended
operation.
OpenSSL:
. Added openssl_pkey_derive that derives a shared secret for DH, ECDH and
possibly other future algorithms supported by EVP_PKEY_derive.
@@ -459,13 +425,6 @@ Standard:
last key of an array, respectively.
(RFC: <https://wiki.php.net/rfc/array_key_first_last>)
LDAP:
. Added functions ldap_add_ext, ldap_bind_ext, ldap_delete_ext, ldap_mod_add_ext,
ldap_mod_replace_ext, ldap_mod_del_ext, ldap_rename_ext
which gives access to the result object to be able to parse it
with ldap_parse_result and get more information than just success/failure.
========================================
7. New Classes and Interfaces
========================================
@@ -490,7 +449,7 @@ JSON:
is fully backward compatible with former PHP versions.
. FILTER_SANITIZE_ADD_SLASHES has been added as an alias of the 'magic_quotes'
filter (FILTER_SANITIZE_MAGIC_QUOTES). The 'magic_quotes' filter is subject
to removal in future versions of PHP.
to removal in future versions of PHP.
FTP:
. Set default transfer mode to binary
@@ -512,22 +471,12 @@ JSON:
related constants for possible TLS protocol values have been added.
See <https://github.com/php/php-src/pull/3317>.
PCRE:
PCRE:
. The PCRE extension has been upgraded to PCRE2, which may cause minor
behavioral changes (for instance, character ranges in classes are now more
strictly interpreted), and augments the existing regular expression syntax.
See <https://wiki.php.net/rfc/pcre2-migration> for details.
PDO_DBLIB:
. Added the attribute PDO::DBLIB_ATTR_SKIP_EMPTY_ROWSETS to enable automatic
skipping of empty rowsets.
. Exposed the TDS version via the PDO::DBLIB_ATTR_TDS_VERSION attribute.
. DATETIME2 columns are now treated like DATETIME columns.
PDO_SQLite:
. SQLite3 databases can now be opened in read-only mode by setting the
new PDO::SQLITE_ATTR_OPEN_FLAGS attribute to PDO::SQLITE_READONLY.
Standard:
. var_export() now exports stdClass objects as an array casted to an object
(`(object) array( ... )`), rather than using the nonexistent method
@@ -547,10 +496,6 @@ JSON:
. Building against the bundled libzip is discouraged, but still possible by
adding `--without-libzip` to the configuration.
zlib:
. Added the zlib/level context option for the compress.zlib wrapper to
facilitate setting the desired compression level.
========================================
10. New Global Constants
========================================
@@ -628,6 +573,7 @@ Curl:
. CURL_VERSION_GSSNEGOTIATE
. CURL_VERSION_HTTPS_PROXY
. CURL_VERSION_IDN
. CURL_VERSION_KERBEROS5
. CURL_VERSION_LARGEFILE
. CURL_VERSION_MULTI_SSL
. CURL_VERSION_NTLM
@@ -635,19 +581,11 @@ Curl:
. CURL_VERSION_SPNEGO
. CURL_VERSION_SSPI
. CURL_VERSION_TLSAUTH_SRP
Filter:
. FILTER_SANITIZE_ADD_SLASHES
. CURL_VERSION_UNIX_SOCKETS
JSON:
. JSON_THROW_ON_ERROR
OpenSSL:
. STREAM_CRYPTO_PROTO_SSLv3
. STREAM_CRYPTO_PROTO_TLSv1_0
. STREAM_CRYPTO_PROTO_TLSv1_1
. STREAM_CRYPTO_PROTO_TLSv1_2
MBString:
. MB_CASE_FOLD
. MB_CASE_LOWER_SIMPLE
@@ -668,34 +606,6 @@ PGSQL:
Standard:
. PASSWORD_ARGON2ID
LDAP:
. LDAP_CONTROL_MANAGEDSAIT
. LDAP_CONTROL_PROXY_AUTHZ
. LDAP_CONTROL_SUBENTRIES
. LDAP_CONTROL_VALUESRETURNFILTER
. LDAP_CONTROL_ASSERT
. LDAP_CONTROL_PRE_READ
. LDAP_CONTROL_POST_READ
. LDAP_CONTROL_SORTREQUEST
. LDAP_CONTROL_SORTRESPONSE
. LDAP_CONTROL_PAGEDRESULTS
. LDAP_CONTROL_AUTHZID_REQUEST
. LDAP_CONTROL_AUTHZID_RESPONSE
. LDAP_CONTROL_SYNC
. LDAP_CONTROL_SYNC_STATE
. LDAP_CONTROL_SYNC_DONE
. LDAP_CONTROL_DONTUSECOPY
. LDAP_CONTROL_PASSWORDPOLICYREQUEST
. LDAP_CONTROL_PASSWORDPOLICYRESPONSE
. LDAP_CONTROL_X_INCREMENTAL_VALUES
. LDAP_CONTROL_X_DOMAIN_SCOPE
. LDAP_CONTROL_X_PERMISSIVE_MODIFY
. LDAP_CONTROL_X_SEARCH_OPTIONS
. LDAP_CONTROL_X_TREE_DELETE
. LDAP_CONTROL_X_EXTENDED_DN
. LDAP_CONTROL_VLVREQUEST
. LDAP_CONTROL_VLVRESPONSE
========================================
11. Changes to INI File Handling
========================================
@@ -739,7 +649,3 @@ LDAP:
========================================
13. Other Changes
========================================
. The cyclic GC has been enhanced, which may result in considerable performance
improvements.
-7
View File
@@ -45,13 +45,6 @@ elseif (PHP_OS == 'FreeBSD') {
if ($freeMemory < 2100*1024*1024) {
die('skip Not enough memory.');
}
} elseif (PHP_OS == "WINNT") {
$s = trim(shell_exec("wmic OS get FreeVirtualMemory /Value 2>nil"));
$freeMemory = explode('=', $s)[1]*1;
if ($freeMemory < 2.1*1024*1024) {
die('skip Not enough memory.');
}
}
?>
--INI--
-15
View File
@@ -1,15 +0,0 @@
--TEST--
Bug #75426: "Cannot use empty array elements" reports wrong position
--FILE--
<?php
$a = [
1,
2,
3,
,
5,
6,
];
?>
--EXPECTF--
Fatal error: Cannot use empty array elements in arrays in %s on line 5
-42
View File
@@ -1,42 +0,0 @@
--TEST--
Bug #77291 (magic methods inherited from a trait may be ignored)
--FILE--
<?php
trait AccessibleProperties
{
public function __isset($property)
{
return property_exists($this, $property);
}
public function __get($property)
{
if (property_exists($this, $property)) {
return $this->$property;
}
}
}
class Foo4567 {
use AccessibleProperties;
protected $a = 'Some value';
}
class Foo45 {
use AccessibleProperties;
protected $a = 'Some value';
}
$foo = new Foo4567;
var_dump(isset($foo->a));
$foo = new Foo45;
var_dump($foo->a);
?>
===DONE===
--EXPECT--
bool(true)
string(10) "Some value"
===DONE===
-33
View File
@@ -1,33 +0,0 @@
--TEST--
Bug #77339 (__callStatic may get incorrect arguments)
--FILE--
<?php
class Foo
{
static function __callStatic($name, $arguments) {
if ($name === 'get') {
if (!isset($arguments[0])) {
var_dump(['getSomeWhat']);
var_dump($arguments);
exit;
}
}
echo "OK\n";
}
protected function get ($key) {
echo "BUG!!!\n";
}
}
class Bar
{
static function __callStatic($name, $arguments) {
echo Foo::get('getSomeWhat');
}
}
Bar::someUndefinedStaticFunction();
?>
--EXPECT--
OK
-12
View File
@@ -1,12 +0,0 @@
--TEST--
Bug #77376 ("undefined function" message no longer includes namespace)
--FILE--
<?php
namespace Hello;
World();
?>
--EXPECTF--
Fatal error: Uncaught Error: Call to undefined function Hello\World() %sbug77376.php:%d
Stack trace:
#0 {main}
thrown in %sbug77376.php on line %d
@@ -1,23 +0,0 @@
--TEST--
Use of self::class inside a constant in an unknown scope
--FILE--
<?php
class Test {
public function foobar() {
eval("
const FOO = self::class;
var_dump(FOO);
");
}
}
(new Test)->foobar();
// This should error, but doesn't
const BAR = self::class;
var_dump(BAR);
?>
--EXPECT--
string(4) "Test"
string(0) ""
+16 -16
View File
@@ -373,17 +373,17 @@ ZEND_API void zend_print_flat_zval_r(zval *expr) /* {{{ */
switch (Z_TYPE_P(expr)) {
case IS_ARRAY:
ZEND_PUTS("Array (");
if (!(GC_FLAGS(Z_ARRVAL_P(expr)) & GC_IMMUTABLE)) {
if (GC_IS_RECURSIVE(Z_ARRVAL_P(expr))) {
if (Z_REFCOUNTED_P(expr)) {
if (Z_IS_RECURSIVE_P(expr)) {
ZEND_PUTS(" *RECURSION*");
return;
}
GC_PROTECT_RECURSION(Z_ARRVAL_P(expr));
Z_PROTECT_RECURSION_P(expr);
}
print_flat_hash(Z_ARRVAL_P(expr));
ZEND_PUTS(")");
if (!(GC_FLAGS(Z_ARRVAL_P(expr)) & GC_IMMUTABLE)) {
GC_UNPROTECT_RECURSION(Z_ARRVAL_P(expr));
if (Z_REFCOUNTED_P(expr)) {
Z_UNPROTECT_RECURSION_P(expr);
}
break;
case IS_OBJECT:
@@ -393,7 +393,7 @@ ZEND_API void zend_print_flat_zval_r(zval *expr) /* {{{ */
zend_printf("%s Object (", ZSTR_VAL(class_name));
zend_string_release_ex(class_name, 0);
if (GC_IS_RECURSIVE(Z_OBJ_P(expr))) {
if (Z_IS_RECURSIVE_P(expr)) {
ZEND_PUTS(" *RECURSION*");
return;
}
@@ -402,9 +402,9 @@ ZEND_API void zend_print_flat_zval_r(zval *expr) /* {{{ */
properties = Z_OBJPROP_P(expr);
}
if (properties) {
GC_PROTECT_RECURSION(Z_OBJ_P(expr));
Z_PROTECT_RECURSION_P(expr);
print_flat_hash(properties);
GC_UNPROTECT_RECURSION(Z_OBJ_P(expr));
Z_UNPROTECT_RECURSION_P(expr);
}
ZEND_PUTS(")");
break;
@@ -424,16 +424,16 @@ static void zend_print_zval_r_to_buf(smart_str *buf, zval *expr, int indent) /*
switch (Z_TYPE_P(expr)) {
case IS_ARRAY:
smart_str_appends(buf, "Array\n");
if (!(GC_FLAGS(Z_ARRVAL_P(expr)) & GC_IMMUTABLE)) {
if (GC_IS_RECURSIVE(Z_ARRVAL_P(expr))) {
if (Z_REFCOUNTED_P(expr)) {
if (Z_IS_RECURSIVE_P(expr)) {
smart_str_appends(buf, " *RECURSION*");
return;
}
GC_PROTECT_RECURSION(Z_ARRVAL_P(expr));
Z_PROTECT_RECURSION_P(expr);
}
print_hash(buf, Z_ARRVAL_P(expr), indent, 0);
if (!(GC_FLAGS(Z_ARRVAL_P(expr)) & GC_IMMUTABLE)) {
GC_UNPROTECT_RECURSION(Z_ARRVAL_P(expr));
if (Z_REFCOUNTED_P(expr)) {
Z_UNPROTECT_RECURSION_P(expr);
}
break;
case IS_OBJECT:
@@ -446,7 +446,7 @@ static void zend_print_zval_r_to_buf(smart_str *buf, zval *expr, int indent) /*
zend_string_release_ex(class_name, 0);
smart_str_appends(buf, " Object\n");
if (GC_IS_RECURSIVE(Z_OBJ_P(expr))) {
if (Z_IS_RECURSIVE_P(expr)) {
smart_str_appends(buf, " *RECURSION*");
return;
}
@@ -454,9 +454,9 @@ static void zend_print_zval_r_to_buf(smart_str *buf, zval *expr, int indent) /*
break;
}
GC_PROTECT_RECURSION(Z_OBJ_P(expr));
Z_PROTECT_RECURSION_P(expr);
print_hash(buf, properties, indent, 1);
GC_UNPROTECT_RECURSION(Z_OBJ_P(expr));
Z_UNPROTECT_RECURSION_P(expr);
if (is_temp) {
zend_hash_destroy(properties);
+1 -1
View File
@@ -20,7 +20,7 @@
#ifndef ZEND_H
#define ZEND_H
#define ZEND_VERSION "3.3.2"
#define ZEND_VERSION "3.3.0-dev"
#define ZEND_ENGINE_3
+6 -24
View File
@@ -480,12 +480,10 @@ static inline zend_string *zval_make_interned_string(zval *zv) /* {{{ */
/* Common part of zend_add_literal and zend_append_individual_literal */
static inline void zend_insert_literal(zend_op_array *op_array, zval *zv, int literal_position) /* {{{ */
{
zval *lit = CT_CONSTANT_EX(op_array, literal_position);
if (Z_TYPE_P(zv) == IS_STRING) {
zval_make_interned_string(zv);
}
ZVAL_COPY_VALUE(lit, zv);
Z_EXTRA_P(lit) = 0;
ZVAL_COPY_VALUE(CT_CONSTANT_EX(op_array, literal_position), zv);
}
/* }}} */
@@ -1499,7 +1497,7 @@ static zend_bool zend_try_compile_const_expr_resolve_class_name(zval *zv, zend_a
switch (fetch_type) {
case ZEND_FETCH_CLASS_SELF:
if (CG(active_class_entry) && zend_is_scope_known()) {
if (constant || (CG(active_class_entry) && zend_is_scope_known())) {
ZVAL_STR_COPY(zv, CG(active_class_entry)->name);
} else {
ZVAL_NULL(zv);
@@ -2446,6 +2444,7 @@ static inline void zend_handle_numeric_dim(zend_op *opline, znode *dim_node) /*
return;
}
}
Z_EXTRA_P(CT_CONSTANT(opline->op2)) = 0;
}
/* }}} */
@@ -4153,14 +4152,6 @@ void zend_compile_static_call(znode *result, zend_ast *ast, uint32_t type) /* {{
if (ce) {
zend_string *lcname = Z_STR_P(CT_CONSTANT(opline->op2) + 1);
fbc = zend_hash_find_ptr(&ce->function_table, lcname);
if (fbc && !(fbc->common.fn_flags & ZEND_ACC_PUBLIC)) {
if (ce != CG(active_class_entry)
&&((fbc->common.fn_flags & ZEND_ACC_PRIVATE)
|| !zend_check_protected(zend_get_function_root_class(fbc), CG(active_class_entry)))) {
/* incompatibe function */
fbc = NULL;
}
}
}
}
@@ -4854,10 +4845,6 @@ void zend_compile_foreach(zend_ast *ast) /* {{{ */
zend_compile_stmt(stmt_ast);
/* Place JMP and FE_FREE on the line where foreach starts. It would be
* better to use the end line, but this information is not available
* currently. */
CG(zend_lineno) = ast->lineno;
zend_emit_jump(opnum_fetch);
opline = &CG(active_op_array)->opcodes[opnum_reset];
@@ -6995,7 +6982,6 @@ static inline void zend_ct_eval_greater(zval *result, zend_ast_kind kind, zval *
static zend_bool zend_try_ct_eval_array(zval *result, zend_ast *ast) /* {{{ */
{
zend_ast_list *list = zend_ast_get_list(ast);
zend_ast *last_elem_ast = NULL;
uint32_t i;
zend_bool is_constant = 1;
@@ -7008,10 +6994,6 @@ static zend_bool zend_try_ct_eval_array(zval *result, zend_ast *ast) /* {{{ */
zend_ast *elem_ast = list->child[i];
if (elem_ast == NULL) {
/* Report error at line of last non-empty element */
if (last_elem_ast) {
CG(zend_lineno) = zend_ast_get_lineno(last_elem_ast);
}
zend_error(E_COMPILE_ERROR, "Cannot use empty array elements in arrays");
}
@@ -7023,8 +7005,6 @@ static zend_bool zend_try_ct_eval_array(zval *result, zend_ast *ast) /* {{{ */
) {
is_constant = 0;
}
last_elem_ast = elem_ast;
}
if (!is_constant) {
@@ -8086,7 +8066,9 @@ void zend_compile_const_expr_magic_const(zend_ast **ast_ptr) /* {{{ */
zend_ast *ast = *ast_ptr;
/* Other cases already resolved by constant folding */
ZEND_ASSERT(ast->attr == T_CLASS_C);
ZEND_ASSERT(ast->attr == T_CLASS_C &&
CG(active_class_entry) &&
(CG(active_class_entry)->ce_flags & ZEND_ACC_TRAIT) != 0);
zend_ast_destroy(ast);
*ast_ptr = zend_ast_create(ZEND_AST_CONSTANT_CLASS);
+3 -23
View File
@@ -36,23 +36,11 @@ static void __zend_cpuid(uint32_t func, uint32_t subfunc, zend_cpu_info *cpuinfo
}
# else
static void __zend_cpuid(uint32_t func, uint32_t subfunc, zend_cpu_info *cpuinfo) {
#if defined(__i386__) && (defined(__pic__) || defined(__PIC__))
/* PIC on i386 uses %ebx, so preserve it. */
__asm__ __volatile__ (
"pushl %%ebx\n"
"cpuid\n"
"mov %%ebx,%1\n"
"popl %%ebx"
: "=a"(cpuinfo->eax), "=r"(cpuinfo->ebx), "=c"(cpuinfo->ecx), "=d"(cpuinfo->edx)
: "a"(func), "c"(subfunc)
);
#else
__asm__ __volatile__ (
"cpuid"
: "=a"(cpuinfo->eax), "=b"(cpuinfo->ebx), "=c"(cpuinfo->ecx), "=d"(cpuinfo->edx)
: "a"(func), "c"(subfunc)
);
#endif
}
# endif
#elif defined(ZEND_WIN32) && !defined(__clang__)
@@ -77,24 +65,16 @@ void zend_cpu_startup(void)
{
if (!cpuinfo.initialized) {
zend_cpu_info ebx;
int max_feature;
cpuinfo.initialized = 1;
__zend_cpuid(0, 0, &cpuinfo);
max_feature = cpuinfo.eax;
if (max_feature == 0) {
if (cpuinfo.eax == 0) {
return;
}
__zend_cpuid(1, 0, &cpuinfo);
/* for avx2 */
if (max_feature >= 7) {
__zend_cpuid(7, 0, &ebx);
cpuinfo.ebx = ebx.ebx;
} else {
cpuinfo.ebx = 0;
}
__zend_cpuid(7, 0, &ebx);
cpuinfo.ebx = ebx.ebx;
}
}
-16
View File
@@ -100,22 +100,12 @@ typedef enum _zend_cpu_feature {
void zend_cpu_startup();
ZEND_API int zend_cpu_supports(zend_cpu_feature feature);
/* Address sanitizer is incompatible with ifunc resolvers, so exclude the
* CPU support helpers from asan.
* See also https://github.com/google/sanitizers/issues/342. */
#if __has_attribute(no_sanitize_address)
# define ZEND_NO_SANITIZE_ADDRESS __attribute__((no_sanitize_address))
#else
# define ZEND_NO_SANITIZE_ADDRESS
#endif
#if PHP_HAVE_BUILTIN_CPU_SUPPORTS
/* NOTE: you should use following inline function in
* resolver functions (ifunc), as it could be called
* before all PLT symbols are resloved. in other words,
* resolver functions should not depends any external
* functions */
ZEND_NO_SANITIZE_ADDRESS
static zend_always_inline int zend_cpu_supports_sse2() {
#if PHP_HAVE_BUILTIN_CPU_INIT
__builtin_cpu_init();
@@ -123,7 +113,6 @@ static zend_always_inline int zend_cpu_supports_sse2() {
return __builtin_cpu_supports("sse2");
}
ZEND_NO_SANITIZE_ADDRESS
static zend_always_inline int zend_cpu_supports_sse3() {
#if PHP_HAVE_BUILTIN_CPU_INIT
__builtin_cpu_init();
@@ -131,7 +120,6 @@ static zend_always_inline int zend_cpu_supports_sse3() {
return __builtin_cpu_supports("sse3");
}
ZEND_NO_SANITIZE_ADDRESS
static zend_always_inline int zend_cpu_supports_ssse3() {
#if PHP_HAVE_BUILTIN_CPU_INIT
__builtin_cpu_init();
@@ -139,7 +127,6 @@ static zend_always_inline int zend_cpu_supports_ssse3() {
return __builtin_cpu_supports("ssse3");
}
ZEND_NO_SANITIZE_ADDRESS
static zend_always_inline int zend_cpu_supports_sse41() {
#if PHP_HAVE_BUILTIN_CPU_INIT
__builtin_cpu_init();
@@ -147,7 +134,6 @@ static zend_always_inline int zend_cpu_supports_sse41() {
return __builtin_cpu_supports("sse4.1");
}
ZEND_NO_SANITIZE_ADDRESS
static zend_always_inline int zend_cpu_supports_sse42() {
#if PHP_HAVE_BUILTIN_CPU_INIT
__builtin_cpu_init();
@@ -155,7 +141,6 @@ static zend_always_inline int zend_cpu_supports_sse42() {
return __builtin_cpu_supports("sse4.2");
}
ZEND_NO_SANITIZE_ADDRESS
static zend_always_inline int zend_cpu_supports_avx() {
#if PHP_HAVE_BUILTIN_CPU_INIT
__builtin_cpu_init();
@@ -163,7 +148,6 @@ static zend_always_inline int zend_cpu_supports_avx() {
return __builtin_cpu_supports("avx");
}
ZEND_NO_SANITIZE_ADDRESS
static zend_always_inline int zend_cpu_supports_avx2() {
#if PHP_HAVE_BUILTIN_CPU_INIT
__builtin_cpu_init();
+3 -13
View File
@@ -170,9 +170,9 @@ ZEND_API const zend_internal_function zend_pass_function = {
#define ZEND_VM_STACK_PAGE_SIZE (ZEND_VM_STACK_PAGE_SLOTS * sizeof(zval))
#define ZEND_VM_STACK_PAGE_ALIGNED_SIZE(size, page_size) \
#define ZEND_VM_STACK_PAGE_ALIGNED_SIZE(size) \
(((size) + ZEND_VM_STACK_HEADER_SLOTS * sizeof(zval) \
+ ((page_size) - 1)) & ~((page_size) - 1))
+ (ZEND_VM_STACK_PAGE_SIZE - 1)) & ~(ZEND_VM_STACK_PAGE_SIZE - 1))
static zend_always_inline zend_vm_stack zend_vm_stack_new_page(size_t size, zend_vm_stack prev) {
zend_vm_stack page = (zend_vm_stack)emalloc(size);
@@ -192,16 +192,6 @@ ZEND_API void zend_vm_stack_init(void)
EG(vm_stack_end) = EG(vm_stack)->end;
}
ZEND_API void zend_vm_stack_init_ex(size_t page_size)
{
/* page_size must be a power of 2 */
ZEND_ASSERT(page_size > 0 && (page_size & (page_size - 1)) == 0);
EG(vm_stack_page_size) = page_size;
EG(vm_stack) = zend_vm_stack_new_page(page_size, NULL);
EG(vm_stack_top) = EG(vm_stack)->top;
EG(vm_stack_end) = EG(vm_stack)->end;
}
ZEND_API void zend_vm_stack_destroy(void)
{
zend_vm_stack stack = EG(vm_stack);
@@ -222,7 +212,7 @@ ZEND_API void* zend_vm_stack_extend(size_t size)
stack->top = EG(vm_stack_top);
EG(vm_stack) = stack = zend_vm_stack_new_page(
EXPECTED(size < EG(vm_stack_page_size) - (ZEND_VM_STACK_HEADER_SLOTS * sizeof(zval))) ?
EG(vm_stack_page_size) : ZEND_VM_STACK_PAGE_ALIGNED_SIZE(size, EG(vm_stack_page_size)),
EG(vm_stack_page_size) : ZEND_VM_STACK_PAGE_ALIGNED_SIZE(size),
stack);
ptr = stack->top;
EG(vm_stack_top) = (void*)(((char*)ptr) + size);
-1
View File
@@ -168,7 +168,6 @@ struct _zend_vm_stack {
#endif
ZEND_API void zend_vm_stack_init(void);
ZEND_API void zend_vm_stack_init_ex(size_t page_size);
ZEND_API void zend_vm_stack_destroy(void);
ZEND_API void* zend_vm_stack_extend(size_t size);
+12 -12
View File
@@ -1126,7 +1126,18 @@ static zend_bool zend_traits_method_compatibility_check(zend_function *fn, zend_
static void zend_add_magic_methods(zend_class_entry* ce, zend_string* mname, zend_function* fe) /* {{{ */
{
if (ZSTR_LEN(ce->name) != ZSTR_LEN(mname) && (ZSTR_VAL(mname)[0] != '_' || ZSTR_VAL(mname)[1] != '_')) {
if (ZSTR_LEN(ce->name) == ZSTR_LEN(mname)) {
zend_string *lowercase_name = zend_string_tolower(ce->name);
lowercase_name = zend_new_interned_string(lowercase_name);
if (!memcmp(ZSTR_VAL(mname), ZSTR_VAL(lowercase_name), ZSTR_LEN(mname))) {
if (ce->constructor && (!ce->parent || ce->constructor != ce->parent->constructor)) {
zend_error_noreturn(E_COMPILE_ERROR, "%s has colliding constructor definitions coming from traits", ZSTR_VAL(ce->name));
}
ce->constructor = fe;
fe->common.fn_flags |= ZEND_ACC_CTOR;
}
zend_string_release_ex(lowercase_name, 0);
} else if (ZSTR_VAL(mname)[0] != '_' || ZSTR_VAL(mname)[1] != '_') {
/* pass */
} else if (zend_string_equals_literal(mname, ZEND_CLONE_FUNC_NAME)) {
ce->clone = fe;
@@ -1157,17 +1168,6 @@ static void zend_add_magic_methods(zend_class_entry* ce, zend_string* mname, zen
ce->__tostring = fe;
} else if (zend_string_equals_literal(mname, ZEND_DEBUGINFO_FUNC_NAME)) {
ce->__debugInfo = fe;
} else if (ZSTR_LEN(ce->name) == ZSTR_LEN(mname)) {
zend_string *lowercase_name = zend_string_tolower(ce->name);
lowercase_name = zend_new_interned_string(lowercase_name);
if (!memcmp(ZSTR_VAL(mname), ZSTR_VAL(lowercase_name), ZSTR_LEN(mname))) {
if (ce->constructor && (!ce->parent || ce->constructor != ce->parent->constructor)) {
zend_error_noreturn(E_COMPILE_ERROR, "%s has colliding constructor definitions coming from traits", ZSTR_VAL(ce->name));
}
ce->constructor = fe;
fe->common.fn_flags |= ZEND_ACC_CTOR;
}
zend_string_release_ex(lowercase_name, 0);
}
}
/* }}} */
+1 -1
View File
@@ -397,7 +397,7 @@ void zend_signal_init(void) /* {{{ */
/* {{{ zend_signal_startup
* alloc zend signal globals */
ZEND_API void zend_signal_startup(void)
void zend_signal_startup(void)
{
#ifdef ZTS
+1 -1
View File
@@ -87,7 +87,7 @@ ZEND_API void zend_signal_handler_unblock(void);
void zend_signal_activate(void);
void zend_signal_deactivate(void);
BEGIN_EXTERN_C()
ZEND_API void zend_signal_startup(void);
void zend_signal_startup(void);
END_EXTERN_C()
void zend_signal_init(void);
+1 -1
View File
@@ -392,7 +392,7 @@ ZEND_API zend_bool ZEND_FASTCALL I_WRAP_SONAME_FNNAME_ZU(NONE,zend_string_equal_
}
#endif
#elif defined(__GNUC__) && defined(__x86_64__) && !defined(__ILP32__)
#elif defined(__GNUC__) && defined(__x86_64__)
ZEND_API zend_bool ZEND_FASTCALL zend_string_equal_val(zend_string *s1, zend_string *s2)
{
char *ptr = ZSTR_VAL(s1);
+1 -1
View File
@@ -294,7 +294,7 @@ static zend_always_inline void zend_string_release_ex(zend_string *s, int persis
}
}
#if defined(__GNUC__) && (defined(__i386__) || (defined(__x86_64__) && !defined(__ILP32__)))
#if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
BEGIN_EXTERN_C()
ZEND_API zend_bool ZEND_FASTCALL zend_string_equal_val(zend_string *s1, zend_string *s2);
END_EXTERN_C()
-8
View File
@@ -570,14 +570,6 @@ static zend_always_inline uint32_t zval_gc_info(uint32_t gc_type_info) {
GC_DEL_FLAGS(p, GC_PROTECTED); \
} while (0)
#define GC_TRY_PROTECT_RECURSION(p) do { \
if (!(GC_FLAGS(p) & GC_IMMUTABLE)) GC_PROTECT_RECURSION(p); \
} while (0)
#define GC_TRY_UNPROTECT_RECURSION(p) do { \
if (!(GC_FLAGS(p) & GC_IMMUTABLE)) GC_UNPROTECT_RECURSION(p); \
} while (0)
#define Z_IS_RECURSIVE(zval) GC_IS_RECURSIVE(Z_COUNTED(zval))
#define Z_PROTECT_RECURSION(zval) GC_PROTECT_RECURSION(Z_COUNTED(zval))
#define Z_UNPROTECT_RECURSION(zval) GC_UNPROTECT_RECURSION(Z_COUNTED(zval))
+55 -1
View File
@@ -764,7 +764,7 @@ static size_t tsrm_realpath_r(char *path, size_t start, size_t len, int *ll, tim
if (i == len ||
(i + 1 == len && path[i] == '.')) {
/* remove double slashes and '.' */
len = EXPECTED(i > 0) ? i - 1 : 0;
len = i - 1;
is_dir = 1;
continue;
} else if (i + 2 == len && path[i] == '.' && path[i+1] == '.') {
@@ -1207,6 +1207,40 @@ static size_t tsrm_realpath_r(char *path, size_t start, size_t len, int *ll, tim
}
/* }}} */
#ifdef ZEND_WIN32
static size_t tsrm_win32_realpath_quick(char *path, size_t len, time_t *t) /* {{{ */
{
char tmp_resolved_path[MAXPATHLEN];
int tmp_resolved_path_len;
BY_HANDLE_FILE_INFORMATION info;
realpath_cache_bucket *bucket;
if (!*t) {
*t = time(0);
}
if (CWDG(realpath_cache_size_limit) && (bucket = realpath_cache_find(path, len, *t)) != NULL) {
memcpy(path, bucket->realpath, bucket->realpath_len + 1);
return bucket->realpath_len;
}
if (!php_win32_ioutil_realpath_ex0(path, tmp_resolved_path, &info)) {
DWORD err = GetLastError();
SET_ERRNO_FROM_WIN32_CODE(err);
return (size_t)-1;
}
tmp_resolved_path_len = strlen(tmp_resolved_path);
if (CWDG(realpath_cache_size_limit)) {
realpath_cache_add(path, len, tmp_resolved_path, tmp_resolved_path_len, info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY, *t);
}
memmove(path, tmp_resolved_path, tmp_resolved_path_len + 1);
return tmp_resolved_path_len;
}
/* }}} */
#endif
/* Resolve path relatively to state and put the real path into state */
/* returns 0 for ok, 1 for error */
CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func verify_path, int use_realpath) /* {{{ */
@@ -1334,7 +1368,27 @@ CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func
add_slash = (use_realpath != CWD_REALPATH) && path_length > 0 && IS_SLASH(resolved_path[path_length-1]);
t = CWDG(realpath_cache_ttl) ? 0 : -1;
#ifdef ZEND_WIN32
if (CWD_EXPAND != use_realpath) {
size_t tmp_len = tsrm_win32_realpath_quick(resolved_path, path_length, &t);
if ((size_t)-1 != tmp_len) {
path_length = tmp_len;
} else {
DWORD err = GetLastError();
/* The access denied error can mean something completely else,
fallback to complicated way. */
if (CWD_REALPATH == use_realpath && ERROR_ACCESS_DENIED != err) {
SET_ERRNO_FROM_WIN32_CODE(err);
return 1;
}
path_length = tsrm_realpath_r(resolved_path, start, path_length, &ll, &t, use_realpath, 0, NULL);
}
} else {
path_length = tsrm_realpath_r(resolved_path, start, path_length, &ll, &t, use_realpath, 0, NULL);
}
#else
path_length = tsrm_realpath_r(resolved_path, start, path_length, &ll, &t, use_realpath, 0, NULL);
#endif
if (path_length == (size_t)-1) {
errno = ENOENT;
+4 -7
View File
@@ -3099,10 +3099,6 @@ ZEND_VM_HOT_OBJ_HANDLER(112, ZEND_INIT_METHOD_CALL, CONST|TMPVAR|UNUSED|THIS|CV,
EXPECTED(obj == orig_obj)) {
CACHE_POLYMORPHIC_PTR(opline->result.num, called_scope, fbc);
}
if ((OP1_TYPE & (IS_VAR|IS_TMP_VAR)) && UNEXPECTED(obj != orig_obj)) {
/* Reset "object" to trigger reference counting */
object = NULL;
}
if (EXPECTED(fbc->type == ZEND_USER_FUNCTION) && UNEXPECTED(!fbc->op_array.run_time_cache)) {
init_func_run_time_cache(&fbc->op_array);
}
@@ -3447,10 +3443,11 @@ ZEND_VM_HOT_HANDLER(69, ZEND_INIT_NS_FCALL_BY_NAME, ANY, CONST, NUM|CACHE_SLOT)
fbc = CACHED_PTR(opline->result.num);
if (UNEXPECTED(fbc == NULL)) {
func_name = (zval *)RT_CONSTANT(opline, opline->op2);
func = zend_hash_find_ex(EG(function_table), Z_STR_P(func_name + 1), 1);
func_name = RT_CONSTANT(opline, opline->op2) + 1;
func = zend_hash_find_ex(EG(function_table), Z_STR_P(func_name), 1);
if (func == NULL) {
func = zend_hash_find_ex(EG(function_table), Z_STR_P(func_name + 2), 1);
func_name++;
func = zend_hash_find_ex(EG(function_table), Z_STR_P(func_name), 1);
if (UNEXPECTED(func == NULL)) {
ZEND_VM_DISPATCH_TO_HELPER(zend_undefined_function_helper, function_name, func_name);
}
+4 -51
View File
@@ -2153,10 +2153,11 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_NS_FCALL_BY_N
fbc = CACHED_PTR(opline->result.num);
if (UNEXPECTED(fbc == NULL)) {
func_name = (zval *)RT_CONSTANT(opline, opline->op2);
func = zend_hash_find_ex(EG(function_table), Z_STR_P(func_name + 1), 1);
func_name = RT_CONSTANT(opline, opline->op2) + 1;
func = zend_hash_find_ex(EG(function_table), Z_STR_P(func_name), 1);
if (func == NULL) {
func = zend_hash_find_ex(EG(function_table), Z_STR_P(func_name + 2), 1);
func_name++;
func = zend_hash_find_ex(EG(function_table), Z_STR_P(func_name), 1);
if (UNEXPECTED(func == NULL)) {
ZEND_VM_TAIL_CALL(zend_undefined_function_helper_SPEC(func_name ZEND_OPCODE_HANDLER_ARGS_PASSTHRU_CC));
}
@@ -5148,10 +5149,6 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_
EXPECTED(obj == orig_obj)) {
CACHE_POLYMORPHIC_PTR(opline->result.num, called_scope, fbc);
}
if ((IS_CONST & (IS_VAR|IS_TMP_VAR)) && UNEXPECTED(obj != orig_obj)) {
/* Reset "object" to trigger reference counting */
object = NULL;
}
if (EXPECTED(fbc->type == ZEND_USER_FUNCTION) && UNEXPECTED(!fbc->op_array.run_time_cache)) {
init_func_run_time_cache(&fbc->op_array);
}
@@ -7329,10 +7326,6 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_
EXPECTED(obj == orig_obj)) {
CACHE_POLYMORPHIC_PTR(opline->result.num, called_scope, fbc);
}
if ((IS_CONST & (IS_VAR|IS_TMP_VAR)) && UNEXPECTED(obj != orig_obj)) {
/* Reset "object" to trigger reference counting */
object = NULL;
}
if (EXPECTED(fbc->type == ZEND_USER_FUNCTION) && UNEXPECTED(!fbc->op_array.run_time_cache)) {
init_func_run_time_cache(&fbc->op_array);
}
@@ -10429,10 +10422,6 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_
EXPECTED(obj == orig_obj)) {
CACHE_POLYMORPHIC_PTR(opline->result.num, called_scope, fbc);
}
if ((IS_CONST & (IS_VAR|IS_TMP_VAR)) && UNEXPECTED(obj != orig_obj)) {
/* Reset "object" to trigger reference counting */
object = NULL;
}
if (EXPECTED(fbc->type == ZEND_USER_FUNCTION) && UNEXPECTED(!fbc->op_array.run_time_cache)) {
init_func_run_time_cache(&fbc->op_array);
}
@@ -14161,10 +14150,6 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_TMPVAR_C
EXPECTED(obj == orig_obj)) {
CACHE_POLYMORPHIC_PTR(opline->result.num, called_scope, fbc);
}
if (((IS_TMP_VAR|IS_VAR) & (IS_VAR|IS_TMP_VAR)) && UNEXPECTED(obj != orig_obj)) {
/* Reset "object" to trigger reference counting */
object = NULL;
}
if (EXPECTED(fbc->type == ZEND_USER_FUNCTION) && UNEXPECTED(!fbc->op_array.run_time_cache)) {
init_func_run_time_cache(&fbc->op_array);
}
@@ -15775,10 +15760,6 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_TMPVAR_T
EXPECTED(obj == orig_obj)) {
CACHE_POLYMORPHIC_PTR(opline->result.num, called_scope, fbc);
}
if (((IS_TMP_VAR|IS_VAR) & (IS_VAR|IS_TMP_VAR)) && UNEXPECTED(obj != orig_obj)) {
/* Reset "object" to trigger reference counting */
object = NULL;
}
if (EXPECTED(fbc->type == ZEND_USER_FUNCTION) && UNEXPECTED(!fbc->op_array.run_time_cache)) {
init_func_run_time_cache(&fbc->op_array);
}
@@ -17656,10 +17637,6 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_TMPVAR_C
EXPECTED(obj == orig_obj)) {
CACHE_POLYMORPHIC_PTR(opline->result.num, called_scope, fbc);
}
if (((IS_TMP_VAR|IS_VAR) & (IS_VAR|IS_TMP_VAR)) && UNEXPECTED(obj != orig_obj)) {
/* Reset "object" to trigger reference counting */
object = NULL;
}
if (EXPECTED(fbc->type == ZEND_USER_FUNCTION) && UNEXPECTED(!fbc->op_array.run_time_cache)) {
init_func_run_time_cache(&fbc->op_array);
}
@@ -32105,10 +32082,6 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_S
EXPECTED(obj == orig_obj)) {
CACHE_POLYMORPHIC_PTR(opline->result.num, called_scope, fbc);
}
if ((IS_UNUSED & (IS_VAR|IS_TMP_VAR)) && UNEXPECTED(obj != orig_obj)) {
/* Reset "object" to trigger reference counting */
object = NULL;
}
if (EXPECTED(fbc->type == ZEND_USER_FUNCTION) && UNEXPECTED(!fbc->op_array.run_time_cache)) {
init_func_run_time_cache(&fbc->op_array);
}
@@ -33840,10 +33813,6 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_UNUSED_T
EXPECTED(obj == orig_obj)) {
CACHE_POLYMORPHIC_PTR(opline->result.num, called_scope, fbc);
}
if ((IS_UNUSED & (IS_VAR|IS_TMP_VAR)) && UNEXPECTED(obj != orig_obj)) {
/* Reset "object" to trigger reference counting */
object = NULL;
}
if (EXPECTED(fbc->type == ZEND_USER_FUNCTION) && UNEXPECTED(!fbc->op_array.run_time_cache)) {
init_func_run_time_cache(&fbc->op_array);
}
@@ -36219,10 +36188,6 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_UNUSED_C
EXPECTED(obj == orig_obj)) {
CACHE_POLYMORPHIC_PTR(opline->result.num, called_scope, fbc);
}
if ((IS_UNUSED & (IS_VAR|IS_TMP_VAR)) && UNEXPECTED(obj != orig_obj)) {
/* Reset "object" to trigger reference counting */
object = NULL;
}
if (EXPECTED(fbc->type == ZEND_USER_FUNCTION) && UNEXPECTED(!fbc->op_array.run_time_cache)) {
init_func_run_time_cache(&fbc->op_array);
}
@@ -41244,10 +41209,6 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_S
EXPECTED(obj == orig_obj)) {
CACHE_POLYMORPHIC_PTR(opline->result.num, called_scope, fbc);
}
if ((IS_CV & (IS_VAR|IS_TMP_VAR)) && UNEXPECTED(obj != orig_obj)) {
/* Reset "object" to trigger reference counting */
object = NULL;
}
if (EXPECTED(fbc->type == ZEND_USER_FUNCTION) && UNEXPECTED(!fbc->op_array.run_time_cache)) {
init_func_run_time_cache(&fbc->op_array);
}
@@ -45011,10 +44972,6 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_CV_TMPVA
EXPECTED(obj == orig_obj)) {
CACHE_POLYMORPHIC_PTR(opline->result.num, called_scope, fbc);
}
if ((IS_CV & (IS_VAR|IS_TMP_VAR)) && UNEXPECTED(obj != orig_obj)) {
/* Reset "object" to trigger reference counting */
object = NULL;
}
if (EXPECTED(fbc->type == ZEND_USER_FUNCTION) && UNEXPECTED(!fbc->op_array.run_time_cache)) {
init_func_run_time_cache(&fbc->op_array);
}
@@ -50813,10 +50770,6 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_CV_CV_HA
EXPECTED(obj == orig_obj)) {
CACHE_POLYMORPHIC_PTR(opline->result.num, called_scope, fbc);
}
if ((IS_CV & (IS_VAR|IS_TMP_VAR)) && UNEXPECTED(obj != orig_obj)) {
/* Reset "object" to trigger reference counting */
object = NULL;
}
if (EXPECTED(fbc->type == ZEND_USER_FUNCTION) && UNEXPECTED(!fbc->op_array.run_time_cache)) {
init_func_run_time_cache(&fbc->op_array);
}
+1 -2
View File
@@ -992,7 +992,7 @@ function gen_code($f, $spec, $kind, $export, $code, $op1, $op2, $name, $extra_sp
}
/* Remove unused free_op1 and free_op2 declarations */
if ($spec && preg_match_all('/^\s*zend_free_op\s+[^;]+;\s*$/m', $code, $matches, PREG_SET_ORDER)) {
if ($spec && preg_match_all('/^\s*zend_free_op\s+[^;]+;\s*$/me', $code, $matches, PREG_SET_ORDER)) {
$n = 0;
foreach ($matches as $match) {
$code = preg_replace('/'.preg_quote($match[0],'/').'/', "\$D$n", $code);
@@ -2671,7 +2671,6 @@ function gen_vm($def, $skel) {
// Generate specialized executor
gen_executor($f, $skl, ZEND_VM_SPEC, ZEND_VM_KIND, "execute", "zend_vm_init");
out($f, "\n");
// Generate zend_vm_get_opcode_handler() function
out($f, "static const void* ZEND_FASTCALL zend_vm_get_opcode_handler_ex(uint32_t spec, const zend_op* op)\n");
+3 -6
View File
@@ -107,8 +107,8 @@ int zend_sprintf(char *buffer, const char *format, ...);
PHP_MAJOR_VERSION=7
PHP_MINOR_VERSION=3
PHP_RELEASE_VERSION=2
PHP_EXTRA_VERSION=""
PHP_RELEASE_VERSION=0
PHP_EXTRA_VERSION="RC5"
PHP_VERSION="$PHP_MAJOR_VERSION.$PHP_MINOR_VERSION.$PHP_RELEASE_VERSION$PHP_EXTRA_VERSION"
PHP_VERSION_ID=`expr [$]PHP_MAJOR_VERSION \* 10000 + [$]PHP_MINOR_VERSION \* 100 + [$]PHP_RELEASE_VERSION`
@@ -585,10 +585,7 @@ PHP_SOCKADDR_CHECKS
dnl Checks for GCC function attributes on all systems except ones without glibc
dnl Fix for these systems is already included in GCC 7, but not on GCC 6
dnl
dnl At least some versions of FreeBSD seem to have buggy ifunc support, see
dnl bug #77284. Conservatively don't use ifuncs on FreeBSD.
AS_CASE([$host_alias], [*-*-*android*|*-*-*uclibc*|*-*-*musl*|*freebsd*], [true], [
AS_CASE([$host_alias], [*-*-*android*|*-*-*uclibc*|*-*-*musl*], [true], [
AX_GCC_FUNC_ATTRIBUTE([ifunc])
AX_GCC_FUNC_ATTRIBUTE([target])
])
-7
View File
@@ -28,7 +28,6 @@
#include "php_com_dotnet.h"
#include "php_com_dotnet_internal.h"
#include "Zend/zend_exceptions.h"
#include "Zend/zend_interfaces.h"
ZEND_DECLARE_MODULE_GLOBALS(com_dotnet)
static PHP_GINIT_FUNCTION(com_dotnet);
@@ -311,15 +310,11 @@ PHP_MINIT_FUNCTION(com_dotnet)
ce.create_object = php_com_object_new;
php_com_variant_class_entry = zend_register_internal_class(&ce);
php_com_variant_class_entry->get_iterator = php_com_iter_get;
php_com_variant_class_entry->serialize = zend_class_serialize_deny;
php_com_variant_class_entry->unserialize = zend_class_unserialize_deny;
INIT_CLASS_ENTRY(ce, "com", NULL);
ce.create_object = php_com_object_new;
tmp = zend_register_internal_class_ex(&ce, php_com_variant_class_entry);
tmp->get_iterator = php_com_iter_get;
tmp->serialize = zend_class_serialize_deny;
tmp->unserialize = zend_class_unserialize_deny;
zend_ts_hash_init(&php_com_typelibraries, 0, NULL, php_com_typelibrary_dtor, 1);
@@ -328,8 +323,6 @@ PHP_MINIT_FUNCTION(com_dotnet)
ce.create_object = php_com_object_new;
tmp = zend_register_internal_class_ex(&ce, php_com_variant_class_entry);
tmp->get_iterator = php_com_iter_get;
tmp->serialize = zend_class_serialize_deny;
tmp->unserialize = zend_class_unserialize_deny;
#endif
REGISTER_INI_ENTRIES();
+1 -1
View File
@@ -229,7 +229,7 @@ static HashTable *com_properties_get(zval *object)
* infinite recursion when the hash is displayed via var_dump().
* Perhaps it is best to leave it un-implemented.
*/
return &zend_empty_array;
return NULL;
}
static void function_dtor(zval *zv)
-57
View File
@@ -1,57 +0,0 @@
--TEST--
Bug #77177 (Serializing or unserializing COM objects crashes)
--SKIPIF--
<?php
if (!extension_loaded('com_dotnet')) die('skip com_dotnet extension not available');
?>
--FILE--
<?php
$com = new COM("WScript.Shell");
$dotnet = new DOTNET("mscorlib", "System.Collections.Stack");
$variant = new VARIANT;
foreach ([$com, $dotnet, $variant] as $object) {
try {
serialize($object);
} catch (Exception $ex) {
echo "Exception: {$ex->getMessage()}\n";
}
}
$strings = ['C:3:"com":0:{}', 'C:6:"dotnet":0:{}', 'C:7:"variant":0:{}'];
foreach ($strings as $string) {
try {
unserialize($string);
} catch (Exception $ex) {
echo "Exception: {$ex->getMessage()}\n";
}
}
$strings = ['O:3:"com":0:{}', 'O:6:"dotnet":0:{}', 'O:7:"variant":0:{}'];
foreach ($strings as $string) {
var_dump(unserialize($string));
}
?>
===DONE===
--EXPECTF--
Exception: Serialization of 'com' is not allowed
Exception: Serialization of 'dotnet' is not allowed
Exception: Serialization of 'variant' is not allowed
Exception: Unserialization of 'com' is not allowed
Exception: Unserialization of 'dotnet' is not allowed
Exception: Unserialization of 'variant' is not allowed
Warning: Erroneous data format for unserializing 'com' in %s on line %d
Notice: unserialize(): Error at offset 13 of 14 bytes in %s on line %d
bool(false)
Warning: Erroneous data format for unserializing 'dotnet' in %s on line %d
Notice: unserialize(): Error at offset 16 of 17 bytes in %s on line %d
bool(false)
Warning: Erroneous data format for unserializing 'variant' in %s on line %d
Notice: unserialize(): Error at offset 17 of 18 bytes in %s on line %d
bool(false)
===DONE===
+32 -7
View File
@@ -3294,27 +3294,52 @@ PHP_FUNCTION(curl_getinfo)
CAAS("scheme", s_code);
}
#endif
#if LIBCURL_VERSION_NUM >= 0x073700 /* Available since 7.55.0 */
if (curl_easy_getinfo(ch->cp, CURLINFO_CONTENT_LENGTH_DOWNLOAD_T, &co) == CURLE_OK) {
CAAL("content_length_download", co);
}
if (curl_easy_getinfo(ch->cp, CURLINFO_CONTENT_LENGTH_UPLOAD_T, &co) == CURLE_OK) {
CAAL("content_length_upload", co);
}
if (curl_easy_getinfo(ch->cp, CURLINFO_SIZE_DOWNLOAD_T, &co) == CURLE_OK) {
CAAL("size_download", co);
}
if (curl_easy_getinfo(ch->cp, CURLINFO_SIZE_UPLOAD_T, &co) == CURLE_OK) {
CAAL("size_upload", co);
}
if (curl_easy_getinfo(ch->cp, CURLINFO_SPEED_DOWNLOAD_T, &co) == CURLE_OK) {
CAAL("speed_download", co);
}
if (curl_easy_getinfo(ch->cp, CURLINFO_SPEED_UPLOAD_T, &co) == CURLE_OK) {
CAAL("speed_upload", co);
}
#endif
#if LIBCURL_VERSION_NUM >= 0x073b00 /* Available since 7.59.0 */
if (curl_easy_getinfo(ch->cp, CURLINFO_FILETIME_T, &co) == CURLE_OK) {
CAAL("filetime", co);
}
#endif
#if LIBCURL_VERSION_NUM >= 0x073d00 /* Available since 7.61.0 */
if (curl_easy_getinfo(ch->cp, CURLINFO_APPCONNECT_TIME_T, &co) == CURLE_OK) {
CAAL("appconnect_time_us", co);
CAAL("appconnect_time", co);
}
if (curl_easy_getinfo(ch->cp, CURLINFO_CONNECT_TIME_T, &co) == CURLE_OK) {
CAAL("connect_time_us", co);
CAAL("connect_time", co);
}
if (curl_easy_getinfo(ch->cp, CURLINFO_NAMELOOKUP_TIME_T, &co) == CURLE_OK) {
CAAL("namelookup_time_us", co);
CAAL("namelookup_time", co);
}
if (curl_easy_getinfo(ch->cp, CURLINFO_PRETRANSFER_TIME_T, &co) == CURLE_OK) {
CAAL("pretransfer_time_us", co);
CAAL("pretransfer_time", co);
}
if (curl_easy_getinfo(ch->cp, CURLINFO_REDIRECT_TIME_T, &co) == CURLE_OK) {
CAAL("redirect_time_us", co);
CAAL("redirect_time", co);
}
if (curl_easy_getinfo(ch->cp, CURLINFO_STARTTRANSFER_TIME_T, &co) == CURLE_OK) {
CAAL("starttransfer_time_us", co);
CAAL("starttransfer_time", co);
}
if (curl_easy_getinfo(ch->cp, CURLINFO_TOTAL_TIME_T, &co) == CURLE_OK) {
CAAL("total_time_us", co);
CAAL("total_time", co);
}
#endif
if (ch->header.str) {
-1
View File
@@ -502,7 +502,6 @@ static int _php_server_push_callback(CURL *parent_ch, CURL *easy, size_t num_hea
Z_ADDREF_P(pz_parent_ch);
res = zend_register_resource(ch, le_curl);
ch->res = res;
ZVAL_RES(&pz_ch, res);
size_t i;
-53
View File
@@ -1,53 +0,0 @@
--TEST--
Bug #76675 (Segfault with H2 server push write/writeheader handlers)
--SKIPIF--
<?php
include 'skipif.inc';
if (getenv("SKIP_ONLINE_TESTS")) {
die("skip online test");
}
$curl_version = curl_version();
if ($curl_version['version_number'] < 0x073d00) {
exit("skip: test may crash with curl < 7.61.0");
}
?>
--FILE--
<?php
$transfers = 1;
$callback = function($parent, $passed) use (&$transfers) {
curl_setopt($passed, CURLOPT_WRITEFUNCTION, function ($ch, $data) {
echo "Received ".strlen($data);
return strlen($data);
});
$transfers++;
return CURL_PUSH_OK;
};
$mh = curl_multi_init();
curl_multi_setopt($mh, CURLMOPT_PIPELINING, CURLPIPE_MULTIPLEX);
curl_multi_setopt($mh, CURLMOPT_PUSHFUNCTION, $callback);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://http2.golang.org/serverpush');
curl_setopt($ch, CURLOPT_HTTP_VERSION, 3);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_multi_add_handle($mh, $ch);
$active = null;
do {
$status = curl_multi_exec($mh, $active);
do {
$info = curl_multi_info_read($mh);
if (false !== $info && $info['msg'] == CURLMSG_DONE) {
$handle = $info['handle'];
if ($handle !== null) {
$transfers--;
curl_multi_remove_handle($mh, $handle);
curl_close($handle);
}
}
} while ($info);
} while ($transfers);
curl_multi_close($mh);
?>
--EXPECTREGEX--
(Received \d+)+
+1 -4
View File
@@ -35,10 +35,7 @@ timelib_rel_time *timelib_diff(timelib_time *one, timelib_time *two)
rt = timelib_rel_time_ctor();
rt->invert = 0;
if (
(one->sse > two->sse) ||
(one->sse == two->sse && one->us > two->us)
) {
if (one->sse > two->sse) {
swp = two;
two = one;
one = swp;
+128 -165
View File
@@ -51,37 +51,17 @@ static inline uint32_t timelib_conv_int_unsigned(uint32_t value)
{
return value;
}
static inline uint64_t timelib_conv_int64_unsigned(uint64_t value)
{
return value;
}
#else
static inline uint32_t timelib_conv_int_unsigned(uint32_t value)
{
return
((value & 0x000000ff) << 24) +
((value & 0x0000ff00) << 8) +
((value & 0x00ff0000) >> 8) +
return ((value & 0x000000ff) << 24) +
((value & 0x0000ff00) << 8) +
((value & 0x00ff0000) >> 8) +
((value & 0xff000000) >> 24);
}
static inline uint64_t timelib_conv_int64_unsigned(uint64_t value)
{
return
((value & 0x00000000000000ff) << 56) +
((value & 0x000000000000ff00) << 40) +
((value & 0x0000000000ff0000) << 24) +
((value & 0x00000000ff000000) << 8) +
((value & 0x000000ff00000000) >> 8) +
((value & 0x0000ff0000000000) >> 24) +
((value & 0x00ff000000000000) >> 40) +
((value & 0xff00000000000000) >> 56);
}
#endif
#define timelib_conv_int_signed(value) ((int32_t) timelib_conv_int_unsigned((int32_t) value))
#define timelib_conv_int64_signed(value) ((int64_t) timelib_conv_int64_unsigned((int64_t) value))
static int read_php_preamble(const unsigned char **tzf, timelib_tzinfo *tz)
{
@@ -152,49 +132,56 @@ static int read_preamble(const unsigned char **tzf, timelib_tzinfo *tz, unsigned
}
}
static void read_32bit_header(const unsigned char **tzf, timelib_tzinfo *tz)
static void read_header(const unsigned char **tzf, timelib_tzinfo *tz)
{
uint32_t buffer[6];
memcpy(&buffer, *tzf, sizeof(buffer));
tz->_bit32.ttisgmtcnt = timelib_conv_int_unsigned(buffer[0]);
tz->_bit32.ttisstdcnt = timelib_conv_int_unsigned(buffer[1]);
tz->_bit32.leapcnt = timelib_conv_int_unsigned(buffer[2]);
tz->_bit32.timecnt = timelib_conv_int_unsigned(buffer[3]);
tz->_bit32.typecnt = timelib_conv_int_unsigned(buffer[4]);
tz->_bit32.charcnt = timelib_conv_int_unsigned(buffer[5]);
tz->bit32.ttisgmtcnt = timelib_conv_int_unsigned(buffer[0]);
tz->bit32.ttisstdcnt = timelib_conv_int_unsigned(buffer[1]);
tz->bit32.leapcnt = timelib_conv_int_unsigned(buffer[2]);
tz->bit32.timecnt = timelib_conv_int_unsigned(buffer[3]);
tz->bit32.typecnt = timelib_conv_int_unsigned(buffer[4]);
tz->bit32.charcnt = timelib_conv_int_unsigned(buffer[5]);
*tzf += sizeof(buffer);
}
static int read_64bit_transitions(const unsigned char **tzf, timelib_tzinfo *tz)
static void skip_64bit_transitions(const unsigned char **tzf, timelib_tzinfo *tz)
{
int64_t *buffer = NULL;
if (tz->bit64.timecnt) {
*tzf += (sizeof(int64_t) * tz->bit64.timecnt);
*tzf += (sizeof(unsigned char) * tz->bit64.timecnt);
}
}
static int read_transitions(const unsigned char **tzf, timelib_tzinfo *tz)
{
int32_t *buffer = NULL;
uint32_t i;
unsigned char *cbuffer = NULL;
if (tz->bit64.timecnt) {
buffer = (int64_t*) timelib_malloc(tz->bit64.timecnt * sizeof(int64_t));
if (tz->bit32.timecnt) {
buffer = (int32_t*) timelib_malloc(tz->bit32.timecnt * sizeof(int32_t));
if (!buffer) {
return TIMELIB_ERROR_CANNOT_ALLOCATE;
}
memcpy(buffer, *tzf, sizeof(int64_t) * tz->bit64.timecnt);
*tzf += (sizeof(int64_t) * tz->bit64.timecnt);
for (i = 0; i < tz->bit64.timecnt; i++) {
buffer[i] = timelib_conv_int64_signed(buffer[i]);
memcpy(buffer, *tzf, sizeof(int32_t) * tz->bit32.timecnt);
*tzf += (sizeof(int32_t) * tz->bit32.timecnt);
for (i = 0; i < tz->bit32.timecnt; i++) {
buffer[i] = timelib_conv_int_signed(buffer[i]);
/* Sanity check to see whether TS is just increasing */
if (i > 0 && !(buffer[i] > buffer[i - 1])) {
return TIMELIB_ERROR_CORRUPT_TRANSITIONS_DONT_INCREASE;
}
}
cbuffer = (unsigned char*) timelib_malloc(tz->bit64.timecnt * sizeof(unsigned char));
cbuffer = (unsigned char*) timelib_malloc(tz->bit32.timecnt * sizeof(unsigned char));
if (!cbuffer) {
timelib_free(buffer);
return TIMELIB_ERROR_CANNOT_ALLOCATE;
}
memcpy(cbuffer, *tzf, sizeof(unsigned char) * tz->bit64.timecnt);
*tzf += sizeof(unsigned char) * tz->bit64.timecnt;
memcpy(cbuffer, *tzf, sizeof(unsigned char) * tz->bit32.timecnt);
*tzf += sizeof(unsigned char) * tz->bit32.timecnt;
}
tz->trans = buffer;
@@ -203,35 +190,41 @@ static int read_64bit_transitions(const unsigned char **tzf, timelib_tzinfo *tz)
return 0;
}
static void skip_32bit_transitions(const unsigned char **tzf, timelib_tzinfo *tz)
static void skip_64bit_types(const unsigned char **tzf, timelib_tzinfo *tz)
{
if (tz->_bit32.timecnt) {
*tzf += (sizeof(int32_t) * tz->_bit32.timecnt);
*tzf += sizeof(unsigned char) * tz->_bit32.timecnt;
*tzf += sizeof(unsigned char) * 6 * tz->bit64.typecnt;
*tzf += sizeof(char) * tz->bit64.charcnt;
if (tz->bit64.leapcnt) {
*tzf += sizeof(int64_t) * tz->bit64.leapcnt * 2;
}
if (tz->bit64.ttisstdcnt) {
*tzf += sizeof(unsigned char) * tz->bit64.ttisstdcnt;
}
if (tz->bit64.ttisgmtcnt) {
*tzf += sizeof(unsigned char) * tz->bit64.ttisgmtcnt;
}
}
static int read_64bit_types(const unsigned char **tzf, timelib_tzinfo *tz)
static int read_types(const unsigned char **tzf, timelib_tzinfo *tz)
{
unsigned char *buffer;
int32_t *leap_buffer;
unsigned int i, j;
/* Offset Types */
buffer = (unsigned char*) timelib_malloc(tz->bit64.typecnt * sizeof(unsigned char) * 6);
buffer = (unsigned char*) timelib_malloc(tz->bit32.typecnt * sizeof(unsigned char) * 6);
if (!buffer) {
return TIMELIB_ERROR_CANNOT_ALLOCATE;
}
memcpy(buffer, *tzf, sizeof(unsigned char) * 6 * tz->bit64.typecnt);
*tzf += sizeof(unsigned char) * 6 * tz->bit64.typecnt;
memcpy(buffer, *tzf, sizeof(unsigned char) * 6 * tz->bit32.typecnt);
*tzf += sizeof(unsigned char) * 6 * tz->bit32.typecnt;
tz->type = (ttinfo*) timelib_malloc(tz->bit64.typecnt * sizeof(ttinfo));
tz->type = (ttinfo*) timelib_malloc(tz->bit32.typecnt * sizeof(ttinfo));
if (!tz->type) {
timelib_free(buffer);
return TIMELIB_ERROR_CANNOT_ALLOCATE;
}
for (i = 0; i < tz->bit64.typecnt; i++) {
for (i = 0; i < tz->bit32.typecnt; i++) {
j = i * 6;
tz->type[i].offset = 0;
tz->type[i].offset += (int32_t) (((uint32_t) buffer[j]) << 24) + (buffer[j + 1] << 16) + (buffer[j + 2] << 8) + tz->type[i].offset + buffer[j + 3];
@@ -240,60 +233,56 @@ static int read_64bit_types(const unsigned char **tzf, timelib_tzinfo *tz)
}
timelib_free(buffer);
/* Abbreviations */
tz->timezone_abbr = (char*) timelib_malloc(tz->bit64.charcnt);
tz->timezone_abbr = (char*) timelib_malloc(tz->bit32.charcnt);
if (!tz->timezone_abbr) {
return TIMELIB_ERROR_CORRUPT_NO_ABBREVIATION;
}
memcpy(tz->timezone_abbr, *tzf, sizeof(char) * tz->bit64.charcnt);
*tzf += sizeof(char) * tz->bit64.charcnt;
memcpy(tz->timezone_abbr, *tzf, sizeof(char) * tz->bit32.charcnt);
*tzf += sizeof(char) * tz->bit32.charcnt;
/* Leap seconds (only use in 'right/') format */
if (tz->bit64.leapcnt) {
leap_buffer = (int32_t *) timelib_malloc(tz->bit64.leapcnt * (sizeof(int64_t) + sizeof(int32_t)));
if (tz->bit32.leapcnt) {
leap_buffer = (int32_t *) timelib_malloc(tz->bit32.leapcnt * 2 * sizeof(int32_t));
if (!leap_buffer) {
return TIMELIB_ERROR_CANNOT_ALLOCATE;
}
memcpy(leap_buffer, *tzf, tz->bit64.leapcnt * (sizeof(int64_t) + sizeof(int32_t)));
*tzf += tz->bit64.leapcnt * (sizeof(int64_t) + sizeof(int32_t));
memcpy(leap_buffer, *tzf, sizeof(int32_t) * tz->bit32.leapcnt * 2);
*tzf += sizeof(int32_t) * tz->bit32.leapcnt * 2;
tz->leap_times = (tlinfo*) timelib_malloc(tz->bit64.leapcnt * sizeof(tlinfo));
tz->leap_times = (tlinfo*) timelib_malloc(tz->bit32.leapcnt * sizeof(tlinfo));
if (!tz->leap_times) {
timelib_free(leap_buffer);
return TIMELIB_ERROR_CANNOT_ALLOCATE;
}
for (i = 0; i < tz->bit64.leapcnt; i++) {
tz->leap_times[i].trans = timelib_conv_int64_signed(leap_buffer[i * 3 + 1] * 4294967296 + leap_buffer[i * 3]);
tz->leap_times[i].offset = timelib_conv_int_signed(leap_buffer[i * 3 + 2]);
for (i = 0; i < tz->bit32.leapcnt; i++) {
tz->leap_times[i].trans = timelib_conv_int_signed(leap_buffer[i * 2]);
tz->leap_times[i].offset = timelib_conv_int_signed(leap_buffer[i * 2 + 1]);
}
timelib_free(leap_buffer);
}
/* Standard/Wall Indicators (unused) */
if (tz->bit64.ttisstdcnt) {
buffer = (unsigned char*) timelib_malloc(tz->bit64.ttisstdcnt * sizeof(unsigned char));
if (tz->bit32.ttisstdcnt) {
buffer = (unsigned char*) timelib_malloc(tz->bit32.ttisstdcnt * sizeof(unsigned char));
if (!buffer) {
return TIMELIB_ERROR_CANNOT_ALLOCATE;
}
memcpy(buffer, *tzf, sizeof(unsigned char) * tz->bit64.ttisstdcnt);
*tzf += sizeof(unsigned char) * tz->bit64.ttisstdcnt;
memcpy(buffer, *tzf, sizeof(unsigned char) * tz->bit32.ttisstdcnt);
*tzf += sizeof(unsigned char) * tz->bit32.ttisstdcnt;
for (i = 0; i < tz->bit64.ttisstdcnt; i++) {
for (i = 0; i < tz->bit32.ttisstdcnt; i++) {
tz->type[i].isstdcnt = buffer[i];
}
timelib_free(buffer);
}
/* UT/Local Time Indicators (unused) */
if (tz->bit64.ttisgmtcnt) {
buffer = (unsigned char*) timelib_malloc(tz->bit64.ttisgmtcnt * sizeof(unsigned char));
if (tz->bit32.ttisgmtcnt) {
buffer = (unsigned char*) timelib_malloc(tz->bit32.ttisgmtcnt * sizeof(unsigned char));
if (!buffer) {
return TIMELIB_ERROR_CANNOT_ALLOCATE;
}
memcpy(buffer, *tzf, sizeof(unsigned char) * tz->bit64.ttisgmtcnt);
*tzf += sizeof(unsigned char) * tz->bit64.ttisgmtcnt;
memcpy(buffer, *tzf, sizeof(unsigned char) * tz->bit32.ttisgmtcnt);
*tzf += sizeof(unsigned char) * tz->bit32.ttisgmtcnt;
for (i = 0; i < tz->bit64.ttisgmtcnt; i++) {
for (i = 0; i < tz->bit32.ttisgmtcnt; i++) {
tz->type[i].isgmtcnt = buffer[i];
}
timelib_free(buffer);
@@ -302,30 +291,6 @@ static int read_64bit_types(const unsigned char **tzf, timelib_tzinfo *tz)
return 0;
}
static void skip_32bit_types(const unsigned char **tzf, timelib_tzinfo *tz)
{
/* Offset Types */
*tzf += sizeof(unsigned char) * 6 * tz->_bit32.typecnt;
/* Abbreviations */
*tzf += sizeof(char) * tz->_bit32.charcnt;
/* Leap seconds (only use in 'right/') format */
if (tz->_bit32.leapcnt) {
*tzf += sizeof(int32_t) * tz->_bit32.leapcnt * 2;
}
/* Standard/Wall Indicators (unused) */
if (tz->_bit32.ttisstdcnt) {
*tzf += sizeof(unsigned char) * tz->_bit32.ttisstdcnt;
}
/* UT/Local Time Indicators (unused) */
if (tz->_bit32.ttisgmtcnt) {
*tzf += sizeof(unsigned char) * tz->_bit32.ttisgmtcnt;
}
}
static void skip_posix_string(const unsigned char **tzf, timelib_tzinfo *tz)
{
int n_count = 0;
@@ -374,16 +339,14 @@ void timelib_dump_tzinfo(timelib_tzinfo *tz)
printf("Geo Location: %f,%f\n", tz->location.latitude, tz->location.longitude);
printf("Comments:\n%s\n", tz->location.comments);
printf("BC: %s\n", tz->bc ? "" : "yes");
printf("UTC/Local count: " TIMELIB_ULONG_FMT "\n", (timelib_ulong) tz->bit32.ttisgmtcnt);
printf("Std/Wall count: " TIMELIB_ULONG_FMT "\n", (timelib_ulong) tz->bit32.ttisstdcnt);
printf("Leap.sec. count: " TIMELIB_ULONG_FMT "\n", (timelib_ulong) tz->bit32.leapcnt);
printf("Trans. count: " TIMELIB_ULONG_FMT "\n", (timelib_ulong) tz->bit32.timecnt);
printf("Local types count: " TIMELIB_ULONG_FMT "\n", (timelib_ulong) tz->bit32.typecnt);
printf("Zone Abbr. count: " TIMELIB_ULONG_FMT "\n", (timelib_ulong) tz->bit32.charcnt);
printf("\n64-bit:\n");
printf("UTC/Local count: " TIMELIB_ULONG_FMT "\n", (timelib_ulong) tz->bit64.ttisgmtcnt);
printf("Std/Wall count: " TIMELIB_ULONG_FMT "\n", (timelib_ulong) tz->bit64.ttisstdcnt);
printf("Leap.sec. count: " TIMELIB_ULONG_FMT "\n", (timelib_ulong) tz->bit64.leapcnt);
printf("Trans. count: " TIMELIB_ULONG_FMT "\n", (timelib_ulong) tz->bit64.timecnt);
printf("Local types count: " TIMELIB_ULONG_FMT "\n", (timelib_ulong) tz->bit64.typecnt);
printf("Zone Abbr. count: " TIMELIB_ULONG_FMT "\n", (timelib_ulong) tz->bit64.charcnt);
printf ("%16s (%20s) = %3d [%5ld %1d %3d '%s' (%d,%d)]\n",
printf ("%8s (%12s) = %3d [%5ld %1d %3d '%s' (%d,%d)]\n",
"", "", 0,
(long int) tz->type[0].offset,
tz->type[0].isdst,
@@ -392,8 +355,8 @@ void timelib_dump_tzinfo(timelib_tzinfo *tz)
tz->type[0].isstdcnt,
tz->type[0].isgmtcnt
);
for (i = 0; i < tz->bit64.timecnt; i++) {
printf ("%016lX (%20ld) = %3d [%5ld %1d %3d '%s' (%d,%d)]\n",
for (i = 0; i < tz->bit32.timecnt; i++) {
printf ("%08X (%12d) = %3d [%5ld %1d %3d '%s' (%d,%d)]\n",
tz->trans[i], tz->trans[i], tz->trans_idx[i],
(long int) tz->type[tz->trans_idx[i]].offset,
tz->type[tz->trans_idx[i]].isdst,
@@ -403,8 +366,8 @@ void timelib_dump_tzinfo(timelib_tzinfo *tz)
tz->type[tz->trans_idx[i]].isgmtcnt
);
}
for (i = 0; i < tz->bit64.leapcnt; i++) {
printf ("%016lX (%20ld) = %d\n",
for (i = 0; i < tz->bit32.leapcnt; i++) {
printf ("%08X (%12ld) = %d\n",
tz->leap_times[i].trans,
(long) tz->leap_times[i].trans,
tz->leap_times[i].offset);
@@ -507,35 +470,31 @@ timelib_tzinfo *timelib_parse_tzfile(char *timezone, const timelib_tzdb *tzdb, i
timelib_tzinfo_dtor(tmp);
return NULL;
}
if (version < 2 || version > 3) {
*error_code = TIMELIB_ERROR_UNSUPPORTED_VERSION;
timelib_tzinfo_dtor(tmp);
return NULL;
}
//printf("- timezone: %s, version: %0d\n", timezone, version);
read_32bit_header(&tzf, tmp);
skip_32bit_transitions(&tzf, tmp);
skip_32bit_types(&tzf, tmp);
if (!skip_64bit_preamble(&tzf, tmp)) {
/* 64 bit preamble is not in place */
*error_code = TIMELIB_ERROR_CORRUPT_NO_64BIT_PREAMBLE;
return NULL;
}
read_64bit_header(&tzf, tmp);
if ((transitions_result = read_64bit_transitions(&tzf, tmp)) != 0) {
read_header(&tzf, tmp);
if ((transitions_result = read_transitions(&tzf, tmp)) != 0) {
/* Corrupt file as transitions do not increase */
*error_code = transitions_result;
timelib_tzinfo_dtor(tmp);
return NULL;
}
if ((types_result = read_64bit_types(&tzf, tmp)) != 0) {
if ((types_result = read_types(&tzf, tmp)) != 0) {
*error_code = types_result;
timelib_tzinfo_dtor(tmp);
return NULL;
}
skip_posix_string(&tzf, tmp);
if (version == 2 || version == 3) {
if (!skip_64bit_preamble(&tzf, tmp)) {
/* 64 bit preamble is not in place */
*error_code = TIMELIB_ERROR_CORRUPT_NO_64BIT_PREAMBLE;
return NULL;
}
read_64bit_header(&tzf, tmp);
skip_64bit_transitions(&tzf, tmp);
skip_64bit_types(&tzf, tmp);
skip_posix_string(&tzf, tmp);
}
if (type == TIMELIB_TZINFO_PHP) {
read_location(&tzf, tmp);
@@ -566,35 +525,29 @@ void timelib_tzinfo_dtor(timelib_tzinfo *tz)
timelib_tzinfo *timelib_tzinfo_clone(timelib_tzinfo *tz)
{
timelib_tzinfo *tmp = timelib_tzinfo_ctor(tz->name);
tmp->_bit32.ttisgmtcnt = tz->_bit32.ttisgmtcnt;
tmp->_bit32.ttisstdcnt = tz->_bit32.ttisstdcnt;
tmp->_bit32.leapcnt = tz->_bit32.leapcnt;
tmp->_bit32.timecnt = tz->_bit32.timecnt;
tmp->_bit32.typecnt = tz->_bit32.typecnt;
tmp->_bit32.charcnt = tz->_bit32.charcnt;
tmp->bit64.ttisgmtcnt = tz->bit64.ttisgmtcnt;
tmp->bit64.ttisstdcnt = tz->bit64.ttisstdcnt;
tmp->bit64.leapcnt = tz->bit64.leapcnt;
tmp->bit64.timecnt = tz->bit64.timecnt;
tmp->bit64.typecnt = tz->bit64.typecnt;
tmp->bit64.charcnt = tz->bit64.charcnt;
tmp->bit32.ttisgmtcnt = tz->bit32.ttisgmtcnt;
tmp->bit32.ttisstdcnt = tz->bit32.ttisstdcnt;
tmp->bit32.leapcnt = tz->bit32.leapcnt;
tmp->bit32.timecnt = tz->bit32.timecnt;
tmp->bit32.typecnt = tz->bit32.typecnt;
tmp->bit32.charcnt = tz->bit32.charcnt;
if (tz->bit64.timecnt) {
tmp->trans = (int64_t *) timelib_malloc(tz->bit64.timecnt * sizeof(int64_t));
tmp->trans_idx = (unsigned char*) timelib_malloc(tz->bit64.timecnt * sizeof(unsigned char));
memcpy(tmp->trans, tz->trans, tz->bit64.timecnt * sizeof(int64_t));
memcpy(tmp->trans_idx, tz->trans_idx, tz->bit64.timecnt * sizeof(unsigned char));
if (tz->bit32.timecnt) {
tmp->trans = (int32_t *) timelib_malloc(tz->bit32.timecnt * sizeof(int32_t));
tmp->trans_idx = (unsigned char*) timelib_malloc(tz->bit32.timecnt * sizeof(unsigned char));
memcpy(tmp->trans, tz->trans, tz->bit32.timecnt * sizeof(int32_t));
memcpy(tmp->trans_idx, tz->trans_idx, tz->bit32.timecnt * sizeof(unsigned char));
}
tmp->type = (ttinfo*) timelib_malloc(tz->bit64.typecnt * sizeof(ttinfo));
memcpy(tmp->type, tz->type, tz->bit64.typecnt * sizeof(ttinfo));
tmp->type = (ttinfo*) timelib_malloc(tz->bit32.typecnt * sizeof(ttinfo));
memcpy(tmp->type, tz->type, tz->bit32.typecnt * sizeof(ttinfo));
tmp->timezone_abbr = (char*) timelib_malloc(tz->bit64.charcnt);
memcpy(tmp->timezone_abbr, tz->timezone_abbr, tz->bit64.charcnt);
tmp->timezone_abbr = (char*) timelib_malloc(tz->bit32.charcnt);
memcpy(tmp->timezone_abbr, tz->timezone_abbr, tz->bit32.charcnt);
if (tz->bit64.leapcnt) {
tmp->leap_times = (tlinfo*) timelib_malloc(tz->bit64.leapcnt * sizeof(tlinfo));
memcpy(tmp->leap_times, tz->leap_times, tz->bit64.leapcnt * sizeof(tlinfo));
if (tz->bit32.leapcnt) {
tmp->leap_times = (tlinfo*) timelib_malloc(tz->bit32.leapcnt * sizeof(tlinfo));
memcpy(tmp->leap_times, tz->leap_times, tz->bit32.leapcnt * sizeof(tlinfo));
}
return tmp;
@@ -606,9 +559,9 @@ static ttinfo* fetch_timezone_offset(timelib_tzinfo *tz, timelib_sll ts, timelib
/* If there is no transition time, we pick the first one, if that doesn't
* exist we return NULL */
if (!tz->bit64.timecnt || !tz->trans) {
if (!tz->bit32.timecnt || !tz->trans) {
*transition_time = 0;
if (tz->bit64.typecnt == 1) {
if (tz->bit32.typecnt == 1) {
return &(tz->type[0]);
}
return NULL;
@@ -619,30 +572,40 @@ static ttinfo* fetch_timezone_offset(timelib_tzinfo *tz, timelib_sll ts, timelib
* one in case there are only DST entries. Not sure which smartass came up
* with this idea in the first though :) */
if (ts < tz->trans[0]) {
return &(tz->type[0]);
uint32_t j;
*transition_time = 0;
j = 0;
while (j < tz->bit32.timecnt && tz->type[tz->trans_idx[j]].isdst) {
++j;
}
if (j == tz->bit32.timecnt) {
j = 0;
}
return &(tz->type[tz->trans_idx[j]]);
}
/* In all other cases we loop through the available transition times to find
* the correct entry */
for (i = 0; i < tz->bit64.timecnt; i++) {
for (i = 0; i < tz->bit32.timecnt; i++) {
if (ts < tz->trans[i]) {
*transition_time = tz->trans[i - 1];
return &(tz->type[tz->trans_idx[i - 1]]);
}
}
*transition_time = tz->trans[tz->bit64.timecnt - 1];
return &(tz->type[tz->trans_idx[tz->bit64.timecnt - 1]]);
*transition_time = tz->trans[tz->bit32.timecnt - 1];
return &(tz->type[tz->trans_idx[tz->bit32.timecnt - 1]]);
}
static tlinfo* fetch_leaptime_offset(timelib_tzinfo *tz, timelib_sll ts)
{
int i;
if (!tz->bit64.leapcnt || !tz->leap_times) {
if (!tz->bit32.leapcnt || !tz->leap_times) {
return NULL;
}
for (i = tz->bit64.leapcnt - 1; i > 0; i--) {
for (i = tz->bit32.leapcnt - 1; i > 0; i--) {
if (ts > tz->leap_times[i].trans) {
return &(tz->leap_times[i]);
}
+4 -4
View File
@@ -153,7 +153,7 @@ typedef struct _timelib_tzinfo
uint32_t timecnt;
uint32_t typecnt;
uint32_t charcnt;
} _bit32;
} bit32;
struct {
uint64_t ttisgmtcnt;
uint64_t ttisstdcnt;
@@ -163,7 +163,7 @@ typedef struct _timelib_tzinfo
uint64_t charcnt;
} bit64;
int64_t *trans;
int32_t *trans;
unsigned char *trans_idx;
ttinfo *type;
@@ -322,8 +322,8 @@ typedef struct _timelib_tzdb {
#endif
#define TIMELIB_VERSION 201801
#define TIMELIB_EXTENDED_VERSION 20180105
#define TIMELIB_ASCII_VERSION "2018.01RC3"
#define TIMELIB_EXTENDED_VERSION 20180103
#define TIMELIB_ASCII_VERSION "2018.01RC1"
#define TIMELIB_NONE 0x00
#define TIMELIB_OVERRIDE_TIME 0x01
+1 -1
View File
@@ -123,7 +123,7 @@ struct _ttinfo
struct _tlinfo
{
int64_t trans;
int32_t trans;
int32_t offset;
};
+30977 -30943
View File
File diff suppressed because it is too large. Load diff
+5 -5
View File
@@ -4032,7 +4032,7 @@ PHP_FUNCTION(timezone_transitions_get)
add_assoc_string(&element, "abbr", &tzobj->tzi.tz->timezone_abbr[tzobj->tzi.tz->type[tzobj->tzi.tz->trans_idx[i]].abbr_idx]); \
add_next_index_zval(return_value, &element);
#define add_last() add(tzobj->tzi.tz->bit64.timecnt - 1, timestamp_begin)
#define add_last() add(tzobj->tzi.tz->bit32.timecnt - 1, timestamp_begin)
array_init(return_value);
@@ -4043,7 +4043,7 @@ PHP_FUNCTION(timezone_transitions_get)
} else {
begin = 0;
found = 0;
if (tzobj->tzi.tz->bit64.timecnt > 0) {
if (tzobj->tzi.tz->bit32.timecnt > 0) {
do {
if (tzobj->tzi.tz->trans[begin] > timestamp_begin) {
if (begin > 0) {
@@ -4055,19 +4055,19 @@ PHP_FUNCTION(timezone_transitions_get)
break;
}
begin++;
} while (begin < tzobj->tzi.tz->bit64.timecnt);
} while (begin < tzobj->tzi.tz->bit32.timecnt);
}
}
if (!found) {
if (tzobj->tzi.tz->bit64.timecnt > 0) {
if (tzobj->tzi.tz->bit32.timecnt > 0) {
add_last();
} else {
add_nominal();
}
} else {
unsigned int i;
for (i = begin; i < tzobj->tzi.tz->bit64.timecnt; ++i) {
for (i = begin; i < tzobj->tzi.tz->bit32.timecnt; ++i) {
if (tzobj->tzi.tz->trans[i] < timestamp_end) {
add(i, tzobj->tzi.tz->trans[i]);
}
+6 -6
View File
@@ -95,11 +95,11 @@ print "wanted=Friday 00:00:00\n\n";
print "TZ=Pacific/Kwajalein - wrong day.\n";
date_default_timezone_set("Pacific/Kwajalein");
$tStamp = mktime (17, 17, 17, 1, 8627, 1970);
$tStamp = mktime (17, 17, 17, 1, 8626, 1970);
print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n";
$strtotime_tstamp = strtotime("next Saturday", $tStamp);
$strtotime_tstamp = strtotime("next Friday", $tStamp);
print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n";
print "wanted=Sunday 00:00:00\n\n";
print "wanted=Friday 00:00:00\n\n";
print "TZ=Asia/Ulan_Bator - wrong day.\n";
date_default_timezone_set("Asia/Ulan_Bator");
@@ -256,9 +256,9 @@ result=Friday 2003-04-04 00:00:00 EEST 1
wanted=Friday 00:00:00
TZ=Pacific/Kwajalein - wrong day.
tStamp=Saturday 1993-08-14 17:17:17 -12 0
result=Sunday 1993-08-22 00:00:00 +12 0
wanted=Sunday 00:00:00
tStamp=Friday 1993-08-13 17:17:17 -12 0
result=Saturday 1993-08-21 00:00:00 +12 0
wanted=Friday 00:00:00
TZ=Asia/Ulan_Bator - wrong day.
tStamp=Saturday 2001-09-22 17:17:17 +09 1
+6 -6
View File
@@ -132,11 +132,11 @@ print "wanted=Wednesday 00:15:00\n\n";
print "TZ=Pacific/Nauru - Is it OK for this to be 0:30? yes\n";
date_default_timezone_set('Pacific/Nauru');
$tStamp = mktime (17, 17, 17, 2, 3, 1979);
$tStamp = mktime (17, 17, 17, 1, 3401, 1970);
print "tStamp=". date("l Y-m-d H:i:s T I", $tStamp). "\n";
$strtotime_tstamp = strtotime("next Saturday +2 hours", $tStamp);
$strtotime_tstamp = strtotime("next Tuesday", $tStamp);
print "result=".date("l Y-m-d H:i:s T I", $strtotime_tstamp)."\n";
print "wanted=Saturday 02:30:00\n\n";
print "wanted=Tuesday 00:30:00\n\n";
print "TZ=Pacific/Niue - Is it OK for this to be 0:30 AM? yes\n";
date_default_timezone_set('Pacific/Niue');
@@ -292,9 +292,9 @@ result=Wednesday 1986-01-01 00:15:00 +0545 0
wanted=Wednesday 00:15:00
TZ=Pacific/Nauru - Is it OK for this to be 0:30? yes
tStamp=Saturday 1979-02-03 17:17:17 +1130 0
result=Saturday 1979-02-10 02:30:00 +12 0
wanted=Saturday 02:30:00
tStamp=Tuesday 1979-04-24 17:17:17 +1130 0
result=Tuesday 1979-05-01 00:30:00 +12 0
wanted=Tuesday 00:30:00
TZ=Pacific/Niue - Is it OK for this to be 0:30 AM? yes
tStamp=Sunday 1978-09-24 17:17:17 -1130 0
-33
View File
@@ -1,33 +0,0 @@
--TEST--
Bug #77097 (DateTime::diff gives wrong diff when the actual diff is less than 1 second)
--FILE--
<?php
$now = new DateTime('2018-11-03 11:34:20.781751');
$ago = new DateTime('2018-11-03 11:34:20.000000');
$diff = $now->diff($ago);
var_dump($diff->invert, $diff->s, $diff->f);
$diff = $ago->diff($now);
var_dump($diff->invert, $diff->s, $diff->f);
$diff = $now->diff($ago, true);
var_dump($diff->invert, $diff->s, $diff->f);
$diff = $ago->diff($now, true);
var_dump($diff->invert, $diff->s, $diff->f);
?>
--EXPECTF--
int(1)
int(0)
float(0.781751)
int(0)
int(0)
float(0.781751)
int(0)
int(0)
float(0.781751)
int(0)
int(0)
float(0.781751)
+3 -3
View File
@@ -3,7 +3,7 @@ date_modify() function [1]
--FILE--
<?php
date_default_timezone_set("Pacific/Kwajalein");
$ts = date_create("Fri Aug 20 1993 23:59:59");
$ts = date_create("Thu Aug 19 1993 23:59:59");
echo date_format($ts, 'D, d M Y H:i:s T'), "\n";
$ts->modify("+1 second");
echo date_format($ts, 'D, d M Y H:i:s T'), "\n";
@@ -20,8 +20,8 @@ $ts->modify("+ 1 hour 1 second");
echo date_format($ts, 'D, d M Y H:i:s T'), "\n";
?>
--EXPECT--
Fri, 20 Aug 1993 23:59:59 -12
Sun, 22 Aug 1993 00:00:00 +12
Thu, 19 Aug 1993 23:59:59 -12
Sat, 21 Aug 1993 00:00:00 +12
Sun, 27 Mar 2005 01:59:59 CET
Sun, 27 Mar 2005 03:00:00 CEST
Sun, 30 Oct 2005 01:59:59 CEST
+1 -1
View File
@@ -2415,7 +2415,7 @@ static void add_assoc_image_info(zval *value, int sub_array, image_info_type *im
break;
case TAG_FMT_URATIONAL:
snprintf(buffer, sizeof(buffer), "%u/%u", info_value->ur.num, info_value->ur.den);
snprintf(buffer, sizeof(buffer), "%i/%i", info_value->ur.num, info_value->ur.den);
if (l==1) {
add_assoc_string(&tmpi, name, buffer);
} else {
Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

-19
View File
@@ -1,19 +0,0 @@
--TEST--
Bug #74428 (Unsigned rational numbers are written out as signed rationals)
--SKIPIF--
<?php if (!extension_loaded('exif')) print 'skip exif extension not available';?>
--INI--
output_handler=
zlib.output_compression=0
--FILE--
<?php
$infile = dirname(__FILE__).'/DJI_0245_tiny.JPG';
$tags = exif_read_data($infile);
echo $tags['GPSLatitude'][2], PHP_EOL;
echo $tags['GPSLongitude'][2], PHP_EOL;
?>
===DONE===
--EXPECTF--
156691934/70000000
2672193571/70000000
===DONE===
+161767 -169185
View File
File diff suppressed because it is too large. Load diff
+2 -2
View File
@@ -3882,7 +3882,7 @@ diff -u libmagic.orig/readcdf.c libmagic/readcdf.c
if (NOTMIME(ms)) {
diff -u libmagic.orig/softmagic.c libmagic/softmagic.c
--- libmagic.orig/softmagic.c 2018-04-15 20:49:15.000000000 +0200
+++ libmagic/softmagic.c 2018-11-10 12:18:21.864916065 +0100
+++ libmagic/softmagic.c 2018-11-05 21:33:14.919371593 +0100
@@ -43,6 +43,10 @@
#include <time.h>
#include "der.h"
@@ -3944,7 +3944,7 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c
- if (rc) {
- file_regerror(&rx, rc, ms);
+ (void)setlocale(LC_CTYPE, "C");
+ pattern = zend_string_init("~%[-0-9\\.]*s~", sizeof("~%[-0-9\\.]*s~") - 1, 0);
+ pattern = zend_string_init("~%[-0-9.]*s~", sizeof("~%[-0-9.]*s~") - 1, 0);
+ if ((pce = pcre_get_compiled_regex(pattern, &capture_count, &re_options)) == NULL) {
+ rv = -1;
} else {
+1 -1
View File
@@ -431,7 +431,7 @@ check_fmt(struct magic_set *ms, const char *fmt)
return 0;
(void)setlocale(LC_CTYPE, "C");
pattern = zend_string_init("~%[-0-9\\.]*s~", sizeof("~%[-0-9\\.]*s~") - 1, 0);
pattern = zend_string_init("~%[-0-9.]*s~", sizeof("~%[-0-9.]*s~") - 1, 0);
if ((pce = pcre_get_compiled_regex(pattern, &capture_count, &re_options)) == NULL) {
rv = -1;
} else {
+124 -165
View File
@@ -1,122 +1,86 @@
diff -u a/magic/Magdir/c-lang b/magic/Magdir/c-lang
--- a/magic/Magdir/c-lang 2017-08-14 09:40:38.000000000 +0200
+++ b/magic/Magdir/c-lang 2018-11-10 13:06:33.171398452 +0100
@@ -13,61 +13,61 @@
# C
# Check for class if include is found, otherwise class is beaten by include becouse of lowered strength
0 regex \^#include C
->0 regex \^class[[:space:]]+
+>0 regex/4096 \^class[[:space:]]+
>>&0 regex \\{[\.\*]\\}(;)?$ \b++
>&0 clear x source text
!:strength + 13
!:mime text/x-c
-0 regex \^#[[:space:]]*pragma C source text
+0 regex/4096 \^#[[:space:]]*pragma C source text
!:mime text/x-c
-0 regex \^#[[:space:]]*(if\|ifn)def
->&0 regex \^#[[:space:]]*endif$ C source text
+0 regex/4096 \^#[[:space:]]*(if\|ifn)def
+>&0 regex/4096 \^#[[:space:]]*endif$ C source text
!:mime text/x-c
-0 regex \^#[[:space:]]*(if\|ifn)def
->&0 regex \^#[[:space:]]*define C source text
+0 regex/4096 \^#[[:space:]]*(if\|ifn)def
+>&0 regex/4096 \^#[[:space:]]*define C source text
!:mime text/x-c
-0 regex \^[[:space:]]*char(\ \\*|\\*)(.+)(=.*)?;[[:space:]]*$ C source text
+0 regex/4096 \^[[:space:]]*char(\ \\*|\\*)(.+)(=.*)?;[[:space:]]*$ C source text
!:mime text/x-c
-0 regex \^[[:space:]]*double(\ \\*|\\*)(.+)(=.*)?;[[:space:]]*$ C source text
+0 regex/4096 \^[[:space:]]*double(\ \\*|\\*)(.+)(=.*)?;[[:space:]]*$ C source text
!:mime text/x-c
-0 regex \^[[:space:]]*extern[[:space:]]+ C source text
+0 regex/4096 \^[[:space:]]*extern[[:space:]]+ C source text
!:mime text/x-c
-0 regex \^[[:space:]]*float(\ \\*|\\*)(.+)(=.*)?;[[:space:]]*$ C source text
+0 regex/4096 \^[[:space:]]*float(\ \\*|\\*)(.+)(=.*)?;[[:space:]]*$ C source text
!:mime text/x-c
-0 regex \^struct[[:space:]]+ C source text
+0 regex/4096 \^struct[[:space:]]+ C source text
!:mime text/x-c
-0 regex \^union[[:space:]]+ C source text
+0 regex/4096 \^union[[:space:]]+ C source text
!:mime text/x-c
0 search/8192 main(
->&0 regex \\)[[:space:]]*\\{ C source text
+>&0 regex/4096 \\)[[:space:]]*\\{ C source text
!:mime text/x-c
diff -u Magdir.orig/cafebabe Magdir/cafebabe
--- Magdir.orig/cafebabe 2017-05-25 22:07:23.000000000 +0200
+++ Magdir/cafebabe 2018-04-28 12:26:00.840857162 +0200
@@ -15,22 +15,6 @@
# might add another one or two as time goes by...
#
### JAVA START ###
-0 belong 0xcafebabe
->4 belong >30 compiled Java class data,
-!:mime application/x-java-applet
->>6 beshort x version %d.
->>4 beshort x \b%d
-# Which is which?
-#>>4 belong 0x032d (Java 1.0)
-#>>4 belong 0x032d (Java 1.1)
->>4 belong 0x002e (Java 1.2)
->>4 belong 0x002f (Java 1.3)
->>4 belong 0x0030 (Java 1.4)
->>4 belong 0x0031 (Java 1.5)
->>4 belong 0x0032 (Java 1.6)
->>4 belong 0x0033 (Java 1.7)
->>4 belong 0x0034 (Java 1.8)
-
0 belong 0xcafed00d JAR compressed with pack200,
>5 byte x version %d.
>4 byte x \b%d
@@ -52,15 +36,28 @@
# C++
# The strength of these rules is increased so they beat the C rules above
-0 regex \^namespace[[:space:]]+[_[:alpha:]]{1,30}[[:space:]]*\\{ C++ source text
+0 regex/4096 \^namespace[[:space:]]+[_[:alpha:]]{1,30}[[:space:]]*\\{ C++ source text
!:strength + 30
!:mime text/x-c++
# using namespace [namespace] or using std::[lib]
-0 regex \^using[[:space:]]+(namespace\ )?std(::)?[[:alpha:]]*[[:space:]]*; C++ source text
+0 regex/4096 \^using[[:space:]]+(namespace\ )?std(::)?[[:alpha:]]*[[:space:]]*; C++ source text
!:strength + 30
!:mime text/x-c++
-0 regex \^[[:space:]]*template[[:space:]]*<.*>[[:space:]]*$ C++ source text
+0 regex/4096 \^[[:space:]]*template[[:space:]]*<.*>[[:space:]]*$ C++ source text
!:strength + 30
!:mime text/x-c++
-0 regex \^[[:space:]]*virtual[[:space:]]+.*[};][[:space:]]*$ C++ source text
+0 regex/4096 \^[[:space:]]*virtual[[:space:]]+.*[};][[:space:]]*$ C++ source text
!:strength + 30
!:mime text/x-c++
# But class alone is reduced to avoid beating php (Jens Schleusener)
-0 regex \^[[:space:]]*class[[:space:]]+[[:digit:][:alpha:]:_]+[[:space:]]*\\{(.*[\n]*)*\\}(;)?$ C++ source text
+0 regex/4096 \^[[:space:]]*class[[:space:]]+[[:digit:][:alpha:]:_]+[[:space:]]*\\{(.*[\n]*)*\\}(;)?$ C++ source text
!:strength + 13
!:mime text/x-c++
-0 regex \^[[:space:]]*public: C++ source text
+0 regex/4096 \^[[:space:]]*public: C++ source text
!:strength + 30
!:mime text/x-c++
-0 regex \^[[:space:]]*private: C++ source text
+0 regex/4096 \^[[:space:]]*private: C++ source text
!:strength + 30
!:mime text/x-c++
-0 regex \^[[:space:]]*protected: C++ source text
+0 regex/4096 \^[[:space:]]*protected: C++ source text
!:strength + 30
!:mime text/x-c++
diff -u a/magic/Magdir/python b/magic/Magdir/python
--- a/magic/Magdir/python 2017-08-14 09:40:38.000000000 +0200
+++ b/magic/Magdir/python 2018-11-10 13:06:36.799268528 +0100
@@ -63,7 +63,7 @@
!:mime text/x-python
# import module [as abrev]
-0 regex \^import\ [_[:alpha:]]+\ as\ [[:alpha:]][[:space:]]*$ Python script text executable
+0 regex/4096 \^import\ [_[:alpha:]]+\ as\ [[:alpha:]][[:space:]]*$ Python script text executable
!:mime text/x-python
# comments
@@ -79,7 +79,7 @@
# except: or finally:
# block
0 search/4096 try:
->&0 regex \^[[:space:]]*except.*:$ Python script text executable
+>&0 regex/4096 \^[[:space:]]*except.*:$ Python script text executable
!:strength + 15
!:mime text/x-python
>&0 search/4096 finally: Python script text executable
@@ -91,7 +91,7 @@
!:mime text/x-python
# def name(*args, **kwargs):
-0 regex \^[[:space:]]{0,50}def\ {1,50}[_a-zA-Z]{1,100}
+0 regex/4096 \^[[:space:]]{0,50}def\ {1,50}[_a-zA-Z]{1,100}
>&0 regex \\(([[:alpha:]*_,\ ]){0,255}\\):$ Python script text executable
!:strength + 15
!:mime text/x-python
diff -u a/magic/Magdir/rpm b/magic/Magdir/rpm
--- a/magic/Magdir/rpm 2013-01-11 17:45:23.000000000 +0100
+++ b/magic/Magdir/rpm 2018-11-10 12:27:29.858619326 +0100
0 belong 0xcafebabe
>4 belong 1 Mach-O universal binary with 1 architecture:
-!:mime application/x-mach-binary
>>8 use mach-o \b
+0 belong 0xcafebabe
+>4 belong >30 compiled Java class data,
+!:mime application/x-java-applet
+>>6 beshort x version %d.
+>>4 beshort x \b%d
+# Which is which?
+#>>4 belong 0x032d (Java 1.0)
+#>>4 belong 0x032d (Java 1.1)
+>>4 belong 0x002e (Java 1.2)
+>>4 belong 0x002f (Java 1.3)
+>>4 belong 0x0030 (Java 1.4)
+>>4 belong 0x0031 (Java 1.5)
+>>4 belong 0x0032 (Java 1.6)
+>>4 belong 0x0033 (Java 1.7)
+>>4 belong 0x0034 (Java 1.8)
>4 belong >1
>>4 belong <20 Mach-O universal binary with %d architectures:
-!:mime application/x-mach-binary
>>>8 use mach-o \b
->>4 belong 2
+>>4 belong >2
>>>28 use mach-o \b
->>4 belong 3
+>>4 belong >3
>>>48 use mach-o \b
>>4 belong 4
>>>68 use mach-o \b
diff -u Magdir.orig/filesystems Magdir/filesystems
--- Magdir.orig/filesystems 2018-03-11 01:46:42.000000000 +0100
+++ Magdir/filesystems 2018-04-28 12:26:11.080817126 +0200
@@ -254,7 +254,7 @@
30 search/481 \x55\xAA
# to display DOS/MBR boot sector (40) before old one (strength=50+21),Syslinux bootloader (71),SYSLINUX MBR (37+36),NetBSD mbr (110),AdvanceMAME mbr (111)
# DOS BPB information (70) and after DOS floppy (120) like in previous file version
-!:strength +65
+!:strength +0
# for sector sizes < 512 Bytes
>11 uleshort <512
>>(11.s-2) uleshort 0xAA55 DOS/MBR boot sector
@@ -266,7 +266,7 @@
0x1FE leshort 0xAA55 DOS/MBR boot sector
#
# to display information (50) before DOS BPB (strength=70) and after DOS floppy (120) like in old file version
-!:strength +65
+!:strength +0
>2 string OSBS OS/BS MBR
# added by Joerg Jenderek at Feb 2013 according to http://thestarman.pcministry.com/asm/mbr/
# and http://en.wikipedia.org/wiki/Master_Boot_Record
diff -u Magdir.orig/rpm Magdir/rpm
--- Magdir.orig/rpm 2013-01-11 17:45:23.000000000 +0100
+++ Magdir/rpm 2018-04-28 12:26:14.072805431 +0200
@@ -29,6 +29,7 @@
>>8 beshort 17 SuperH
>>8 beshort 18 Xtensa
@@ -125,56 +89,51 @@ diff -u a/magic/Magdir/rpm b/magic/Magdir/rpm
#delta RPM Daniel Novotny (dnovotny@redhat.com)
0 string drpm Delta RPM
diff -u a/magic/Magdir/ruby b/magic/Magdir/ruby
--- a/magic/Magdir/ruby 2017-08-14 15:39:18.000000000 +0200
+++ b/magic/Magdir/ruby 2018-11-10 13:06:28.703557761 +0100
@@ -22,30 +22,30 @@
# What looks like ruby, but does not have a shebang
# (modules and such)
# From: Lubomir Rintel <lkundrak@v3.sk>
-0 regex \^[[:space:]]*require[[:space:]]'[A-Za-z_/]+'
+0 regex/4096 \^[[:space:]]*require[[:space:]]'[A-Za-z_/]+'
>0 regex def\ [a-z]|\ do$
->>&0 regex \^[[:space:]]*end([[:space:]]+[;#].*)?$ Ruby script text
+>>&0 regex/4096 \^[[:space:]]*end([[:space:]]+[;#].*)?$ Ruby script text
!:strength + 30
!:mime text/x-ruby
-0 regex \^[[:space:]]*(class|module)[[:space:]][A-Z]
+0 regex/4096 \^[[:space:]]*(class|module)[[:space:]][A-Z]
>0 regex (modul|includ)e\ [A-Z]|def\ [a-z]
->>&0 regex \^[[:space:]]*end([[:space:]]+[;#].*)?$ Ruby script text
+>>&0 regex/4096 \^[[:space:]]*end([[:space:]]+[;#].*)?$ Ruby script text
!:strength + 30
!:mime text/x-ruby
# Classes with no modules or defs, beats simple ASCII
-0 regex \^[[:space:]]*(class|module)[[:space:]][A-Z]
->&0 regex \^[[:space:]]*end([[:space:]]+[;#if].*)?$ Ruby script text
+0 regex/4096 \^[[:space:]]*(class|module)[[:space:]][A-Z]
+>&0 regex/4096 \^[[:space:]]*end([[:space:]]+[;#if].*)?$ Ruby script text
!:strength + 10
!:mime text/x-ruby
# Looks for function definition to balance python magic
# def name (args)
# end
-0 regex \^[[:space:]]*def\ [a-z]|def\ [[:alpha:]]+::[a-z]
->&0 regex \^[[:space:]]*end([[:space:]]+[;#].*)?$ Ruby script text
+0 regex/4096 \^[[:space:]]*def\ [a-z]|def\ [[:alpha:]]+::[a-z]
+>&0 regex/4096 \^[[:space:]]*end([[:space:]]+[;#].*)?$ Ruby script text
!:strength + 10
!:mime text/x-ruby
-0 regex \^[[:space:]]*require[[:space:]]'[A-Za-z_/]+' Ruby script text
+0 regex/4096 \^[[:space:]]*require[[:space:]]'[A-Za-z_/]+' Ruby script text
!:mime text/x-ruby
-0 regex \^[[:space:]]*include\ ([A-Z]+[a-z]*(::))+ Ruby script text
+0 regex/4096 \^[[:space:]]*include\ ([A-Z]+[a-z]*(::))+ Ruby script text
!:mime text/x-ruby
diff -u a/magic/Magdir/securitycerts b/magic/Magdir/securitycerts
--- a/magic/Magdir/securitycerts 2009-09-19 18:28:12.000000000 +0200
+++ b/magic/Magdir/securitycerts 2018-11-10 12:27:29.858619326 +0100
diff -u Magdir.orig/securitycerts Magdir/securitycerts
--- Magdir.orig/securitycerts 2009-09-19 18:28:12.000000000 +0200
+++ Magdir/securitycerts 2018-04-28 12:26:14.072805431 +0200
@@ -4,3 +4,5 @@
0 search/1 -----BEGIN\ CERTIFICATE------ RFC1421 Security Certificate text
0 search/1 -----BEGIN\ NEW\ CERTIFICATE RFC1421 Security Certificate Signing Request text
0 belong 0xedfeedfe Sun 'jks' Java Keystore File data
+
+0 string \0volume_key volume_key escrow packet
diff -u Magdir.orig/varied.script Magdir/varied.script
--- Magdir.orig/varied.script 2015-03-27 18:59:39.000000000 +0100
+++ Magdir/varied.script 2018-04-28 12:26:14.072805431 +0200
@@ -4,27 +4,35 @@
0 string/t #!\ / a
>3 string >\0 %s script text executable
+!:strength / 10
0 string/b #!\ / a
>3 string >\0 %s script executable (binary data)
+!:strength / 10
0 string/t #!\t/ a
>3 string >\0 %s script text executable
+!:strength / 10
0 string/b #!\t/ a
>3 string >\0 %s script executable (binary data)
+!:strength / 10
0 string/t #!/ a
>2 string >\0 %s script text executable
+!:strength / 10
0 string/b #!/ a
>2 string >\0 %s script executable (binary data)
+!:strength / 10
0 string/t #!\ script text executable
>3 string >\0 for %s
+!:strength / 10
0 string/b #!\ script executable
>3 string >\0 for %s (binary data)
+!:strength / 10
# using env
0 string/t #!/usr/bin/env a
@@ -1,40 +0,0 @@
--TEST--
Bug #66731: file: extensive backtraking, with pcre.jit=0
--SKIPIF--
<?php
if (defined("PHP_DEBUG") && PHP_DEBUG)
die("skip not suitable for debug build");
if (!class_exists('finfo'))
die('skip no fileinfo extension');
?>
--INI--
pcre.jit=0
--FILE--
<?php
$fd = __DIR__.'/cve-2014-3538.data';
file_put_contents($fd,
'try:' .
str_repeat("\n", 1000000));
$fi = finfo_open(FILEINFO_NONE);
$t = microtime(true);
var_dump(finfo_file($fi, $fd));
$t = microtime(true) - $t;
finfo_close($fi);
if ($t < 1) {
echo "Ok\n";
} else {
printf("Failed, time=%.2f\n", $t);
}
?>
Done
--CLEAN--
<?php
@unlink(__DIR__.'/cve-2014-3538.data');
?>
--EXPECTF--
string(%d) "%s"
Ok
Done
+1 -3
View File
@@ -18,7 +18,7 @@ ksort($results);
var_dump($results);
?>
--EXPECTF--
array(%d) {
array(9) {
["%s/resources/dir.zip"]=>
string(15) "application/zip"
["%s/resources/test.awk"]=>
@@ -37,6 +37,4 @@ array(%d) {
string(9) "image/png"
["%s/resources/test.ppt"]=>
string(29) "application/vnd.ms-powerpoint"
["%s/resources/test.webm"]=>
string(10) "video/webm"
}
+151 -856
View File
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
Binary file not shown.
+6 -8
View File
@@ -1906,10 +1906,10 @@ static void ftp_ssl_shutdown(ftpbuf_t *ftp, php_socket_t fd, SSL *ssl_handle) {
done = 0;
}
while (!done && data_available(ftp, fd)) {
ERR_clear_error();
nread = SSL_read(ssl_handle, buf, sizeof(buf));
if (nread <= 0) {
while (!done) {
if (data_available(ftp, fd)) {
ERR_clear_error();
nread = SSL_read(ssl_handle, buf, sizeof(buf));
err = SSL_get_error(ssl_handle, nread);
switch (err) {
case SSL_ERROR_NONE: /* this is not an error */
@@ -1927,11 +1927,9 @@ static void ftp_ssl_shutdown(ftpbuf_t *ftp, php_socket_t fd, SSL *ssl_handle) {
break;
default:
if ((sslerror = ERR_get_error())) {
ERR_error_string_n(sslerror, buf, sizeof(buf));
php_error_docref(NULL, E_WARNING, "SSL_read on shutdown: %s", buf);
} else if (errno) {
php_error_docref(NULL, E_WARNING, "SSL_read on shutdown: %s (%d)", strerror(errno), errno);
ERR_error_string_n(sslerror, buf, sizeof(buf));
}
php_error_docref(NULL, E_WARNING, "SSL_read on shutdown: %s (%d)", (sslerror ? buf : strerror(errno)), errno);
done = 1;
break;
}
+5 -23
View File
@@ -1593,7 +1593,7 @@ void gdImageFilledArc (gdImagePtr im, int cx, int cy, int w, int h, int s, int e
int i, pti;
int lx = 0, ly = 0;
int fx = 0, fy = 0;
int startx, starty, endx, endy;
if ((s % 360) == (e % 360)) {
s = 0; e = 360;
@@ -1620,8 +1620,8 @@ void gdImageFilledArc (gdImagePtr im, int cx, int cy, int w, int h, int s, int e
for (i = s, pti = 1; i <= e; i++, pti++) {
int x, y;
x = endx = ((long) gdCosT[i % 360] * (long) w / (2 * 1024)) + cx;
y = endy = ((long) gdSinT[i % 360] * (long) h / (2 * 1024)) + cy;
x = ((long) gdCosT[i % 360] * (long) w / (2 * 1024)) + cx;
y = ((long) gdSinT[i % 360] * (long) h / (2 * 1024)) + cy;
if (i != s) {
if (!(style & gdChord)) {
if (style & gdNoFill) {
@@ -1646,8 +1646,8 @@ void gdImageFilledArc (gdImagePtr im, int cx, int cy, int w, int h, int s, int e
if (!(style & (gdChord | gdNoFill))) {
pts[0].x = cx;
pts[0].y = cy;
pts[pti].x = startx = x;
pts[pti].y = starty = y;
pts[pti].x = x;
pts[pti].y = y;
}
}
lx = x;
@@ -1676,24 +1676,6 @@ void gdImageFilledArc (gdImagePtr im, int cx, int cy, int w, int h, int s, int e
gdImageLine(im, cx, cy, fx, fy, color);
}
} else {
if (e - s < 360) {
if (pts[1].x != startx && pts[1].y == starty) {
/* start point has been removed due to y-coord fix => insert it */
for (i = pti; i > 1; i--) {
pts[i].x = pts[i-1].x;
pts[i].y = pts[i-1].y;
}
pts[1].x = startx;
pts[1].y = starty;
pti++;
}
if (pts[pti-1].x != endx && pts[pti-1].y == endy) {
/* end point has been removed due to y-coord fix => insert it */
pts[pti].x = endx;
pts[pti].y = endy;
pti++;
}
}
pts[pti].x = cx;
pts[pti].y = cy;
gdImageFilledPolygon(im, pts, pti+1, color);
+2 -2
View File
@@ -813,8 +813,8 @@ static int bmp_read_1bit(gdImagePtr im, gdIOCtxPtr infile, bmp_info_t *info, bmp
}
}
/* The line must be aligned on a 32 bits word, else it is padded with zeros */
padding = (info->width + 7) / 8 % 4;
/* The line must be divisible by 4, else its padded with NULLs */
padding = ((int)ceil(0.1 * info->width)) % 4;
if (padding) {
padding = 4 - padding;
}
+2 -2
View File
@@ -33,8 +33,8 @@ int gdImageColorMatch (gdImagePtr im1, gdImagePtr im2)
return -4; /* At least 1 color must be allocated */
}
buf = (unsigned long *)safe_emalloc(sizeof(unsigned long), 5 * gdMaxColors, 0);
memset( buf, 0, sizeof(unsigned long) * 5 * gdMaxColors );
buf = (unsigned long *)safe_emalloc(sizeof(unsigned long), 5 * im2->colorsTotal, 0);
memset( buf, 0, sizeof(unsigned long) * 5 * im2->colorsTotal );
for (x=0; x<im1->sx; x++) {
for( y=0; y<im1->sy; y++ ) {
+29 -17
View File
@@ -127,24 +127,30 @@ gdImagePtr gdImageCropAuto(gdImagePtr im, const unsigned int mode)
}
}
/* Whole image would be cropped > bye */
if (match) {
/* Nothing to do > bye
* Duplicate the image?
*/
if (y == height - 1) {
return NULL;
}
crop.y = y - 1;
crop.y = y -1;
match = 1;
for (y = height - 1; match && y >= 0; y--) {
for (x = 0; match && x < width; x++) {
match = (color == gdImageGetPixel(im, x,y));
}
}
crop.height = y - crop.y + 2;
if (y == 0) {
crop.height = height - crop.y + 1;
} else {
crop.height = y - crop.y + 2;
}
match = 1;
for (x = 0; match && x < width; x++) {
for (y = 0; match && y < crop.y + crop.height; y++) {
for (y = 0; match && y < crop.y + crop.height - 1; y++) {
match = (color == gdImageGetPixel(im, x,y));
}
}
@@ -152,13 +158,12 @@ gdImagePtr gdImageCropAuto(gdImagePtr im, const unsigned int mode)
match = 1;
for (x = width - 1; match && x >= 0; x--) {
for (y = 0; match && y < crop.y + crop.height; y++) {
for (y = 0; match && y < crop.y + crop.height - 1; y++) {
match = (color == gdImageGetPixel(im, x,y));
}
}
crop.width = x - crop.x + 2;
if (crop.x < 0 || crop.y < 0 || crop.width <= 0 || crop.height <= 0) {
if (crop.x <= 0 || crop.y <= 0 || crop.width <= 0 || crop.height <= 0) {
return NULL;
}
return gdImageCrop(im, &crop);
@@ -217,24 +222,31 @@ gdImagePtr gdImageCropThreshold(gdImagePtr im, const unsigned int color, const f
}
}
/* Whole image would be cropped > bye */
if (match) {
/* Pierre
* Nothing to do > bye
* Duplicate the image?
*/
if (y == height - 1) {
return NULL;
}
crop.y = y - 1;
crop.y = y -1;
match = 1;
for (y = height - 1; match && y >= 0; y--) {
for (x = 0; match && x < width; x++) {
match = (gdColorMatch(im, color, gdImageGetPixel(im, x, y), threshold)) > 0;
}
}
crop.height = y - crop.y + 2;
if (y == 0) {
crop.height = height - crop.y + 1;
} else {
crop.height = y - crop.y + 2;
}
match = 1;
for (x = 0; match && x < width; x++) {
for (y = 0; match && y < crop.y + crop.height; y++) {
for (y = 0; match && y < crop.y + crop.height - 1; y++) {
match = (gdColorMatch(im, color, gdImageGetPixel(im, x,y), threshold)) > 0;
}
}
@@ -242,7 +254,7 @@ gdImagePtr gdImageCropThreshold(gdImagePtr im, const unsigned int color, const f
match = 1;
for (x = width - 1; match && x >= 0; x--) {
for (y = 0; match && y < crop.y + crop.height; y++) {
for (y = 0; match && y < crop.y + crop.height - 1; y++) {
match = (gdColorMatch(im, color, gdImageGetPixel(im, x,y), threshold)) > 0;
}
}
@@ -279,7 +291,7 @@ static int gdGuessBackgroundColorFromCorners(gdImagePtr im, int *color)
} else if (tl == tr || tl == bl || tl == br) {
*color = tl;
return 2;
} else if (tr == bl || tr == br) {
} else if (tr == bl) {
*color = tr;
return 2;
} else if (br == bl) {
+117 -37
View File
@@ -662,7 +662,43 @@ static inline int getPixelOverflowTC(gdImagePtr im, const int x, const int y, co
}
return c;
} else {
return bgColor;
register int border = 0;
if (y < im->cy1) {
border = im->tpixels[0][im->cx1];
goto processborder;
}
if (y < im->cy1) {
border = im->tpixels[0][im->cx1];
goto processborder;
}
if (y > im->cy2) {
if (x >= im->cx1 && x <= im->cx1) {
border = im->tpixels[im->cy2][x];
goto processborder;
} else {
return gdTrueColorAlpha(0, 0, 0, 127);
}
}
/* y is bound safe at this point */
if (x < im->cx1) {
border = im->tpixels[y][im->cx1];
goto processborder;
}
if (x > im->cx2) {
border = im->tpixels[y][im->cx2];
}
processborder:
if (border == im->transparent) {
return gdTrueColorAlpha(0, 0, 0, 127);
} else{
return gdTrueColorAlpha(gdTrueColorGetRed(border), gdTrueColorGetGreen(border), gdTrueColorGetBlue(border), 127);
}
}
}
@@ -677,7 +713,42 @@ static inline int getPixelOverflowPalette(gdImagePtr im, const int x, const int
}
return colorIndex2RGBA(c);
} else {
return bgColor;
register int border = 0;
if (y < im->cy1) {
border = gdImageGetPixel(im, im->cx1, 0);
goto processborder;
}
if (y < im->cy1) {
border = gdImageGetPixel(im, im->cx1, 0);
goto processborder;
}
if (y > im->cy2) {
if (x >= im->cx1 && x <= im->cx1) {
border = gdImageGetPixel(im, x, im->cy2);
goto processborder;
} else {
return gdTrueColorAlpha(0, 0, 0, 127);
}
}
/* y is bound safe at this point */
if (x < im->cx1) {
border = gdImageGetPixel(im, im->cx1, y);
goto processborder;
}
if (x > im->cx2) {
border = gdImageGetPixel(im, im->cx2, y);
}
processborder:
if (border == im->transparent) {
return gdTrueColorAlpha(0, 0, 0, 127);
} else{
return colorIndex2RGBcustomA(border, 127);
}
}
}
@@ -819,13 +890,8 @@ static inline LineContribType * _gdContributionsAlloc(unsigned int line_length,
{
unsigned int u = 0;
LineContribType *res;
size_t weights_size;
int overflow_error = 0;
if (overflow2(windows_size, sizeof(double))) {
return NULL;
} else {
weights_size = windows_size * sizeof(double);
}
res = (LineContribType *) gdMalloc(sizeof(LineContribType));
if (!res) {
return NULL;
@@ -842,10 +908,15 @@ static inline LineContribType * _gdContributionsAlloc(unsigned int line_length,
return NULL;
}
for (u = 0 ; u < line_length ; u++) {
res->ContribRow[u].Weights = (double *) gdMalloc(weights_size);
if (res->ContribRow[u].Weights == NULL) {
if (overflow2(windows_size, sizeof(double))) {
overflow_error = 1;
} else {
res->ContribRow[u].Weights = (double *) gdMalloc(windows_size * sizeof(double));
}
if (overflow_error == 1 || res->ContribRow[u].Weights == NULL) {
unsigned int i;
for (i=0;i<u;i++) {
u--;
for (i=0;i<=u;i++) {
gdFree(res->ContribRow[i].Weights);
}
gdFree(res->ContribRow);
@@ -949,7 +1020,7 @@ static inline void _gdScaleRow(gdImagePtr pSrc, unsigned int src_width, gdImage
}
}
static inline int _gdScaleHoriz(gdImagePtr pSrc, unsigned int src_width, unsigned int src_height, gdImagePtr pDst, unsigned int dst_width, unsigned int dst_height)
static inline void _gdScaleHoriz(gdImagePtr pSrc, unsigned int src_width, unsigned int src_height, gdImagePtr pDst, unsigned int dst_width, unsigned int dst_height)
{
unsigned int u;
LineContribType * contrib;
@@ -964,14 +1035,13 @@ static inline int _gdScaleHoriz(gdImagePtr pSrc, unsigned int src_width, unsigne
contrib = _gdContributionsCalc(dst_width, src_width, (double)dst_width / (double)src_width, pSrc->interpolation);
if (contrib == NULL) {
return 0;
return;
}
/* Scale each row */
for (u = 0; u < dst_height - 1; u++) {
_gdScaleRow(pSrc, src_width, pDst, dst_width, u, contrib);
}
_gdContributionsFree (contrib);
return 1;
}
static inline void _gdScaleCol (gdImagePtr pSrc, unsigned int src_width, gdImagePtr pRes, unsigned int dst_width, unsigned int dst_height, unsigned int uCol, LineContribType *contrib)
@@ -996,7 +1066,7 @@ static inline void _gdScaleCol (gdImagePtr pSrc, unsigned int src_width, gdImag
}
}
static inline int _gdScaleVert (const gdImagePtr pSrc, const unsigned int src_width, const unsigned int src_height, const gdImagePtr pDst, const unsigned int dst_width, const unsigned int dst_height)
static inline void _gdScaleVert (const gdImagePtr pSrc, const unsigned int src_width, const unsigned int src_height, const gdImagePtr pDst, const unsigned int dst_width, const unsigned int dst_height)
{
unsigned int u;
LineContribType * contrib;
@@ -1011,21 +1081,19 @@ static inline int _gdScaleVert (const gdImagePtr pSrc, const unsigned int src_wi
contrib = _gdContributionsCalc(dst_height, src_height, (double)(dst_height) / (double)(src_height), pSrc->interpolation);
if (contrib == NULL) {
return 0;
return;
}
/* scale each column */
for (u = 0; u < dst_width - 1; u++) {
_gdScaleCol(pSrc, src_width, pDst, dst_width, dst_height, u, contrib);
}
_gdContributionsFree(contrib);
return 1;
}
gdImagePtr gdImageScaleTwoPass(const gdImagePtr src, const unsigned int src_width, const unsigned int src_height, const unsigned int new_width, const unsigned int new_height)
{
gdImagePtr tmp_im;
gdImagePtr dst;
int scale_pass_res;
if (new_width == 0 || new_height == 0) {
return NULL;
@@ -1041,11 +1109,7 @@ gdImagePtr gdImageScaleTwoPass(const gdImagePtr src, const unsigned int src_widt
return NULL;
}
gdImageSetInterpolationMethod(tmp_im, src->interpolation_id);
scale_pass_res = _gdScaleHoriz(src, src_width, src_height, tmp_im, new_width, src_height);
if (scale_pass_res != 1) {
gdImageDestroy(tmp_im);
return NULL;
}
_gdScaleHoriz(src, src_width, src_height, tmp_im, new_width, src_height);
dst = gdImageCreateTrueColor(new_width, new_height);
if (dst == NULL) {
@@ -1053,17 +1117,33 @@ gdImagePtr gdImageScaleTwoPass(const gdImagePtr src, const unsigned int src_widt
return NULL;
}
gdImageSetInterpolationMethod(dst, src->interpolation_id);
scale_pass_res = _gdScaleVert(tmp_im, new_width, src_height, dst, new_width, new_height);
if (scale_pass_res != 1) {
gdImageDestroy(dst);
gdImageDestroy(tmp_im);
return NULL;
}
_gdScaleVert(tmp_im, new_width, src_height, dst, new_width, new_height);
gdImageDestroy(tmp_im);
return dst;
}
gdImagePtr Scale(const gdImagePtr src, const unsigned int src_width, const unsigned int src_height, const gdImagePtr dst, const unsigned int new_width, const unsigned int new_height)
{
gdImagePtr tmp_im;
if (new_width == 0 || new_height == 0) {
return NULL;
}
tmp_im = gdImageCreateTrueColor(new_width, src_height);
if (tmp_im == NULL) {
return NULL;
}
gdImageSetInterpolationMethod(tmp_im, src->interpolation_id);
_gdScaleHoriz(src, src_width, src_height, tmp_im, new_width, src_height);
_gdScaleVert(tmp_im, new_width, src_height, dst, new_width, new_height);
gdImageDestroy(tmp_im);
return dst;
}
/*
BilinearFixed, BicubicFixed and nearest implementations are rewamped versions of the implementation in CBitmapEx
http://www.codeproject.com/Articles/29121/CBitmapEx-Free-C-Bitmap-Manipulation-Class
@@ -1235,11 +1315,11 @@ static gdImagePtr gdImageScaleBilinearPalette(gdImagePtr im, const unsigned int
f_b1, f_b2, f_b3, f_b4,
f_a1, f_a2, f_a3, f_a4;
/* 0 for bgColor; (n,m) is supposed to be valid anyway */
/* zero for the background color, nothig gets outside anyway */
pixel1 = getPixelOverflowPalette(im, n, m, 0);
pixel2 = getPixelOverflowPalette(im, n + 1, m, pixel1);
pixel3 = getPixelOverflowPalette(im, n, m + 1, pixel1);
pixel4 = getPixelOverflowPalette(im, n + 1, m + 1, pixel1);
pixel2 = getPixelOverflowPalette(im, n + 1, m, 0);
pixel3 = getPixelOverflowPalette(im, n, m + 1, 0);
pixel4 = getPixelOverflowPalette(im, n + 1, m + 1, 0);
f_r1 = gd_itofx(gdTrueColorGetRed(pixel1));
f_r2 = gd_itofx(gdTrueColorGetRed(pixel2));
@@ -1327,11 +1407,11 @@ static gdImagePtr gdImageScaleBilinearTC(gdImagePtr im, const unsigned int new_w
f_b1, f_b2, f_b3, f_b4,
f_a1, f_a2, f_a3, f_a4;
dwSrcTotalOffset = m + n;
/* 0 for bgColor; (n,m) is supposed to be valid anyway */
/* 0 for bgColor, nothing gets outside anyway */
pixel1 = getPixelOverflowTC(im, n, m, 0);
pixel2 = getPixelOverflowTC(im, n + 1, m, pixel1);
pixel3 = getPixelOverflowTC(im, n, m + 1, pixel1);
pixel4 = getPixelOverflowTC(im, n + 1, m + 1, pixel1);
pixel2 = getPixelOverflowTC(im, n + 1, m, 0);
pixel3 = getPixelOverflowTC(im, n, m + 1, 0);
pixel4 = getPixelOverflowTC(im, n + 1, m + 1, 0);
f_r1 = gd_itofx(gdTrueColorGetRed(pixel1));
f_r2 = gd_itofx(gdTrueColorGetRed(pixel2));
+4 -9
View File
@@ -67,18 +67,14 @@ static long php_jpeg_emit_message(j_common_ptr jpeg_info, int level)
* unless strace_level >= 3
*/
if ((jpeg_info->err->num_warnings == 0) || (jpeg_info->err->trace_level >= 3)) {
if (!ignore_warning) {
gd_error("gd-jpeg, libjpeg: recoverable error: %s\n", message);
}
gd_error_ex(ignore_warning ? GD_NOTICE : GD_WARNING, "gd-jpeg, libjpeg: recoverable error: %s\n", message);
}
jpeg_info->err->num_warnings++;
} else {
/* strace msg, Show it if trace_level >= level. */
if (jpeg_info->err->trace_level >= level) {
if (!ignore_warning) {
gd_error("gd-jpeg, libjpeg: strace message: %s\n", message);
}
gd_error_ex(GD_NOTICE, "gd-jpeg, libjpeg: strace message: %s\n", message);
}
}
return 1;
@@ -90,10 +86,9 @@ static long php_jpeg_emit_message(j_common_ptr jpeg_info, int level)
static void fatal_jpeg_error (j_common_ptr cinfo)
{
jmpbuf_wrapper *jmpbufw;
char buffer[JMSG_LENGTH_MAX];
(*cinfo->err->format_message)(cinfo, buffer);
gd_error_ex(GD_WARNING, "gd-jpeg: JPEG library reports unrecoverable error: %s", buffer);
gd_error("gd-jpeg: JPEG library reports unrecoverable error: ");
(*cinfo->err->output_message) (cinfo);
jmpbufw = (jmpbuf_wrapper *) cinfo->client_data;
jpeg_destroy (cinfo);
-1
View File
@@ -100,7 +100,6 @@ void gdImageWBMPCtx (gdImagePtr image, int fg, gdIOCtx * out)
/* create the WBMP */
if ((wbmp = createwbmp (gdImageSX (image), gdImageSY (image), WBMP_WHITE)) == NULL) {
gd_error("Could not create WBMP");
return;
}
/* fill up the WBMP structure */
-45
View File
@@ -1,45 +0,0 @@
--TEST--
Bug #73281 (imagescale(…, IMG_BILINEAR_FIXED) can cause black border)
--SKIPIF--
<?php
if (!extension_loaded('gd')) die('skip gd extension not available');
if (!GD_BUNDLED && version_compare(GD_VERSION, '2.2.3', '<=')) die('skip upstream fix not yet released');
?>
--FILE--
<?php
$coordinates = [[0, 0], [0, 199], [199, 199], [199, 0]];
$src = imagecreatetruecolor(100, 100);
$white = imagecolorallocate($src, 255, 255, 255);
imagefilledrectangle($src, 0,0, 99,99, $white);
$dst = imagescale($src, 200, 200, IMG_BILINEAR_FIXED);
echo "truecolor source\n";
foreach ($coordinates as $coordinate) {
list($x, $y) = $coordinate;
printf("%3d, %3d: %x\n", $x, $y, imagecolorat($dst, $x, $y));
}
$src = imagecreate(100, 100);
$white = imagecolorallocate($src, 255, 255, 255);
imagefilledrectangle($src, 0,0, 99,99, $white);
$dst = imagescale($src, 200, 200, IMG_BILINEAR_FIXED);
echo "\npalette source\n";
foreach ($coordinates as $coordinate) {
list($x, $y) = $coordinate;
printf("%3d, %3d: %x\n", $x, $y, imagecolorat($dst, $x, $y));
}
?>
===DONE===
--EXPECT--
truecolor source
0, 0: ffffff
0, 199: ffffff
199, 199: ffffff
199, 0: ffffff
palette source
0, 0: ffffff
0, 199: ffffff
199, 199: ffffff
199, 0: ffffff
===DONE===
-27
View File
@@ -1,27 +0,0 @@
--TEST--
Bug #73614 (gdImageFilledArc() doesn't properly draw pies)
--SKIPIF--
<?php
if (!extension_loaded('gd')) die('skip gd extension not available');
if (!GD_BUNDLED && version_compare(GD_VERSION, '2.2.5', '<=')) die('skip upstream bugfix not yet released');
?>
--FILE--
<?php
require_once __DIR__ . '/func.inc';
$image = imagecreatetruecolor(500, 500);
$white = imagecolorallocate($image, 0xFF, 0xFF, 0xFF);
$navy = imagecolorallocate($image, 0x00, 0x00, 0x80);
$red = imagecolorallocate($image, 0xFF, 0x00, 0x00);
imagefilledarc($image, 250, 250, 500, 250, 0, 88, $white, IMG_ARC_PIE);
imagefilledarc($image, 250, 250, 500, 250, 88, 91 , $navy, IMG_ARC_PIE);
imagefilledarc($image, 250, 250, 500, 250, 91, 360 , $red, IMG_ARC_PIE);
test_image_equals_file(__DIR__ . '/bug73614.png', $image);
?>
===DONE===
--EXPECT--
The images are equal.
===DONE===
Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

-19
View File
@@ -1,19 +0,0 @@
--TEST--
Bug #77195 (Incorrect error handling of imagecreatefromjpeg())
--SKIPIF--
<?php
if (!extension_loaded('gd')) die('skip gd extension not available');
if (!gd_info()['JPEG Support']) die('skip JPEG support not available');
?>
--FILE--
<?php
$filename = __DIR__ . '/bug77195.jpeg';
@imagecreatefromjpeg($filename);
imagecreatefromjpeg($filename);
?>
===DONE===
--EXPECTF--
Warning: imagecreatefromjpeg(): gd-jpeg: JPEG library reports unrecoverable error: JPEG datastream contains no image in %s on line %d
Warning: imagecreatefromjpeg(): '%s' is not a valid JPEG file in %s on line %d
===DONE===
-50
View File
@@ -1,50 +0,0 @@
--TEST--
Bug #77198 (auto cropping has insufficient precision)
--SKIPIF--
<?php
if (!extension_loaded('gd')) die('skip gd extension not available');
if (!GD_BUNDLED) die('upstream bugfix has not been released');
?>
--FILE--
<?php
function createWhiteImageWithBlackPixelAt($x, $y)
{
$im = imagecreatetruecolor(8, 8);
imagefilledrectangle($im, 0, 0, 7, 7, 0xffffff);
imagesetpixel($im, $x, $y, 0x000000);
return $im;
}
for ($y = 0; $y < 8; $y++) {
for ($x = 0; $x < 8; $x++) {
if (($x == 0 && ($y == 0 || $y == 7)) || ($x == 7 && ($y == 0 || $y == 7))) {
continue; // skip the corners
}
$orig = createWhiteImageWithBlackPixelAt($x, $y);
$cropped = imagecropauto($orig, IMG_CROP_SIDES);
if (!$cropped) {
printf("Pixel at %d, %d: unexpected NULL crop\n", $x, $y);
} else {
$width = imagesx($cropped);
if ($width !== 1) {
printf("Pixel at %d, %d: unexpected width (%d)\n", $x, $y, $width);
}
$height = imagesy($cropped);
if ($height !== 1) {
printf("Pixel at %d, %d: unexpected height (%d)\n", $x, $y, $height);
}
$color = imagecolorat($cropped, 0, 0);
if ($color !== 0x000000) {
printf("Pixel at %d, %d: unexpected color (%d)\n", $x, $y, $color);
}
imagedestroy($cropped);
}
imagedestroy($orig);
}
}
?>
===DONE===
--EXPECT--
===DONE===
-47
View File
@@ -1,47 +0,0 @@
--TEST--
Bug #77198 (threshold cropping has insufficient precision)
--SKIPIF--
<?php
if (!extension_loaded('gd')) die('skip gd extension not available');
if (!GD_BUNDLED) die('upstream bugfix has not been released');
?>
--FILE--
<?php
function createWhiteImageWithBlackPixelAt($x, $y)
{
$im = imagecreatetruecolor(8, 8);
imagefilledrectangle($im, 0, 0, 7, 7, 0xffffff);
imagesetpixel($im, $x, $y, 0x000000);
return $im;
}
for ($y = 0; $y < 8; $y++) {
for ($x = 0; $x < 8; $x++) {
$orig = createWhiteImageWithBlackPixelAt($x, $y);
$cropped = imagecropauto($orig, IMG_CROP_THRESHOLD, 1, 0xffffff);
if (!$cropped) {
printf("Pixel at %d, %d: unexpected NULL crop\n", $x, $y);
} else {
$width = imagesx($cropped);
if ($width !== 1) {
printf("Pixel at %d, %d: unexpected width (%d)\n", $x, $y, $width);
}
$height = imagesy($cropped);
if ($height !== 1) {
printf("Pixel at %d, %d: unexpected height (%d)\n", $x, $y, $height);
}
$color = imagecolorat($cropped, 0, 0);
if ($color !== 0x000000) {
printf("Pixel at %d, %d: unexpected color (%d)\n", $x, $y, $color);
}
imagedestroy($cropped);
}
imagedestroy($orig);
}
}
?>
===DONE===
--EXPECT--
===DONE===
-37
View File
@@ -1,37 +0,0 @@
--TEST--
Bug #77200 (imagecropauto(…, GD_CROP_SIDES) crops left but not right)
--SKIPIF--
<?php
if (!extension_loaded('gd')) die('skip gd extension not available');
if (!GD_BUNDLED) die('upstream bugfix has not been released');
?>
--FILE--
<?php
$orig = imagecreatetruecolor(8, 8);
$red = imagecolorallocate($orig, 255, 0, 0);
$green = imagecolorallocate($orig, 0, 255, 0);
$blue = imagecolorallocate($orig, 0, 0, 255);
imagefilledrectangle($orig, 0, 0, 3, 3, $green); // tl
imagefilledrectangle($orig, 4, 0, 7, 3, $red); // tr
imagefilledrectangle($orig, 0, 4, 3, 7, $green); // bl
imagefilledrectangle($orig, 4, 4, 7, 7, $blue); // br
$cropped = imagecropauto($orig, IMG_CROP_SIDES);
var_dump(imagesx($cropped));
imagefilledrectangle($orig, 0, 0, 3, 3, $red); // tl
imagefilledrectangle($orig, 4, 0, 7, 3, $green); // tr
imagefilledrectangle($orig, 0, 4, 3, 7, $blue); // bl
imagefilledrectangle($orig, 4, 4, 7, 7, $green); // br
$cropped = imagecropauto($orig, IMG_CROP_SIDES);
var_dump(imagesx($cropped));
?>
===DONE===
--EXPECT--
int(4)
int(4)
===DONE===
-21
View File
@@ -1,21 +0,0 @@
--TEST--
Bug #77269 (Potential unsigned underflow in gdImageScale)
--SKIPIF--
<?php
if (!extension_loaded('gd')) die('skip gd extension not available');
if (getenv("SKIP_SLOW_TESTS")) die("skip slow test");
?>
--INI--
memory_limit=2G
--FILE--
<?php
$im = imagecreate(2**28, 1);
if(is_resource($im)) {
imagescale($im, 1, 1, IMG_TRIANGLE);
}
?>
===DONE===
--EXPECTF--
Warning: imagescale():%S product of memory allocation multiplication would exceed INT_MAX, failing operation gracefully
in %s on line %d
===DONE===
-20
View File
@@ -1,20 +0,0 @@
--TEST--
Bug #77270 (imagecolormatch Out Of Bounds Write on Heap)
--INI--
memory_limit=-1
--SKIPIF--
<?php
if (!extension_loaded('gd')) die('skip gd extension not available');
if (!GD_BUNDLED && version_compare(GD_VERSION, '2.2.5', '<=')) die('skip upstream bugfix has not been released');
?>
--FILE--
<?php
$img1 = imagecreatetruecolor(0xfff, 0xfff);
$img2 = imagecreate(0xfff, 0xfff);
imagecolorallocate($img2, 0, 0, 0);
imagesetpixel($img2, 0, 0, 255);
imagecolormatch($img1, $img2);
?>
===DONE===
--EXPECT--
===DONE===
-21
View File
@@ -1,21 +0,0 @@
--TEST--
Bug #77272 (imagescale() may return image resource on failure)
--INI--
memory_limit=-1
--SKIPIF--
<?php
if (!extension_loaded('gd')) die('skip gd extension not available');
if (!GD_BUNGLED && version_compare(GD_VERSION, '2.2.5', '<=')) die('skip upstream fix not yet released');
if (getenv("SKIP_SLOW_TESTS")) die("skip slow test");
?>
--FILE--
<?php
$img = imagecreate(2**28, 1);
var_dump(imagescale($img, 1, 1, IMG_TRIANGLE));
?>
===DONE===
--EXPECTF--
Warning: imagescale():%S product of memory allocation multiplication would exceed INT_MAX, failing operation gracefully
in %s on line %d
bool(false)
===DONE===
Binary file not shown.

Before

Width:  |  Height:  |  Size: 102 B

-15
View File
@@ -1,15 +0,0 @@
--TEST--
Bug #77391 (1bpp BMPs may fail to be loaded)
--SKIPIF--
<?php
if (!extension_loaded('gd')) die('skip gd extension not available');
if (!GD_BUNDLED && version_compare(GD_VERSION, '2.2.5', '<=')) die('skip upstream not yet fixed');
?>
--FILE--
<?php
var_dump(imagecreatefrombmp(__DIR__ . '/bug77391.bmp'));
?>
===DONE===
--EXPECTF--
resource(%d) of type (gd)
===DONE===
-26
View File
@@ -1,26 +0,0 @@
--TEST--
Bug #77479 (imagewbmp() segfaults with very large image)
--SKIPIF--
<?php
if (!extension_loaded('gd')) die('skip gd extension not available');
if (getenv("SKIP_SLOW_TESTS")) die("skip slow test");
?>
--INI--
memory_limit=-1
--FILE--
<?php
$im = imagecreate(40000, 20000);
imagecolorallocate($im, 0, 0, 0);
imagewbmp($im, __DIR__ . '/77479.wbmp');
?>
===DONE===
--EXPECTF--
Warning: imagewbmp():%S product of memory allocation multiplication would exceed INT_MAX, failing operation gracefully
in %s on line %d
Warning: imagewbmp(): Could not create WBMP in %s on line %d
===DONE===
--CLEAN--
<?php
@unlink(__DIR__ . '/77479.wbmp');
?>
+1 -5
View File
@@ -1536,11 +1536,7 @@ static php_iconv_err_t _php_iconv_mime_decode(smart_str *pretval, const char *st
default: /* first letter of a non-encoded word */
err = _php_iconv_appendc(pretval, *p1, cd_pl);
if (err != PHP_ICONV_ERR_SUCCESS) {
if (mode & PHP_ICONV_MIME_DECODE_CONTINUE_ON_ERROR) {
err = PHP_ICONV_ERR_SUCCESS;
} else {
goto out;
}
goto out;
}
encoded_word = NULL;
if ((mode & PHP_ICONV_MIME_DECODE_STRICT)) {
-21
View File
@@ -1,21 +0,0 @@
--TEST--
Bug #77147 (Fixing 60494 ignored ICONV_MIME_DECODE_CONTINUE_ON_ERROR)
--SKIPIF--
<?php
if (!extension_loaded('iconv')) die('skip iconv extension not available');
?>
--FILE--
<?php
$string = <<<EOF
Feedback-ID: 014a93e3-1f5e-4df6-b347-6b59f0f746b8:b5891053-55d1-45bc-a0b5-47a7a9b59687:email:epslh1�
EOF;
$headers = iconv_mime_decode_headers($string, ICONV_MIME_DECODE_CONTINUE_ON_ERROR);
var_dump($headers);
?>
===DONE===
--EXPECT--
array(1) {
["Feedback-ID"]=>
string(86) "014a93e3-1f5e-4df6-b347-6b59f0f746b8:b5891053-55d1-45bc-a0b5-47a7a9b59687:email:epslh1"
}
===DONE===
+1 -19
View File
@@ -561,15 +561,6 @@ static const zend_module_dep imap_deps[] = {
};
/* }}} */
/* {{{ PHP_INI
*/
PHP_INI_BEGIN()
STD_PHP_INI_BOOLEAN("imap.enable_insecure_rsh", "0", PHP_INI_SYSTEM, OnUpdateBool, enable_rsh, zend_imap_globals, imap_globals)
PHP_INI_END()
/* }}} */
/* {{{ imap_module_entry
*/
zend_module_entry imap_module_entry = {
@@ -840,8 +831,6 @@ PHP_MINIT_FUNCTION(imap)
{
unsigned long sa_all = SA_MESSAGES | SA_RECENT | SA_UNSEEN | SA_UIDNEXT | SA_UIDVALIDITY;
REGISTER_INI_ENTRIES();
#ifndef PHP_WIN32
mail_link(&unixdriver); /* link in the unix driver */
mail_link(&mhdriver); /* link in the mh driver */
@@ -1059,12 +1048,6 @@ PHP_MINIT_FUNCTION(imap)
GC_TEXTS texts
*/
if (!IMAPG(enable_rsh)) {
/* disable SSH and RSH, see https://bugs.php.net/bug.php?id=77153 */
mail_parameters (NIL, SET_RSHTIMEOUT, 0);
mail_parameters (NIL, SET_SSHTIMEOUT, 0);
}
le_imap = zend_register_list_destructors_ex(mail_close_it, NULL, "imap", module_number);
return SUCCESS;
}
@@ -1152,8 +1135,6 @@ PHP_MINFO_FUNCTION(imap)
php_info_print_table_row(2, "Kerberos Support", "enabled");
#endif
php_info_print_table_end();
DISPLAY_INI_ENTRIES();
}
/* }}} */
@@ -4116,6 +4097,7 @@ PHP_FUNCTION(imap_mail)
if (!ZSTR_LEN(message)) {
/* this is not really an error, so it is allowed. */
php_error_docref(NULL, E_WARNING, "No message string in mail command");
message = NULL;
}
if (_php_imap_mail(ZSTR_VAL(to), ZSTR_VAL(subject), ZSTR_VAL(message), headers?ZSTR_VAL(headers):NULL, cc?ZSTR_VAL(cc):NULL,
-1
View File
@@ -229,7 +229,6 @@ ZEND_BEGIN_MODULE_GLOBALS(imap)
#endif
/* php_stream for php_mail_gets() */
php_stream *gets_stream;
zend_bool enable_rsh;
ZEND_END_MODULE_GLOBALS(imap)
#ifdef ZTS
-15
View File
@@ -1,15 +0,0 @@
--TEST--
Bug #77020 (null pointer dereference in imap_mail)
--SKIPIF--
<?php
if (!extension_loaded('imap')) die('skip imap extension not available');
?>
--FILE--
<?php
imap_mail('1', 1, NULL);
?>
===DONE===
--EXPECTF--
Warning: imap_mail(): No message string in mail command in %s on line %d
%s
===DONE===
-24
View File
@@ -1,24 +0,0 @@
--TEST--
Bug #77153 (imap_open allows to run arbitrary shell commands via mailbox parameter)
--SKIPIF--
<?php
if (!extension_loaded("imap")) {
die("skip imap extension not available");
}
?>
--FILE--
<?php
$payload = "echo 'BUG'> " . __DIR__ . '/__bug';
$payloadb64 = base64_encode($payload);
$server = "x -oProxyCommand=echo\t$payloadb64|base64\t-d|sh}";
@imap_open('{'.$server.':143/imap}INBOX', '', '');
// clean
imap_errors();
var_dump(file_exists(__DIR__ . '/__bug'));
?>
--EXPECT--
bool(false)
--CLEAN--
<?php
if(file_exists(__DIR__ . '/__bug')) unlink(__DIR__ . '/__bug');
?>
+10 -9
View File
@@ -3125,7 +3125,7 @@ MBSTRING_API HashTable *php_mb_convert_encoding_recursive(HashTable *input, cons
php_error_docref(NULL, E_WARNING, "Cannot convert recursively referenced values");
return NULL;
}
GC_TRY_PROTECT_RECURSION(input);
GC_PROTECT_RECURSION(input);
output = zend_new_array(zend_hash_num_elements(input));
ZEND_HASH_FOREACH_KEY_VAL(input, idx, key, entry) {
/* convert key */
@@ -3170,7 +3170,7 @@ MBSTRING_API HashTable *php_mb_convert_encoding_recursive(HashTable *input, cons
zend_hash_index_add(output, idx, &entry_tmp);
}
} ZEND_HASH_FOREACH_END();
GC_TRY_UNPROTECT_RECURSION(input);
GC_UNPROTECT_RECURSION(input);
return output;
}
@@ -4738,7 +4738,7 @@ MBSTRING_API int php_mb_check_encoding_recursive(HashTable *vars, const zend_str
php_error_docref(NULL, E_WARNING, "Cannot not handle circular references");
return 0;
}
GC_TRY_PROTECT_RECURSION(vars);
GC_PROTECT_RECURSION(vars);
ZEND_HASH_FOREACH_KEY_VAL(vars, idx, key, entry) {
ZVAL_DEREF(entry);
if (key) {
@@ -4772,7 +4772,7 @@ MBSTRING_API int php_mb_check_encoding_recursive(HashTable *vars, const zend_str
break;
}
} ZEND_HASH_FOREACH_END();
GC_TRY_UNPROTECT_RECURSION(vars);
GC_UNPROTECT_RECURSION(vars);
mbfl_buffer_converter_delete(convd);
return valid;
}
@@ -5010,9 +5010,11 @@ PHP_FUNCTION(mb_chr)
/* }}} */
static inline char* php_mb_scrub(const char* str, size_t str_len, const mbfl_encoding *enc, size_t *ret_len)
static inline char* php_mb_scrub(const char* str, size_t str_len, const mbfl_encoding *enc)
{
return php_mb_convert_encoding_ex(str, str_len, enc, enc, ret_len);
size_t ret_len;
return php_mb_convert_encoding_ex(str, str_len, enc, enc, &ret_len);
}
@@ -5025,7 +5027,6 @@ PHP_FUNCTION(mb_scrub)
char *enc_name = NULL;
size_t enc_name_len;
char *ret;
size_t ret_len;
ZEND_PARSE_PARAMETERS_START(1, 2)
Z_PARAM_STRING(str, str_len)
@@ -5038,13 +5039,13 @@ PHP_FUNCTION(mb_scrub)
RETURN_FALSE;
}
ret = php_mb_scrub(str, str_len, enc, &ret_len);
ret = php_mb_scrub(str, str_len, enc);
if (ret == NULL) {
RETURN_FALSE;
}
RETVAL_STRINGL(ret, ret_len);
RETVAL_STRING(ret);
efree(ret);
}
/* }}} */
+5 -5
View File
@@ -540,13 +540,13 @@ compile_length_string_node(Node* node, regex_t* reg)
ambig = NODE_STRING_IS_AMBIG(node);
p = prev = sn->s;
SAFE_ENC_LEN(enc, p, sn->end, prev_len);
prev_len = enclen(enc, p);
p += prev_len;
slen = 1;
rlen = 0;
for (; p < sn->end; ) {
SAFE_ENC_LEN(enc, p, sn->end, len);
len = enclen(enc, p);
if (len == prev_len) {
slen++;
}
@@ -591,12 +591,12 @@ compile_string_node(Node* node, regex_t* reg)
ambig = NODE_STRING_IS_AMBIG(node);
p = prev = sn->s;
SAFE_ENC_LEN(enc, p, end, prev_len);
prev_len = enclen(enc, p);
p += prev_len;
slen = 1;
for (; p < end; ) {
SAFE_ENC_LEN(enc, p, end, len);
len = enclen(enc, p);
if (len == prev_len) {
slen++;
}
@@ -3624,7 +3624,7 @@ expand_case_fold_string(Node* node, regex_t* reg)
goto err;
}
SAFE_ENC_LEN(reg->enc, p, end, len);
len = enclen(reg->enc, p);
if (n == 0) {
if (IS_NULL(snode)) {
+1 -6
View File
@@ -393,17 +393,14 @@ save_entry(ScanEnv* env, enum SaveType type, int* id)
c = ONIGENC_MBC_TO_CODE(enc, p, end); \
pfetch_prev = p; \
p += ONIGENC_MBC_ENC_LEN(enc, p); \
if(UNEXPECTED(p > end)) p = end; \
} while (0)
#define PINC_S do { \
p += ONIGENC_MBC_ENC_LEN(enc, p); \
if(UNEXPECTED(p > end)) p = end; \
} while (0)
#define PFETCH_S(c) do { \
c = ONIGENC_MBC_TO_CODE(enc, p, end); \
p += ONIGENC_MBC_ENC_LEN(enc, p); \
if(UNEXPECTED(p > end)) p = end; \
} while (0)
#define PPEEK (p < end ? ONIGENC_MBC_TO_CODE(enc, p, end) : PEND_VALUE)
@@ -5412,9 +5409,7 @@ fetch_token(OnigToken* tok, UChar** src, UChar* end, ScanEnv* env)
tok->u.code = c2;
}
else { /* string */
int len;
SAFE_ENC_LEN(enc, tok->backp, end, len);
p = tok->backp + len;
p = tok->backp + enclen(enc, tok->backp);
}
}
break;
-12
View File
@@ -455,16 +455,4 @@ extern int onig_global_callout_names_free(void);
extern int onig_print_names(FILE*, regex_t*);
#endif
#if (defined (__GNUC__) && __GNUC__ > 2 ) && !defined(DARWIN) && !defined(__hpux) && !defined(_AIX)
# define UNEXPECTED(condition) __builtin_expect(condition, 0)
#else
# define UNEXPECTED(condition) (condition)
#endif
#define SAFE_ENC_LEN(enc, p, end, res) do { \
int __res = enclen(enc, p); \
if (UNEXPECTED(p + __res > end)) __res = end - p; \
res = __res; \
} while(0);
#endif /* REGPARSE_H */
+1 -3
View File
@@ -128,18 +128,16 @@ utf16be_is_mbc_newline(const UChar* p, const UChar* end)
}
static OnigCodePoint
utf16be_mbc_to_code(const UChar* p, const UChar* end)
utf16be_mbc_to_code(const UChar* p, const UChar* end ARG_UNUSED)
{
OnigCodePoint code;
if (UTF16_IS_SURROGATE_FIRST(*p)) {
if (end - p < 4) return 0;
code = ((((p[0] - 0xd8) << 2) + ((p[1] & 0xc0) >> 6) + 1) << 16)
+ ((((p[1] & 0x3f) << 2) + (p[2] - 0xdc)) << 8)
+ p[3];
}
else {
if (end - p < 2) return 0;
code = p[0] * 256 + p[1];
}
return code;
+1 -2
View File
@@ -141,14 +141,13 @@ utf16le_is_mbc_newline(const UChar* p, const UChar* end)
}
static OnigCodePoint
utf16le_mbc_to_code(const UChar* p, const UChar* end)
utf16le_mbc_to_code(const UChar* p, const UChar* end ARG_UNUSED)
{
OnigCodePoint code;
UChar c0 = *p;
UChar c1 = *(p+1);
if (UTF16_IS_SURROGATE_FIRST(c1)) {
if (end - p < 4) return 0;
code = ((((c1 - 0xd8) << 2) + ((c0 & 0xc0) >> 6) + 1) << 16)
+ ((((c0 & 0x3f) << 2) + (p[3] - 0xdc)) << 8)
+ p[2];
-1
View File
@@ -67,7 +67,6 @@ utf32be_is_mbc_newline(const UChar* p, const UChar* end)
static OnigCodePoint
utf32be_mbc_to_code(const UChar* p, const UChar* end ARG_UNUSED)
{
if (end - p < 4) return 0;
return (OnigCodePoint )(((p[0] * 256 + p[1]) * 256 + p[2]) * 256 + p[3]);
}
-1
View File
@@ -67,7 +67,6 @@ utf32le_is_mbc_newline(const UChar* p, const UChar* end)
static OnigCodePoint
utf32le_mbc_to_code(const UChar* p, const UChar* end ARG_UNUSED)
{
if (end - p < 4) return 0;
return (OnigCodePoint )(((p[3] * 256 + p[2]) * 256 + p[1]) * 256 + p[0]);
}
+4 -5
View File
@@ -791,9 +791,7 @@ static inline void mb_regex_substitute(
no = onig_name_to_backref_number(regexp, (OnigUChar *)name, (OnigUChar *)name_end, regs);
break;
default:
/* We're not treating \ as an escape character and will interpret something like
* \\1 as \ followed by \1, rather than \\ followed by 1. This is because this
* function has not supported escaping of backslashes historically. */
p += clen;
smart_str_appendl(pbuf, sp, p - sp);
continue;
}
@@ -1240,6 +1238,7 @@ PHP_FUNCTION(mb_split)
size_t string_len;
int err;
size_t n;
zend_long count = -1;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss|l", &arg_pattern, &arg_pattern_len, &string, &string_len, &count) == FAILURE) {
@@ -1297,8 +1296,8 @@ PHP_FUNCTION(mb_split)
}
/* otherwise we just have one last element to add to the array */
if ((OnigUChar *)(string + string_len) > chunk_pos) {
size_t n = ((OnigUChar *)(string + string_len) - chunk_pos);
n = ((OnigUChar *)(string + string_len) - chunk_pos);
if (n > 0) {
add_next_index_stringl(return_value, (char *)chunk_pos, n);
} else {
add_next_index_stringl(return_value, "", 0);
-11
View File
@@ -1,11 +0,0 @@
--TEST--
Bug #77165: mb_check_encoding crashes when argument given an empty array
--FILE--
<?php
var_dump(mb_check_encoding(array()));
var_dump(mb_convert_encoding(array(), 'UTF-8'));
?>
--EXPECT--
bool(true)
array(0) {
}
-21
View File
@@ -1,21 +0,0 @@
--TEST--
Bug #77367 (Negative size parameter in mb_split)
--SKIPIF--
<?php
if (!extension_loaded('mbstring')) die('mbstring extension not available');
if (!function_exists('mb_split')) die('mb_split() not available');
?>
--FILE--
<?php
mb_regex_encoding('UTF-8');
var_dump(mb_split("\\w", "\xfc"));
?>
===DONE===
--EXPECT--
array(2) {
[0]=>
string(0) ""
[1]=>
string(0) ""
}
===DONE===
-11
View File
@@ -1,11 +0,0 @@
--TEST--
Bug #77370 (Buffer overflow on mb regex functions - fetch_token)
--SKIPIF--
<?php extension_loaded('mbstring') or die('skip mbstring not available'); ?>
--FILE--
<?php
var_dump(mb_split(" \xfd",""));
?>
--EXPECTF--
Warning: mb_split(): mbregex compile err: invalid code point value in %sbug77370.php on line %d
bool(false)
-11
View File
@@ -1,11 +0,0 @@
--TEST--
Bug #77371 (heap buffer overflow in mb regex functions - compile_string_node)
--SKIPIF--
<?php extension_loaded('mbstring') or die('skip mbstring not available'); ?>
--FILE--
<?php
var_dump(mb_ereg("()0\xfc00000\xfc00000\xfc00000\xfc",""));
?>
--EXPECTF--
Warning: mb_ereg(): mbregex compile err: invalid code point value in %sbug77371.php on line %d
bool(false)
-23
View File
@@ -1,23 +0,0 @@
--TEST--
Bug #77381 (heap buffer overflow in multibyte match_at)
--SKIPIF--
<?php extension_loaded('mbstring') or die('skip mbstring not available'); ?>
--FILE--
<?php
var_dump(mb_ereg("000||0\xfa","0"));
var_dump(mb_ereg("(?i)000000000000000000000\xf0",""));
var_dump(mb_ereg("0000\\"."\xf5","0"));
var_dump(mb_ereg("(?i)FFF00000000000000000\xfd",""));
?>
--EXPECTF--
Warning: mb_ereg(): mbregex compile err: invalid code point value in %sbug77381.php on line %d
bool(false)
Warning: mb_ereg(): mbregex compile err: invalid code point value in %sbug77381.php on line %d
bool(false)
Warning: mb_ereg(): mbregex compile err: invalid code point value in %sbug77381.php on line %d
bool(false)
Warning: mb_ereg(): mbregex compile err: invalid code point value in %sbug77381.php on line %d
bool(false)
-14
View File
@@ -1,14 +0,0 @@
--TEST--
Bug #77371 (Heap overflow in utf32be_mbc_to_code)
--SKIPIF--
<?php extension_loaded('mbstring') or die('skip mbstring not available'); ?>
--FILE--
<?php
mb_regex_encoding("UTF-32");
var_dump(mb_split("\x00\x00\x00\x5c\x00\x00\x00B","000000000000000000000000000000"));
?>
--EXPECT--
array(1) {
[0]=>
string(30) "000000000000000000000000000000"
}
Loaded 100 of 239 files, more files were not shown because too many files have changed in this diff. Show more