Ahmed Abdou [Sun, 17 Feb 2019 21:59:00 +0000 (22:59 +0100)]
Fix #64705 errorInfo property of PDOException is null when PDO::__construct() fails
PDO driver constructors are throwing PdoException without setting
errorInfo, so create a new reusable function that throws exceptions
for PDO and will also set the errorInfo. Use this function in
pdo_mysql, pdo_sqlite, and pdo_pgsql.
Fix bug #75785 by attempt switching endianness on Maker's Note
Different manufacturer models may come with a
different endianness (motorola/intel) format. In
order to avoid a big refactor and a gigantic lookup
table, this commit simply attempts to switch the
endianness and proceed when values are acceptable.
Nikita Popov [Tue, 11 Aug 2020 12:42:13 +0000 (14:42 +0200)]
Fixed bug #79917
op_arrays can be shared on two levels: Either the op_array is
completely shared, or it is distinct but shares all members
(apart from static_variables).
The the op_array is distinct, we need to make sure to properly
initialize the MAP_PTR structures.
The `cached` out parameter of `php_com_load_typelib_via_cache()` was
meant to signal whether a particular typelib actually has been cached.
This is not really relevant, though, for the imagined purposes, and
since the parameter is no longer really used, we removed it altohether.
Fix #48585: com_load_typelib holds reference, fails on second call
Whether the type library is cached is actually irrelevant here; what
matters is that the symbols are imported, and since these are not
cached, we have to import them for every request. And we cannot cache
the symbols, because the import depends on the current codepage, but
the codepage is a `PHP_INI_ALL` setting.
Nikita Popov [Mon, 10 Aug 2020 10:54:02 +0000 (12:54 +0200)]
Fixed bug #62294
The primary issue was already resolved in 7c3e487289ec41e560cf7a77e36eb43da2234f33,
but the particular example used in this bug report ran into an
additional issue on PHP 8, because I forgot to drop a number of
zend_bailout calls when switch require failure to throw.
Fix #79922: Crash after multiple calls to xml_parser_free()
We must not call `zend_list_delete()` in resource closer functions
exposed to userland, because decreasing the refcount there leads to
use-after-free scenarios. In this case, commit 4a42fbb worked for
typical use-cases where `xml_parser_free()` has been called exactly
once for the resource, because there is an internal zval (`->index`)
referencing the same resource which already increased the refcount by
one. However, when `xml_parser_free()` is called multiple times on the
same XML parser resource, the resource would be freed prematurely.
Instead we forcefully close the resource in `xml_parser_free()`. We
also could decrease the refcount of the resource there, but that would
require to call `xml_parser_free()` which is somewhat uncommon, and
would be particularly bad wrt. PHP 8 where that function is a NOP, and
as such doesn't have to be called. So we do no longer increase the
refcount of the resource when copying it to the internal zval, and let
the usualy refcounting semantics take care of the resource destruction.
Nikita Popov [Thu, 6 Aug 2020 11:18:29 +0000 (13:18 +0200)]
Improve X509_PKEY management in OpenSSL
Remove the free_pkey argument from php_openssl_pkey_from_zval,
instead return an EVP_PKEY that always needs to be freed
(by incrementing refcount if necessary).
This makes the code simpler and fixes a number of bugs in the
existing handling.
Nikita Popov [Mon, 10 Aug 2020 08:28:13 +0000 (10:28 +0200)]
Fixed bug #79948
Make sure we don't execute further scripts if one of them encountered
an exit exception.
Also make sure that we free file handles that end up unused due to
an early abort in php_execute_scripts(), which turned up as an
issue in the added test case.
Finally, make use of EG(exit_status) in the places where we
zend_eval_string_ex, instead of unconditionally assigning exit
code 254. If an error occurs, the error handler will already set
exit status 255.
Nikita Popov [Mon, 10 Aug 2020 08:38:33 +0000 (10:38 +0200)]
Fixed bug #77561
Unconditionally strip shebang lines when using the CLI SAPI,
independently of whether they occur in the primary or non-primary
script. It's unlikely that someone intentionally wants to print
that shebang line when including a script, and this regularly
causes issues when scripts are used in multiple contexts, e.g.
for direct invocation and as a phar bootstrap.
Nikita Popov [Mon, 10 Aug 2020 08:08:31 +0000 (10:08 +0200)]
Fixed bug #79947
Move the FREE_OP for op_data out of the zend_binary_assign_op_dim_slow()
slow path, so it can be used by the other error path as well. This
makes ASSIGN_DIM_OP structurally more similar to ASSIGN_DIM.
Nikita Popov [Mon, 10 Aug 2020 07:50:55 +0000 (09:50 +0200)]
Fixed bug #79946
Declare __STDC_CONSTANT_MACROS and __STDC_FORMAT_MACROS via -D
to make sure they are declared before the first stdint.h include.
We also define these in php_stdint.h, but don't always include that
file first.
This is necessary for old compilers that use C99 rather than C11
semantics for stdint.h.
Nikita Popov [Fri, 7 Aug 2020 14:05:24 +0000 (16:05 +0200)]
Remove giconv support
The best information I was able to find about this is this mail
from 2009 which indicates that giconv is an old FreeBSD iconv
implementation that has long since been superseded by libiconv.