Compare commits

...
131 Commits
Author SHA1 Message Date
Stanislav Malyshev d4f5aed221 Fix #77423: parse_url() will deliver a wrong host to user
(cherry picked from commit 128fca4037)
2021-01-04 11:49:32 +01:00
Christoph M. Becker 45f25e16d2 Prepare for 7.3.26 2021-01-04 11:34:03 +01:00
Christoph M. Becker 4631611c44 Prepare 7.3.26RC1 2020-12-15 11:10:32 +01:00
Daniel Black 0697a64f7e Fix mysqli_expire_password test for mariadb
In MariaDB-10.4.3 EXPIRE passwords where supported for
MariaDB. This only behaves like MySQL when the system
variable disconnect_on_expired_passwords=1.

MariaDB if there was no password it could not be considered
expired. So the test is adjusted to use actual passwords.
(MariaDB commit a94b20a8e0d9e64eeaabdaaa7a3e03fcdb8a686e)

The error codes produced my MariaDB are different
however still conforming to the SQL specification.

Closes GH-6480.
2020-12-03 10:56:00 +01:00
Nikita Popov d6fcaf5da4 Fixed bug #80457
On x32 sizeof(size_t) != sizeof(zend_long), so we need to be
careful with sign extension here.

Patch by bruno dot premont at restena dot lu.
2020-12-02 11:26:10 +01:00
Jakub Zelenka 685708160e Fix test for bug62890 to not depend on system cert store 2020-11-27 16:32:43 +00:00
Daniel Black 4a10037cb4 Fix mysqli_get_client_stats test
MySQL removed RENAME DATABASE in 18300001c1dbbfddf9a0adcbaeea68956102bdd0
(Sept 2007, 5.1.23). As this briefest existance is very insignificant lets remove it.

It also breaks when testing against MariaDB.

As the alternate path in this test covers all supported MySQL and MariaDB
versions and a signifant portion of unsupported versions lets keep it simple.

Closes GH-6459.
2020-11-27 11:43:34 +01:00
Christoph M. Becker b5ce6df0da 7.3.26 is next 2020-11-10 11:08:16 +01:00
Alexander M. Turek 8eaaabdd58 Fixed bug #80310: Support for icu4c 68.1.
On stable versions, bring back the TRUE/FALSE defines by defining
_U_DEFINE_TRUE_AND_FALSE.

Closes GH-6397.
2020-11-09 14:31:29 +01:00
Christoph M. Becker 2cab085bb3 Fix #80266: parse_url silently drops port number 0
As of commit 81b2f3e[1], `parse_url()` accepts URLs with a zero port,
but does not report that port, what is wrong in hindsight.

Since the port number is stored as `unsigned short` there is no way to
distinguish between port zero and no port.  For BC reasons, we thus
introduce `parse_url_ex2()` which accepts an output parameter that
allows that distinction, and use the new function to fix the behavior.

The introduction of `parse_url_ex2()` has been suggested by Nikita.

[1] <http://git.php.net/?p=php-src.git;a=commit;h=81b2f3e5d9fcdffd87a4fcd12bd8c708a97091e1>

Closes GH-6399.
2020-11-04 14:53:19 +01:00
Nikita Popov 00ba784a2c Fix another implicit function declaration in configure
As mentioned on bug #80171. This one is in libtool.m4, might get
lost on libtool updates.
2020-11-03 10:38:16 +01:00
Christoph M. Becker 9690ded288 Fix #70461: disable md5 code when it is not supported in net-snmp
Patch contributed by Alexander Bergmann.

Closes GH-6389.
2020-11-02 11:36:26 +01:00
Christoph M. Becker ee3227af48 Fix format specifier
In this function, `i` is of type `size_t`.
2020-10-29 13:08:16 +01:00
Christoph M. Becker c21e901ba7 Fix #44618: Fetching may rely on uninitialized data
Unless `SQLGetData()` returns `SQL_SUCCESS` or `SQL_SUCCESS_WITH_INFO`,
the `StrLen_or_IndPtr` output argument is not guaranteed to be properly
set.  Thus we handle retrieval failure other than `SQL_ERROR` by
yielding `false` for those column values and raising a warning.

Closes GH-6281.
2020-10-29 11:59:12 +01:00
Nikita Popov 7817fc07e1 Deny cloning of fileinfo objects
Using a cloned finfo object will crash.
2020-10-26 16:50:20 +01:00
Christoph M. Becker be6d72b3a4 Revert "Fix out-of-bounds write"
This reverts commit bf6873a18e.

CVE-2020-26159 is bogus; the "bug" was apparently a false positive
reported by Coverity, and the "fix" apparently wrong, see
<https://github.com/kkos/oniguruma/issues/221>.

Closes GH-6357.
2020-10-26 15:40:12 +01:00
Christoph M. Becker 6d2bc72530 Fix #80268: loadHTML() truncates at NUL bytes
libxml2 has no particular issues parsing HTML strings with NUL bytes;
these just cause truncation of the current text content, but parsing
continues generally.  Since `::loadHTMLFile()` already supports NUL
bytes, `::loadHTML()` should as well.

Note that this is different from XML, which does not allow any NUL
bytes.

Closes GH-6368.
2020-10-26 13:08:05 +01:00
Nikita Popov 824cbc2781 Declare may_retry_reparse_point on windows only 2020-10-26 12:40:45 +01:00
Christoph M. Becker 7424bfc7ac Fix #62474: com_event_sink crashes on certain arguments
We have to make sure that the variant is of type `VT_DISPATCH` before
we access it as such.

Closes GH-6372.
2020-10-26 11:48:57 +01:00
Christoph M. Becker 848e24f24d Fix #80258: Windows Deduplication Enabled, randon permission errors
A recent bug fix regarding symlinks claimed:

> After resolving reparse points, the path still may be a reparse
> point; in that case we have to resolve that reparse point as well.

While that is basically correct, some reparse points may point to
inaccessible system folders (e.g. `IO_REPARSE_TAG_DEDUP` points to
"\System Volume Information").  Since we don't know details about
arbitrary reparse points, and are mainly interested in nested symlinks,
we take a step back, and only resolve `IO_REPARSE_TAG_SYMLINK` for now.

Close GH-6354.
2020-10-26 11:21:14 +01:00
Christoph M. Becker 2be27074b6 Fix #80280: ADD_EXTENSION_DEP() fails for ext/standard and ext/date
`ADD_EXTENSION_DEP()` relies on the `PHP_<extname>` config variables to
be set to `"yes"`, and since the standard and date extension are always
enabled, we define the respective variables uncoditionally.

Closes GH-6383.
2020-10-26 11:03:05 +01:00
George Peter Banyard 12a09183b3 Fix bug 76618
Apply patch which was attached to the bug in July 2018
2020-10-22 17:01:48 +01:00
Nikita Popov d4bf0799b8 Don't crash on uninitialized tidy object
"Uninitialized" here means that the object was created ordinarily
-- no constructor skipping involved. Most tidy methods seem to
handle this fine, but these three need to be guarded.
2020-10-22 16:04:22 +02:00
Derick Rethans d4200ba6cf Updated to version 2020.4 (2020d) 2020-10-22 10:12:24 +01:00
Christoph M. Becker 315b95b065 Fix #80242: imap_mail_compose() segfaults for multipart with rfc822
libc-client expects `TYPEMESSAGE` with an explicit subtype of `RFC822`
to have a `nested.msg` (otherwise there will be a segfault during
free), but not to have any `contents.text.data` (this will leak
otherwise).

Closes GH-6345.
2020-10-20 18:58:45 +02:00
Christoph M. Becker de58fb34c9 Add char* cast to avoid compiler warnings
In libc-client 2007f `data` is declared as `unsigned char *`; there may
be variants which declare it as `void *`, but in any case picky
compilers may warn about a pointer type mismatch in the conditional
(and error with `-W-error`), so we're adding a `char *` cast for good
measure.
2020-10-20 16:29:42 +02:00
Christoph M. Becker 7f3bdda29b Properly fix #80220
The original fix for that bug[1] broke the formerly working composition
of message/rfc822 messages, which results in a segfault when freeing
the message body now.  While `imap_mail_compose()` does not really
support composition of meaningful message/rfc822 messages (although
libc-client appears to support that), some code may still use this to
compose partial messages, and using string manipulation to create the
final message.

The point is that libc-client expects `TYPEMESSAGE` with an explicit
subtype of `RFC822` to have a `nested.msg` (otherwise there will be a
segfault during free), but not to have any `contents.text.data` (this
will leak otherwise).

[1] <http://git.php.net/?p=php-src.git;a=commit;h=0d022ddf03c5fabaaa22e486d1e4a367ed9170a7>

Closes GH-6343.
2020-10-20 13:32:53 +02:00
Derick Rethans 7b5f232b03 Updated to version 2020.3 (2020c) 2020-10-19 09:31:02 +01:00
Christoph M. Becker 4b9db65f68 Fix broken fix for #80239
No idea why that `git am` failed that badly.
2020-10-15 13:18:34 +02:00
Christoph M. Becker 5941b30bb8 Fix #80239: imap_rfc822_write_address() leaks memory
We have to free the address when we're finished with it.
2020-10-15 12:54:53 +02:00
Nikita Popov a29016d70d Fix leak in gmp_export() 2020-10-15 10:16:22 +02:00
Christoph M. Becker db8bf0a9e0 Fix #64076: imap_sort() does not return FALSE on failure
If unsupported `$search_criteria` are passed to `imap_sort()`, the
function returns an empty array, but there is also an error on the
libc-client error stack ("Unknown search criterion: UNSUPPORTED
(errflg=2)").  If, on the other hand, unsupported `$criteria` or
unsupported `$flags` are passed, the function returns `false`.  We
solve this inconsistency by returning `false` for unsupported
`$search_criteria` as well.

Closes GH-6332.
2020-10-13 19:37:05 +02:00
Christoph M. Becker 2d01a89ad1 7.3.25 is next 2020-10-13 09:52:46 +02:00
Christoph M. Becker 8488c34fc6 Fix #80226: imap_sort() leaks sortpgm memory
We need to free what we have allocated.

Closes GH-6327.
2020-10-12 23:16:31 +02:00
Christoph M. Becker 73e43b6e19 Fix #80216: imap_mail_compose() does not validate types/encodings
We need to check whether the given `type`s and `encoding`s are within
bounds to avoid segfaults and out-of-bound reads.

Closes GH-6323.
2020-10-12 16:27:49 +02:00
Christoph M. Becker c1962e900a Fix #80223: imap_mail_compose() leaks envelope on malformed bodies
We have to clean up even on failure.

Closes GH-6322.
2020-10-12 15:08:30 +02:00
Christoph M. Becker 0d022ddf03 Fix #80220: imap_mail_compose() may leak memory
Unless `topbod` is of `TYPEMULTIPART`, `mail_free_body()` does not free
the `nested.part`; while we could do this ourselves, instead we just
ignore additional bodies in this case, i.e. we don't attach them in the
first place.

Closes GH-6321.
2020-10-12 13:31:30 +02:00
Nikita Popov 3c4dd73c02 Detect self-addition of array more accurately
While the zvals may be different, they may still point to the
same array.

Fixes oss-fuzz #26245.
2020-10-12 11:24:31 +02:00
Nikita Popov e304468e57 Deindirect source elements in zend_hash_merge
If the RHS has INDIRECT elements, we do not those to be added to
the LHS verbatim. As we're using UPDATE_INDIRECT, we might even
create a nested INDIRECT that way.

This is a side-quest of oss-fuzz #26245.
2020-10-12 11:24:27 +02:00
Derick Rethans 1ed5a2a54d Fixed test for bug #48097 due to confirmed data changes in timelib 2020-10-11 14:53:52 +01:00
Christoph M. Becker 62a2387a8d Fix #80215: imap_mail_compose() may modify by-val parameters
We separate the input arrays and all sub-arrays to avoid modification
of the passed parameters.

This should be rewritten to use `zend_string`s for the "master" branch.

Closes GH-6316.
2020-10-10 23:25:06 +02:00
Christoph M. Becker 8bee0fbd37 Fix #80213: imap_mail_compose() segfaults on certain $bodies
We have to cater to non-associative arrays where the key may be `NULL`;
we just skip these elements.

Closes GH-6315.
2020-10-10 19:17:13 +02:00
Petr Sumbera 07a4185df1 Make iconv errno support test pass on Solaris.
Closes GH-6291.
2020-10-09 15:24:36 +02:00
Nikita Popov 5018581410 XFAIL test broken by timelib update
I was expecting this to get fixed quickly, but it didn't.
XFAIL for now.
2020-10-09 14:04:47 +02:00
Derick Rethans 14d231bd16 Updated to version 2020.2 (2020b) 2020-10-08 15:19:46 +01:00
Derick Rethans 90a5d7c2ad Updated to version 2020.2 (2020b) 2020-10-08 15:05:38 +01:00
Christoph M. Becker 1895bf7b94 Fix too strict imap test expectations 2020-10-08 12:06:54 +02:00
Christoph M. Becker e68acd031d Fix #77040: tidyNode::isHtml() is completely broken
The documentation of `tidyNode::isHtml()` states that this method
"checks if a node is part of a HTML document".  That is, of course,
nonsense, since a tidyNode is "an HTML node in an HTML file, as
detected by tidy."

What this method is actually supposed to do is to check whether a node
is an element (unless it is the root element).  This has been broken by
commit d8eeb8e[1], which assumed that `enum TidyNodeType` would
represent flags of a bitmask, what it does not.

[1] <http://git.php.net/?p=php-src.git;a=commit;h=d8eeb8e28673236bca3f066ded75037a5bdf6378>

Closes GH-6290.
2020-10-07 17:43:56 +02:00
Christoph M. Becker e857dfa7cc Fix #80185: jdtounix() fails after 2037
There is no such thing as the "end of the unix epoch", and if it was,
it would certainly not be 2037-10-11T02:00:00.  There is, however,
potential integer overflow which we need to avoid.

Closes GH-6288.
2020-10-07 13:23:50 +02:00
Christoph M. Becker 69ba81d183 Fix #46050: odbc_next_result corrupts prepared resource
When resetting the result's values, we also have to reset its numcols.
2020-10-05 17:46:37 +02:00
Nikita Popov aa405b7da2 Fix -Wimplicit-function-declaration in configure
As this is an error with xcode 12, see bug #80171.
2020-10-05 10:43:58 +02:00
K.Kosako bf6873a18e Fix out-of-bounds write
Fixes CVE-2020-26159.

Backported from <https://github.com/kkos/oniguruma/commit/cbe9f8bd9cfc6c3c87a60fbae58fa1a85db59df0>.
2020-10-02 15:02:35 +02:00
Matteo Beccati 1666cfcca0 [ci skip] moved soap fix to 7.3.23
When committing I didn't notice that version had been just bumped
2020-10-02 09:32:52 +02:00
Dmitry Stogov 773f980e00 Backport of a partial fix for bug Bug #76982 (memory leak declaring closure in included file). 2020-10-01 13:18:21 +03:00
Remi Collet 5733f11ee9 Merge branch 'PHP-7.2' into PHP-7.3
* PHP-7.2:
  bump version to 7.2.35-dev
2020-09-30 07:42:14 +02:00
George Peter Banyard 1616363850 Fixed incorrect error message 2020-09-30 08:37:16 +03:00
Remi Collet 662083fc4f bump version to 7.2.35-dev 2020-09-30 07:36:59 +02:00
George Peter Banyard 3f5c47af3b Fixed incorrect logical condition 2020-09-30 08:29:00 +03:00
Stanislav Malyshev ae95d06f68 [ci skip] Add 7.3.23 security fixes to NEWS 2020-09-29 10:09:33 -07:00
Christoph M. Becker b5cb999e7f [ci skip] Fix version 2020-09-29 12:10:51 +02:00
Christoph M. Becker bf5f07cc8b Fix #80152: odbc_execute() moves internal pointer of $params
As least intrusive fix, we separate the passed array argument.

Closes GH-6219.
2020-09-29 11:34:48 +02:00
Christoph M. Becker df5efa2fcd Fix #80150: Failure to fetch error message
In case of statement related errors, we need to pass the respective
statement handle to `SQLError()`.

Closes GH-6217.
2020-09-29 11:02:51 +02:00
Matthias Karbe f5afd0a827 Fix bug #80137
Skip getprotobyname() and getprotobynumber() tests on *nix if there
is no /etc/protocols file.

Closes GH-6193.
2020-09-29 10:58:00 +02:00
Matthias Karbe 2899137391 Fix bug #80138
Skip getservbyname() and getservbyport() tests on *nix if there is
no /etc/services file.

Closes GH-6191.
2020-09-29 10:57:20 +02:00
Remi Collet 035ad0aed5 Merge branch 'PHP-7.2' into PHP-7.3
* PHP-7.2:
  [ci skip] typo
  Update NEWS & UPGRADING
  Do not decode cookie names anymore
  Fix bug #79601 (Wrong ciphertext/tag in AES-CCM encryption for a 12 bytes IV)
2020-09-29 08:50:14 +02:00
Remi Collet af500b8685 [ci skip] typo 2020-09-29 08:49:56 +02:00
Stanislav Malyshev 95e1a415a5 Do not decode cookie names anymore 2020-09-28 21:43:11 -07:00
Stanislav Malyshev 2f5cb702ff Fix bug #79601 (Wrong ciphertext/tag in AES-CCM encryption for a 12 bytes IV) 2020-09-28 21:43:11 -07:00
Stanislav Malyshev 311922ddbe Update UPGRADING 2020-09-28 21:38:58 -07:00
Stanislav Malyshev 7bc112a142 Update NEWS & UPGRADING 2020-09-28 21:38:43 -07:00
Christoph M. Becker 6acfb79276 Fix #67465: NULL Pointer dereference in odbc_handle_preparer
We have to initialize `stmt->driver_data` before we use it.

Closes GH-6225.
2020-09-28 22:57:01 +02:00
Stanislav Malyshev 6559fe9126 Do not decode cookie names anymore 2020-09-26 23:47:04 -07:00
Stanislav Malyshev 0216630ea2 Fix bug #79601 (Wrong ciphertext/tag in AES-CCM encryption for a 12 bytes IV) 2020-09-26 23:46:53 -07:00
George Peter Banyard 4dfbf07644 Fix logic error in PDO 2020-09-25 16:28:48 +01:00
Christoph M. Becker a49555a9e1 Fix #80147: BINARY strings may not be properly zero-terminated
We have to manually ensure that all strings fetched from a data source
are zero-terminated.

Closes GH-6213.
2020-09-25 13:51:18 +02:00
Christoph M. Becker e74f89d95a Use proper skipif section
The ODBC tests have to be skipped if no connection to the server can be
established.
2020-09-24 17:12:18 +02:00
Christoph M. Becker 610e7d2c77 Fix #78470: odbc_specialcolumns() no longer accepts $nullable
It is mandatory to pass either `SQL_NO_NULLS` or `SQL_NULLABLE` as
tenth parameter to `SQLSpecialColumns()`; otherwise the function call
fails.  Therefore the user must be allowed to pass the desired value
as parameter to `odbc_specialcolumns()` again.

Closes GH-6200.
2020-09-24 12:15:59 +02:00
Christoph M. Becker 2576c57a51 Fix #76735: Incorrect message in fopen on invalid mode
We have to log errors in `stream_opener` callbacks to the wrapper's
error log, because otherwise we may pick up an unrelated `errno` or a
most generic message.

Closes GH-6187.
2020-09-23 10:54:06 +02:00
Christoph M. Becker 9439d65f0d Fix #77493: curl_basic_009 fails with newer curl versions
libcurl 7.62.0 introduced a maximum protocol length of 8, so this test
case failed with `CURLE_URL_MALFORMAT`.  While this is lifted to 40 as
of libcurl 7.65.0, and this test case has already been fixed with
commit e27301c[1], we restore the original intention to check for a
`CURLE_UNSUPPORTED_PROTOCOL ` error.

[1] <http://git.php.net/?p=php-src.git;a=commit;h=e27301c7b37f6a1643a0dc1966919bd62a32bc74>
2020-09-23 10:42:48 +02:00
Christoph M. Becker 5ed0602ec6 Fix #76943: Inconsistent stream_wrapper_restore() errors
If restoring of any not registered built-in wrapper is requested, the
function is supposed to fail with a warning, so we have to check this
condition first.

Furthermore, to be able to detect whether a built-in wrapper has been
changed, it is not sufficient to check whether *any* userland wrapper
has been registered, but rather whether the specific wrapper has been
modified.

Closes GH-6183.
2020-09-22 16:11:35 +02:00
Christoph M. Becker 4000780b3d Fix #79423: copy command is limited to size of file it can copy
Passing `NULL` as `lpFileSizeHigh` to `GetFileSize()` gives wrong
results for files larger than 0xFFFFFFFF bytes.  We fix this by using
`GetFileSizeEx()`, and let the mapping fail, if the file size is too
large for the architecture.

Closes GH-5319.
2020-09-22 13:15:07 +02:00
Christoph M. Becker 730fdc77a7 Fix memory leak in php_imap_mutf7()
We have to free the string which has been allocated by libc-client.
2020-09-21 11:25:46 +02:00
Christoph M. Beckerandtwosee 81b2f3e5d9 Fix #80114: parse_url does not accept URLs with port 0
URIs with a 0 port are generally valid, so `parse_url()` should
recognize such URIs, but still report the port as missing.

Co-authored-by: twosee <twose@qq.com>

Closes GH-6152.
2020-09-20 15:34:45 +02:00
Bob Weinand a7544411df Fix mysqli build with mysqlnd and without PDO 2020-09-20 10:02:09 +02:00
Daniel Black 740f0f6165 Fix #78179: mysqli/mysqlnd transaction extensions
MariaDB versioning created a mess with regarding testing
features based on version. We sidestep the problem here
by assuming the extensions are present, and if a syntax
error occurs with a SQL mode TRANS_START_READ_WRITE |
TRANS_START_READ_ONLY enabled, then output the same
warning as before.
2020-09-18 15:29:44 +02:00
Nikita Popov 70cba36fc9 Support NO_BACKSLASH_ESCAPES with newer libmysqlclient
Requires the use of mysql_real_escape_string_quote().
2020-09-18 15:24:57 +02:00
Nikita Popov 77f43e48ff Use MyISAM engine for new test
Travis on 7.3 is showing this error:

> The size of BLOB/TEXT data inserted in one transaction is greater
> than 10% of redo log size. Increase the redo log size using
> innodb_log_file_size.

Force MyISAM engine to avoid this.
2020-09-18 14:49:43 +02:00
Nikita Popov ecd9c42f9e Fix bug #80107: Handling of large compressed packets
There's two layers of packet splitting going on. First, packets
need to be split into having a payload of exactly 2^24-1 bytes or
being the last packet. If the split packet has size between 2^24-5
and 2^24-1 bytes, the compressed packets also needs to be split,
though the choice of split doesn't matter here. I'm splitting off
the first 8192 bytes, as that's what I observe libmysqlclient to be
doing.
2020-09-18 12:55:44 +02:00
Máté Kocsis c7ceebc42c Bug #80107 Add test for mysqli_query() fails for ~16 MB long query when compression is enabled 2020-09-18 12:42:08 +02:00
Nikita Popov c3944c4c4f Fix mysqli_release_savepoint() on mysqlnd
mysqli_release_savepoint() was not actually releasing a savepoint...
2020-09-17 15:59:09 +02:00
Christoph M. Becker efdbc3688b Fix #80115: mysqlnd.debug doesn't recognize absolute paths with slashes 2020-09-17 12:37:02 +02:00
Daniel Black 1aab7db6c8 pdo_mysql/mysqli (native) libmysqlclient_r no-longer used
The mysqlclient_r library exists in mysql-5.6 for compatibility only.

Later versions have it removed.
2020-09-17 11:27:31 +02:00
Daniel Black c9abb0c0ac mysql: native mysql-8.0 uses _Bool
MySQL-8.0 removes option MYSQLI_OPT_SSL_VERIFY_SERVER_CERT
2020-09-17 11:27:31 +02:00
Daniel Black 202a0697f3 mysqli: use native api
Tested with:
* mysql-5.6.49-linux-glibc2.12-x86_64
* mysql-5.7.31-linux-glibc2.12-x86_64
* mysql-8.0.21-linux-glibc2.17-x86_64
* mariadb-10.5.6

configure --with-mysqli=/usr/local/$version/bin/mysql_config   --with-pdo-mysql=/usr/local/$version

MySQL-8.0 removed my_bool
Some options where deprecated in mysql-8.0

MY_CHARSET_INFO used with exposed api mysql_get_character_set_info
rather than internal structures.
2020-09-17 11:27:31 +02:00
Gabríel Arthúr Pétursson efc52f1754 ext/soap: Compare Set-Cookie header case-insensitively
Closes GH-6143.
2020-09-17 10:31:06 +02:00
Nikita Popov a4f806aa79 Fixed bug #80083
Add db2_execute() to the list of functions accessing the local
scope. Ideally the API wouldn't do that, but it seems most
pragmatic to address this on the opcache side at this point.
2020-09-17 10:12:10 +02:00
Christoph M. Becker edddddcea8 7.3.24 is next 2020-09-15 10:51:41 +02:00
Christoph M. Becker 4e198c0064 Avoid segfault if module/extension version is not defined 2020-09-14 22:34:10 +02:00
Christoph M. Becker dfb3a79914 Fix #80067: Omitting the port in bindto setting errors
A recent commit[1] which fixed a memory leak introduced a regression
regarding the formerly liberal handling of IP addresses to bind to.  We
fix this by reverting that commit, and fix the memory leak where it
actually occurs.  In other words, this fix is less intrusive than the
former fix.

[1] <http://git.php.net/?p=php-src.git;a=commit;h=0b8c83f5936581942715d14883cdebddc18bad30>

Closes GH-6104.
2020-09-11 14:44:12 +02:00
Sammy Kaye Powers 2d4aa1ef3d Fix #79825: opcache.file_cache causes SIGSEGV with custom opcode handlers
Modules may have changed after restart which can cause dangling pointers from custom opcode handlers in the second-level cache files. This fix includes the installed module names and versions in the accel_system_id hash as entropy. Closes GH-5836
2020-09-09 12:08:19 -07:00
Christoph M. Becker 5dcb8f2f1c Fix #72941: Modifying bucket->data by-ref has no effect any longer
To match the PHP 5 behavior, we have to explicitly cater to `buffer` or
`data` being references.

Closes GH-6096.
2020-09-08 18:06:40 +02:00
Nikita Popov 07cb665515 Fixed bug #80077
Quoting from the bug report:

> The domain names passed to getmxrr() do not contain a trailing dot.
> DNS lookups which do not find records will (depending on the local
> resolver config) try again by adding the local domain to the end of
> the searched host/domain. In many environments there's an mx record
> for any subdomain of the local domain and the MX query will return
> a hit. But the test expects no hit. So the test fails when checking
> that "qa.php.net" does not have an MX record in DNS. In our local
> environment the resolver falls back to also check qa.php.net.kippdata.de
> which does have an MX record. Using "qa.php.net." instead of "qa.php.net"
> should fix this for everyone.
2020-09-08 10:00:49 +02:00
Nikita Popov e8d36ce762 Avoid duplicate octal warning during heredoc scan ahead 2020-09-04 10:58:51 +02:00
Nikita Popov 46a49be6c8 Fixed bug #80049
Type checking may convert to refcounted values, so force freeing
of extra args.
2020-09-03 17:12:40 +02:00
Christoph M. Becker 1848ccdae2 Fix #80048: Bug #69100 has not been fixed for Windows
We fix the erroneous length calculation on Windows, too.

Closes GH-6067.
2020-09-03 15:43:19 +02:00
Christoph M. Becker c70a938f28 Skip test if A: drive exists
Otherwise the test case will fail for a very different reason.
2020-09-03 10:29:38 +02:00
Nikita Popov 573ad182d2 Handle memory limit error during string reallocation correctly
Do not decrement the refcount before allocating the new string,
as the allocation operation may bail out and cause a use-after-free
lateron. We can only decrement the refcount once the allocation
has succeeded.

Fixes oss-fuzz #25384.
2020-09-03 09:49:29 +02:00
Nikita Popov 54dbd3eccc Fix binary-safety of parse_url
php_parse_url() is intended to support strings that are not zero
terminated. We can't use strcspn in the implementation.

As we have two uses of strcspn, add a helper.
2020-09-02 16:45:25 +02:00
Nikita Popov 2e9e706a82 Fix throwing of yield from related exceptions into generator
Use the general zend_generator_throw_exception() helper for this.
Otherwise we don't handle the off-by-one opline correctly (should
we maybe just stop doing that?)

This is a followup to ad750c3bb6,
which fixed a different yield from exception handling problem that
happened to show up in the same test case from oss-fuzz #25321.
Now both issues should be fixed.
2020-09-02 10:52:55 +02:00
Nikita Popov a07c1f56aa Fix infinite loop on string offset during by-ref list assign
There is a deeper underlying issue here, in that the opcodes violate
VM write-fetch safety, but let's fix the infinite loop first.

This fixes oss-fuzz #25352.
2020-09-02 10:16:05 +02:00
Nikita Popov cd2afd99b1 Fix leak on assign concat of array and empty string 2020-08-31 17:05:31 +02:00
Derick Rethans 488e53c18b Fixed test case 2020-08-31 12:31:23 +01:00
Derick Rethans 778902db63 Update timelib to 2018.04 2020-08-31 11:41:41 +01:00
Matteo Beccati 44ade0e875 Fix #80027 Terrible performance using $query->fetch on queries with many bind parameters
Added new flags that allow skipping param_evt(s) that are not used by drivers,
in a backwards and forward compatible manner. Updated the pgsql, mysql, sqlite
and oci drivers to properly use the new flags. I've left out pdo_dblib, which
doesn't have a param_hook, and pdo_firebird, which seems to be using
PARAM_EVT_NORMALIZE in a wrong context (param type vs event type).
2020-08-31 11:03:03 +02:00
Nikita Popov ad750c3bb6 Fix handling of exception if valid() during yield from
Fixes oss-fuzz #25296.
2020-08-31 10:51:31 +02:00
Nikita Popov 376bbbdf3b Make MAX_IFD_NESTING_LEVEL an actual nesting level
Currently we only ever increment ifd_nesting_level, so this ends up
being a limit on the total number of IFD tags and we regularly get
bug reports of it being exceeded. I think the intention behind this
limit was to prevent recursion stack overflow, and for that we only
need to check actual recursive usage. I've implemented that here,
and dropped the nesting limit down to a smaller value
(which still passes our tests).

However, it seems that we do also need to have a total limit on
the number of tags, as we don't catch some instances of infinite
looping otherwise. Add this as a separate limit with a higher
value, that should hopefully be sufficient.

This is expected to fix a number of bugs:

https://bugs.php.net/bug.php?id=78083
https://bugs.php.net/bug.php?id=78701
https://bugs.php.net/bug.php?id=79907
https://bugs.php.net/bug.php?id=80016
2020-08-31 09:28:59 +02:00
twosee e948188832 Improve error_handing replacement functions
We explicitly skip calls to user_error_handler in EH_THROW mode

Closes GH-6050.
2020-08-30 16:24:42 +08:00
Nikita Popov 62dce97973 Require non-negative length in stream_get_contents()
If the length is not -1, require it to be non-negative.

Using such lengths doesn't make sense (as only -1 is special-case
to read in chunks, anything else will end up doing a huge upfront
allocation) and can lead to string allocation overflow.

A similar check is already in place for file_get_contents(). That
one does not allow -1 (and uses null instead), but this function
is explicitly specified to accept -1, so stick to that behavior.
2020-08-27 15:50:49 +02:00
Christoph M. Becker 1b7ee6db88 Fix com_safearray_proxy related memory management issues 2020-08-26 15:39:32 +02:00
Christoph M. Becker 75ac3f1cba Separate COM::__construct()s $server_name array
This may otherwise be modified.
2020-08-26 15:00:02 +02:00
Christoph M. Becker 5ff15e2651 Fix #64130: COM obj parameters passed by reference are not updated
`ITypeInfo_GetIDsOfNames()` is supposed to fail with `E_NOTIMPL` for
out-of-process servers, thus we should not remove the already available
typeinfo of the object in this case.

We also properly free the `byref_vals`.
2020-08-26 14:50:04 +02:00
Nikita Popov d179e34e42 Fix memory leak when yielding from non-iterable 2020-08-26 11:32:01 +02:00
Christoph M. Becker 3324bb893e Avoid double-free
As of commit b2e3fd1[1] the `authid.User` is no longer newly allocated,
so we must not free it.

[1] <http://git.php.net/?p=php-src.git;a=commit;h=b2e3fd1e691b1dc82aaaf4150461db97bd5acf4a>
2020-08-25 13:11:22 +02:00
Nikita Popov 063082043a Remove bogus REGISTER_LONG_CONSTANT
This shouldn't be in this function, probably a copy/paste mistake...
2020-08-25 12:35:38 +02:00
Christoph M. Becker 74de17f2ea Fix potential integer overflow detected by oss-fuzz
We port the respective fix from upstream[1].

[1] <https://github.com/libgd/libgd/commit/9ed642764cf0b4585d135eb738812a43265cb2d3>
2020-08-24 17:35:04 +02:00
Christoph M. Becker 844a2dd6ac Fix #79986: str_ireplace bug with diacritics characters
`tolower()` returns an `int`, so we must not convert to `char` which
may be `signed` and as such may be subject to overflow (actually,
implementation defined behavior).

Closes GH-6007
2020-08-24 11:08:48 +02:00
Christoph M. Becker fcd26ffcc3 Fix #80002: calc free space for new interned string is wrong
We need to calculate the free size in bytes.

Patch contributed by t-matsuno.

Closes GH-6024
2020-08-24 11:03:19 +02:00
Andy Postnikov b2a33ab06b Fix #80007: Potential type confusion in unixtojd() parameter parsing
Also it fixes test on 32-bit armv7 and x86
- Test unixtojd() function : error conditions [ext/calendar/tests/unixtojd_error1.phpt]

Closes GH-6033
2020-08-22 12:30:04 +02:00
Manuel Mausz 46d62e5464 Fix wrong datatype
ini_entry->modifiable is of type uint8_t and so should be the temp. variable. Especially important after 4b77a158.

Closes GH-6028
2020-08-21 15:28:12 +02:00
Matteo Beccati f7c43b8c72 Fix #47021: SoapClient stumbles over WSDL delivered with "Transfer-Encoding: chunked" 2020-08-18 18:10:39 +02:00
Christoph M. Becker ff14b7adad 7.3.23 is next 2020-08-18 09:55:37 +02:00
158 changed files with 23689 additions and 25025 deletions

No files matched your search

+135 -1
View File
@@ -1,6 +1,140 @@
PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ??? ????, PHP 7.3.22
07 Jan 2021, PHP 7.3.26
- Standard:
. Fixed bug #77423 (FILTER_VALIDATE_URL accepts URLs with invalid userinfo).
(CVE-2020-7071) (cmb)
. Fixed bug #80457 (stream_get_contents() fails with maxlength=-1 or default).
(bruno dot premont at restena dot lu)
26 Nov 2020, PHP 7.3.25
- Core:
. Fixed bug #80280 (ADD_EXTENSION_DEP() fails for ext/standard and ext/date).
(cmb)
. Fixed bug #80258 (Windows Deduplication Enabled, randon permission errors).
(cmb)
- COM:
. Fixed bug #62474 (com_event_sink crashes on certain arguments). (cmb)
- DOM:
. Fixed bug #80268 (loadHTML() truncates at NUL bytes). (cmb)
- IMAP:
. Fixed bug #64076 (imap_sort() does not return FALSE on failure). (cmb)
. Fixed bug #76618 (segfault on imap_reopen). (girgias)
. Fixed bug #80239 (imap_rfc822_write_address() leaks memory). (cmb)
. Fixed minor regression caused by fixing bug #80220. (cmb)
. Fixed bug #80242 (imap_mail_compose() segfaults for multipart with rfc822).
(cmb)
- Intl:
. Fixed bug #80310 (ext-intl with icu4c 68.1: use of undeclared identifier
'TRUE'). (Alexander M. Turek)
- ODBC:
. Fixed bug #44618 (Fetching may rely on uninitialized data). (cmb)
- SNMP:
. Fixed bug #70461 (disable md5 code when it is not supported in net-snmp).
(Alexander Bergmann, cmb)
- Standard:
. Fixed bug #80266 (parse_url silently drops port number 0). (cmb, Nikita)
29 Oct 2020, PHP 7.3.24
- Core:
. Fixed bug #79423 (copy command is limited to size of file it can copy).
(cmb)
- Calendar:
. Fixed bug #80185 (jdtounix() fails after 2037). (cmb)
- IMAP:
. Fixed bug #80213 (imap_mail_compose() segfaults on certain $bodies). (cmb)
. Fixed bug #80215 (imap_mail_compose() may modify by-val parameters). (cmb)
. Fixed bug #80220 (imap_mail_compose() may leak memory). (cmb)
. Fixed bug #80223 (imap_mail_compose() leaks envelope on malformed bodies).
(cmb)
. Fixed bug #80216 (imap_mail_compose() does not validate types/encodings).
(cmb)
. Fixed bug #80226 (imap_sort() leaks sortpgm memory). (cmb)
- MySQLnd:
. Fixed bug #80115 (mysqlnd.debug doesn't recognize absolute paths with
slashes). (cmb)
. Fixed bug #80107 (mysqli_query() fails for ~16 MB long query when
compression is enabled). (Nikita)
- ODBC:
. Fixed bug #78470 (odbc_specialcolumns() no longer accepts $nullable). (cmb)
. Fixed bug #80147 (BINARY strings may not be properly zero-terminated).
(cmb)
. Fixed bug #80150 (Failure to fetch error message). (cmb)
. Fixed bug #80152 (odbc_execute() moves internal pointer of $params). (cmb)
. Fixed bug #46050 (odbc_next_result corrupts prepared resource). (cmb)
- OPcache:
. Fixed bug #80083 (Optimizer pass 6 removes variables used for ibm_db2 data
binding). (Nikita)
- PDO_ODBC:
. Fixed bug #67465 (NULL Pointer dereference in odbc_handle_preparer). (cmb)
- Standard:
. Fixed bug #80114 (parse_url does not accept URLs with port 0). (cmb, twosee)
. Fixed bug #76943 (Inconsistent stream_wrapper_restore() errors). (cmb)
. Fixed bug #76735 (Incorrect message in fopen on invalid mode). (cmb)
- Tidy:
. Fixed bug #77040 (tidyNode::isHtml() is completely broken). (cmb)
01 Oct 2020, PHP 7.3.23
- Core:
. Fixed bug #80048 (Bug #69100 has not been fixed for Windows). (cmb)
. Fixed bug #80049 (Memleak when coercing integers to string via variadic
argument). (Nikita)
. Fixed bug #79699 (PHP parses encoded cookie names so malicious `__Host-`
cookies can be sent). (CVE-2020-7070) (Stas)
- Calendar:
. Fixed bug #80007 (Potential type confusion in unixtojd() parameter parsing).
(Andy Postnikov)
- COM:
. Fixed bug #64130 (COM obj parameters passed by reference are not updated).
(cmb)
- OPcache:
. Fixed bug #80002 (calc free space for new interned string is wrong).
(t-matsuno)
. Fixed bug #79825 (opcache.file_cache causes SIGSEGV when custom opcode
handlers changed). (SammyK)
- OpenSSL:
. Fixed bug #79601 (Wrong ciphertext/tag in AES-CCM encryption for a 12
bytes IV). (CVE-2020-7069) (Jakub Zelenka)
- PDO:
. Fixed bug #80027 (Terrible performance using $query->fetch on queries with
many bind parameters). (Matteo)
- SOAP:
. Fixed bug #47021 (SoapClient stumbles over WSDL delivered with
"Transfer-Encoding: chunked"). (Matteo)
- Standard:
. Fixed bug #79986 (str_ireplace bug with diacritics characters). (cmb)
. Fixed bug #80077 (getmxrr test bug). (Rainer Jung)
. Fixed bug #72941 (Modifying bucket->data by-ref has no effect any longer).
(cmb)
. Fixed bug #80067 (Omitting the port in bindto setting errors). (cmb)
03 Sep 2020, PHP 7.3.22
- Core:
. Fixed bug #79884 (PHP_CONFIG_FILE_PATH is meaningless). (cmb)
+5
View File
@@ -151,6 +151,11 @@ Reflection:
. Reflection export to string now uses `int` and `bool` instead of `integer`
and `boolean`.
- SAPI:
. Starting with 7.3.23, incoming cookie names are not url-decoded. This was never
required by the standard, outgoing cookie names aren't encoded and this leads
to security issues (CVE-2020-7070).
SPL:
. If an SPL autoloader throws an exception, following autoloaders will not be
executed. Previously all autoloaders were executed and exceptions were
+5 -4
View File
@@ -116,16 +116,16 @@ int main()
double d = (double) LONG_MIN * LONG_MIN + 2e9;
if ((long) d == 2e9 && (long) -d == -2e9) {
exit(0);
return 0;
}
} else if (sizeof(long) == 8) {
double correct = 18e18 - ((double) LONG_MIN * -2); /* Subtract ULONG_MAX + 1 */
if ((long) 18e18 == correct) { /* On 64-bit, only check between LONG_MAX and ULONG_MAX */
exit(0);
return 0;
}
}
exit(1);
return 1;
}
]])], [
AC_DEFINE([ZEND_DVAL_TO_LVAL_CAST_OK], 1, [Define if double cast to long preserves least significant bits])
@@ -249,7 +249,7 @@ int main()
fprintf(fp, "%d %d\n", ZEND_MM_ALIGNMENT, zeros);
fclose(fp);
exit(0);
return 0;
}
]])], [
LIBZEND_MM_ALIGN=`cat conftest.zend | cut -d ' ' -f 1`
@@ -318,6 +318,7 @@ AC_RUN_IFELSE([AC_LANG_SOURCE([[
#include <sys/mman.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#ifndef MAP_ANON
# ifdef MAP_ANONYMOUS
# define MAP_ANON MAP_ANONYMOUS
+4 -1
View File
@@ -63,7 +63,10 @@ dnl Check for broken sprintf()
dnl
AC_DEFUN([AC_ZEND_BROKEN_SPRINTF],[
AC_CACHE_CHECK(whether sprintf is broken, ac_cv_broken_sprintf,[
AC_RUN_IFELSE([AC_LANG_SOURCE([[main() {char buf[20];exit(sprintf(buf,"testing 123")!=11); }]])],[
AC_RUN_IFELSE([AC_LANG_SOURCE([[
#include <stdio.h>
int main() {char buf[20]; return sprintf(buf,"testing 123")!=11; }
]])],[
ac_cv_broken_sprintf=no
],[
ac_cv_broken_sprintf=yes
+16
View File
@@ -0,0 +1,16 @@
--TEST--
Array addition should not add INDIRECT elements
--FILE--
<?php
$x = 1;
$ary = ['y' => 1];
$ary += $GLOBALS;
var_dump($ary['x']);
$x = 2;
var_dump($ary['x']);
?>
--EXPECT--
int(1)
int(1)
+10
View File
@@ -0,0 +1,10 @@
--TEST--
Add $GLOBALS to itself
--FILE--
<?php
$GLOBALS += $GLOBALS;
$x = $GLOBALS + $GLOBALS;
?>
===DONE===
--EXPECT--
===DONE===
@@ -0,0 +1,13 @@
--TEST--
Assign concat of array and empty string
--FILE--
<?php
$a = [0];
$a .= '';
var_dump($a);
?>
--EXPECTF--
Notice: Array to string conversion in %s on line %d
string(5) "Array"
+14
View File
@@ -0,0 +1,14 @@
--TEST--
Bug #80049: Memleak when coercing integers to string via variadic argument
--FILE--
<?php
function coerceToString(string ...$strings) {
var_dump($strings);
}
coerceToString(...[123]);
?>
--EXPECT--
array(1) {
[0]=>
string(3) "123"
}
@@ -0,0 +1,18 @@
--TEST--
Yield from non-iterable
--FILE--
<?php
function gen() {
yield from new stdClass;
}
try {
gen()->current();
} catch (Error $e) {
echo $e->getMessage(), "\n";
}
?>
--EXPECT--
Can use "yield from" only with arrays and Traversables
@@ -0,0 +1,30 @@
--TEST--
Exception from valid() during yield from
--FILE--
<?php
class FooBar implements Iterator {
function rewind() {}
function current() {}
function key() {}
function next() {}
function valid() {
throw new Exception("Exception from valid()");
}
}
function gen() {
try {
// the fact that the yield from result is used is relevant.
var_dump(yield from new FooBar);
} catch (Exception $e) {
echo $e->getMessage(), "\n";
}
}
$x = gen();
$x->current();
?>
--EXPECT--
Exception from valid()
@@ -0,0 +1,16 @@
--TEST--
String offset error during list() by-ref assignment
--FILE--
<?php
$a = [0];
$v = 'b';
$i = 0;
list(&$a[$i++]) = $v;
?>
--EXPECTF--
Fatal error: Uncaught Error: Cannot create references to/from string offsets in %s:%d
Stack trace:
#0 {main}
thrown in %s on line %d
@@ -6,6 +6,7 @@ No warnings should be thrown during heredoc scan-ahead
<<<TEST
${x}
\400
${"\400"}
${/*}
TEST;
@@ -15,6 +16,8 @@ Warning: Unexpected character in input: '' (ASCII=1) state=0 in %s on line %d
Warning: Octal escape sequence overflow \400 is greater than \377 in %s on line %d
Warning: Octal escape sequence overflow \400 is greater than \377 in %s on line %d
Warning: Unterminated comment starting line %d in %s on line %d
Parse error: syntax error, unexpected end of file in %s on line %d
+1 -1
View File
@@ -20,7 +20,7 @@
#ifndef ZEND_H
#define ZEND_H
#define ZEND_VERSION "3.3.22-dev"
#define ZEND_VERSION "3.3.26"
#define ZEND_ENGINE_3
+4 -41
View File
@@ -4230,7 +4230,7 @@ ZEND_API void zend_save_error_handling(zend_error_handling *current) /* {{{ */
{
current->handling = EG(error_handling);
current->exception = EG(exception_class);
ZVAL_COPY(&current->user_handler, &EG(user_error_handler));
ZVAL_UNDEF(&current->user_handler);
}
/* }}} */
@@ -4238,54 +4238,17 @@ ZEND_API void zend_replace_error_handling(zend_error_handling_t error_handling,
{
if (current) {
zend_save_error_handling(current);
if (error_handling != EH_NORMAL && Z_TYPE(EG(user_error_handler)) != IS_UNDEF) {
zval_ptr_dtor(&EG(user_error_handler));
ZVAL_UNDEF(&EG(user_error_handler));
}
}
ZEND_ASSERT(error_handling == EH_THROW || exception_class == NULL);
EG(error_handling) = error_handling;
EG(exception_class) = error_handling == EH_THROW ? exception_class : NULL;
}
/* }}} */
static int same_zval(zval *zv1, zval *zv2) /* {{{ */
{
if (Z_TYPE_P(zv1) != Z_TYPE_P(zv2)) {
return 0;
}
switch (Z_TYPE_P(zv1)) {
case IS_UNDEF:
case IS_NULL:
case IS_FALSE:
case IS_TRUE:
return 1;
case IS_LONG:
return Z_LVAL_P(zv1) == Z_LVAL_P(zv2);
case IS_DOUBLE:
return Z_LVAL_P(zv1) == Z_LVAL_P(zv2);
case IS_STRING:
case IS_ARRAY:
case IS_OBJECT:
case IS_RESOURCE:
return Z_COUNTED_P(zv1) == Z_COUNTED_P(zv2);
default:
return 0;
}
EG(exception_class) = exception_class;
}
/* }}} */
ZEND_API void zend_restore_error_handling(zend_error_handling *saved) /* {{{ */
{
EG(error_handling) = saved->handling;
EG(exception_class) = saved->handling == EH_THROW ? saved->exception : NULL;
if (Z_TYPE(saved->user_handler) != IS_UNDEF
&& !same_zval(&saved->user_handler, &EG(user_error_handler))) {
zval_ptr_dtor(&EG(user_error_handler));
ZVAL_COPY_VALUE(&EG(user_error_handler), &saved->user_handler);
} else if (Z_TYPE(saved->user_handler)) {
zval_ptr_dtor(&saved->user_handler);
}
ZVAL_UNDEF(&saved->user_handler);
EG(exception_class) = saved->exception;
}
/* }}} */
+4 -1
View File
@@ -666,6 +666,7 @@ ZEND_API void zend_create_closure(zval *res, zend_function *func, zend_class_ent
if (func->type == ZEND_USER_FUNCTION) {
memcpy(&closure->func, func, sizeof(zend_op_array));
closure->func.common.fn_flags |= ZEND_ACC_CLOSURE;
closure->func.common.fn_flags &= ~ZEND_ACC_IMMUTABLE;
if (closure->func.op_array.static_variables) {
closure->func.op_array.static_variables =
zend_array_dup(closure->func.op_array.static_variables);
@@ -676,7 +677,9 @@ ZEND_API void zend_create_closure(zval *res, zend_function *func, zend_class_ent
|| func->common.scope != scope
|| (func->common.fn_flags & ZEND_ACC_NO_RT_ARENA)
) {
if (!func->op_array.run_time_cache && (func->common.fn_flags & ZEND_ACC_CLOSURE)) {
if (!func->op_array.run_time_cache
&& (func->common.fn_flags & ZEND_ACC_CLOSURE)
&& !(func->common.fn_flags & ZEND_ACC_IMMUTABLE)) {
/* If a real closure is used for the first time, we create a shared runtime cache
* and remember which scope it is for. */
func->common.scope = scope;
+1
View File
@@ -1329,6 +1329,7 @@ static zend_never_inline ZEND_COLD void zend_wrong_string_offset(EXECUTE_DATA_D)
msg = "Cannot create references to/from string offsets";
break;
}
opline++;
}
break;
EMPTY_SWITCH_DEFAULT_CASE();
+4 -1
View File
@@ -709,6 +709,9 @@ static int zend_generator_get_next_delegated_value(zend_generator *generator) /*
}
if (iter->funcs->valid(iter) == FAILURE) {
if (UNEXPECTED(EG(exception) != NULL)) {
goto exception;
}
/* reached end of iteration */
goto failure;
}
@@ -737,7 +740,7 @@ static int zend_generator_get_next_delegated_value(zend_generator *generator) /*
return SUCCESS;
exception:
zend_rethrow_exception(generator->execute_data);
zend_generator_throw_exception(generator, NULL);
failure:
zval_ptr_dtor(&generator->values);
+17 -13
View File
@@ -1999,7 +1999,7 @@ ZEND_API void ZEND_FASTCALL zend_hash_merge(HashTable *target, HashTable *source
{
uint32_t idx;
Bucket *p;
zval *t;
zval *t, *s;
IS_CONSISTENT(source);
IS_CONSISTENT(target);
@@ -2008,18 +2008,20 @@ ZEND_API void ZEND_FASTCALL zend_hash_merge(HashTable *target, HashTable *source
if (overwrite) {
for (idx = 0; idx < source->nNumUsed; idx++) {
p = source->arData + idx;
if (UNEXPECTED(Z_TYPE(p->val) == IS_UNDEF)) continue;
if (UNEXPECTED(Z_TYPE(p->val) == IS_INDIRECT) &&
UNEXPECTED(Z_TYPE_P(Z_INDIRECT(p->val)) == IS_UNDEF)) {
continue;
s = &p->val;
if (UNEXPECTED(Z_TYPE_P(s) == IS_INDIRECT)) {
s = Z_INDIRECT_P(s);
}
if (UNEXPECTED(Z_TYPE_P(s) == IS_UNDEF)) {
continue;
}
if (p->key) {
t = _zend_hash_add_or_update_i(target, p->key, &p->val, HASH_UPDATE | HASH_UPDATE_INDIRECT);
t = _zend_hash_add_or_update_i(target, p->key, s, HASH_UPDATE | HASH_UPDATE_INDIRECT);
if (pCopyConstructor) {
pCopyConstructor(t);
}
} else {
t = zend_hash_index_update(target, p->h, &p->val);
t = zend_hash_index_update(target, p->h, s);
if (pCopyConstructor) {
pCopyConstructor(t);
}
@@ -2028,18 +2030,20 @@ ZEND_API void ZEND_FASTCALL zend_hash_merge(HashTable *target, HashTable *source
} else {
for (idx = 0; idx < source->nNumUsed; idx++) {
p = source->arData + idx;
if (UNEXPECTED(Z_TYPE(p->val) == IS_UNDEF)) continue;
if (UNEXPECTED(Z_TYPE(p->val) == IS_INDIRECT) &&
UNEXPECTED(Z_TYPE_P(Z_INDIRECT(p->val)) == IS_UNDEF)) {
continue;
s = &p->val;
if (UNEXPECTED(Z_TYPE_P(s) == IS_INDIRECT)) {
s = Z_INDIRECT_P(s);
}
if (UNEXPECTED(Z_TYPE_P(s) == IS_UNDEF)) {
continue;
}
if (p->key) {
t = _zend_hash_add_or_update_i(target, p->key, &p->val, HASH_ADD | HASH_UPDATE_INDIRECT);
t = _zend_hash_add_or_update_i(target, p->key, s, HASH_ADD | HASH_UPDATE_INDIRECT);
if (t && pCopyConstructor) {
pCopyConstructor(t);
}
} else {
t = zend_hash_index_add(target, p->h, &p->val);
t = zend_hash_index_add(target, p->h, s);
if (t && pCopyConstructor) {
pCopyConstructor(t);
}
+1 -1
View File
@@ -334,7 +334,7 @@ ZEND_API int zend_alter_ini_entry_ex(zend_string *name, zend_string *new_value,
{
zend_ini_entry *ini_entry;
zend_string *duplicate;
zend_bool modifiable;
uint8_t modifiable;
zend_bool modified;
if ((ini_entry = zend_hash_find_ptr(EG(ini_directives), name)) == NULL) {
File diff suppressed because it is too large. Load diff
+1 -2
View File
@@ -1066,8 +1066,7 @@ static int zend_scan_escape_string(zval *zendlval, char *str, int len, char quot
octal_buf[2] = *(++s);
}
}
if (octal_buf[2] &&
(octal_buf[0] > '3')) {
if (octal_buf[2] && (octal_buf[0] > '3') && !SCNG(heredoc_scan_ahead)) {
/* 3 octit values must not overflow 0xFF (\377) */
zend_error(E_COMPILE_WARNING, "Octal escape sequence overflow \\%s is greater than \\377", octal_buf);
}
+4 -1
View File
@@ -903,7 +903,7 @@ try_again:
static zend_never_inline void ZEND_FASTCALL add_function_array(zval *result, zval *op1, zval *op2) /* {{{ */
{
if ((result == op1) && (result == op2)) {
if (result == op1 && Z_ARR_P(op1) == Z_ARR_P(op2)) {
/* $a += $a */
return;
}
@@ -1836,6 +1836,9 @@ ZEND_API int ZEND_FASTCALL concat_function(zval *result, zval *op1, zval *op2) /
}
} else if (UNEXPECTED(Z_STRLEN_P(op2) == 0)) {
if (EXPECTED(result != op1)) {
if (result == orig_op1) {
i_zval_ptr_dtor(result ZEND_FILE_LINE_CC);
}
ZVAL_COPY(result, op1);
}
} else {
+12 -8
View File
@@ -186,12 +186,13 @@ static zend_always_inline zend_string *zend_string_realloc(zend_string *s, size_
ZSTR_LEN(ret) = len;
zend_string_forget_hash_val(ret);
return ret;
} else {
GC_DELREF(s);
}
}
ret = zend_string_alloc(len, persistent);
memcpy(ZSTR_VAL(ret), ZSTR_VAL(s), MIN(len, ZSTR_LEN(s)) + 1);
if (!ZSTR_IS_INTERNED(s)) {
GC_DELREF(s);
}
return ret;
}
@@ -206,12 +207,13 @@ static zend_always_inline zend_string *zend_string_extend(zend_string *s, size_t
ZSTR_LEN(ret) = len;
zend_string_forget_hash_val(ret);
return ret;
} else {
GC_DELREF(s);
}
}
ret = zend_string_alloc(len, persistent);
memcpy(ZSTR_VAL(ret), ZSTR_VAL(s), ZSTR_LEN(s) + 1);
if (!ZSTR_IS_INTERNED(s)) {
GC_DELREF(s);
}
return ret;
}
@@ -226,12 +228,13 @@ static zend_always_inline zend_string *zend_string_truncate(zend_string *s, size
ZSTR_LEN(ret) = len;
zend_string_forget_hash_val(ret);
return ret;
} else {
GC_DELREF(s);
}
}
ret = zend_string_alloc(len, persistent);
memcpy(ZSTR_VAL(ret), ZSTR_VAL(s), len + 1);
if (!ZSTR_IS_INTERNED(s)) {
GC_DELREF(s);
}
return ret;
}
@@ -245,12 +248,13 @@ static zend_always_inline zend_string *zend_string_safe_realloc(zend_string *s,
ZSTR_LEN(ret) = (n * m) + l;
zend_string_forget_hash_val(ret);
return ret;
} else {
GC_DELREF(s);
}
}
ret = zend_string_safe_alloc(n, m, l, persistent);
memcpy(ZSTR_VAL(ret), ZSTR_VAL(s), MIN((n * m) + l, ZSTR_LEN(s)) + 1);
if (!ZSTR_IS_INTERNED(s)) {
GC_DELREF(s);
}
return ret;
}
+4 -1
View File
@@ -747,6 +747,7 @@ static size_t tsrm_realpath_r(char *path, size_t start, size_t len, int *ll, tim
HANDLE hFind = INVALID_HANDLE_VALUE;
ALLOCA_FLAG(use_heap_large)
wchar_t *pathw = NULL;
int may_retry_reparse_point;
#define FREE_PATHW() \
do { free(pathw); } while(0);
@@ -846,6 +847,7 @@ static size_t tsrm_realpath_r(char *path, size_t start, size_t len, int *ll, tim
#ifdef ZEND_WIN32
retry_reparse_point:
may_retry_reparse_point = 0;
if (save) {
pathw = php_win32_ioutil_any_to_w(path);
if (!pathw) {
@@ -940,6 +942,7 @@ retry_reparse_tag_cloud:
CloseHandle(hLink);
if(pbuffer->ReparseTag == IO_REPARSE_TAG_SYMLINK) {
may_retry_reparse_point = 1;
reparsetarget = pbuffer->SymbolicLinkReparseBuffer.ReparseTarget;
isabsolute = (pbuffer->SymbolicLinkReparseBuffer.Flags == 0) ? 1 : 0;
#if VIRTUAL_CWD_DEBUG
@@ -1076,7 +1079,7 @@ retry_reparse_tag_cloud:
free_alloca(pbuffer, use_heap_large);
free(substitutename);
{
if (may_retry_reparse_point) {
DWORD attrs;
FREE_PATHW()
+2 -9
View File
@@ -4819,6 +4819,7 @@ ZEND_VM_HANDLER(164, ZEND_RECV_VARIADIC, NUM, UNUSED|CACHE_SLOT)
ZEND_HASH_FILL_PACKED(Z_ARRVAL_P(params)) {
param = EX_VAR_NUM(EX(func)->op_array.last_var + EX(func)->op_array.T);
if (UNEXPECTED((EX(func)->op_array.fn_flags & ZEND_ACC_HAS_TYPE_HINTS) != 0)) {
ZEND_ADD_CALL_FLAG(execute_data, ZEND_CALL_FREE_EXTRA_ARGS);
do {
zend_verify_arg_type(EX(func), arg_num, param, NULL, CACHE_ADDR(opline->op2.num));
if (Z_OPT_REFCOUNTED_P(param)) Z_ADDREF_P(param);
@@ -7096,15 +7097,6 @@ ZEND_VM_HANDLER(153, ZEND_DECLARE_LAMBDA_FUNCTION, CONST, UNUSED)
zfunc = zend_hash_find_ex(EG(function_table), Z_STR_P(RT_CONSTANT(opline, opline->op1)), 1);
ZEND_ASSERT(zfunc != NULL && Z_FUNC_P(zfunc)->type == ZEND_USER_FUNCTION);
fbc = Z_PTR_P(zfunc);
if (fbc->common.fn_flags & ZEND_ACC_IMMUTABLE) {
zend_function *new_func = zend_arena_alloc(&CG(arena), sizeof(zend_op_array));
memcpy(new_func, fbc, sizeof(zend_op_array));
new_func->common.fn_flags &= ~ZEND_ACC_IMMUTABLE;
Z_PTR_P(zfunc) = fbc = new_func;
}
if (Z_TYPE(EX(This)) == IS_OBJECT) {
called_scope = Z_OBJCE(EX(This));
if (UNEXPECTED((Z_FUNC_P(zfunc)->common.fn_flags & ZEND_ACC_STATIC) ||
@@ -7371,6 +7363,7 @@ ZEND_VM_HANDLER(142, ZEND_YIELD_FROM, CONST|TMP|VAR|CV, ANY)
}
} else {
zend_throw_error(NULL, "Can use \"yield from\" only with arrays and Traversables");
FREE_OP1();
UNDEF_RESULT();
HANDLE_EXCEPTION();
}
+5 -9
View File
@@ -2375,6 +2375,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_RECV_VARIADIC_SPEC_UNUSED_HAND
ZEND_HASH_FILL_PACKED(Z_ARRVAL_P(params)) {
param = EX_VAR_NUM(EX(func)->op_array.last_var + EX(func)->op_array.T);
if (UNEXPECTED((EX(func)->op_array.fn_flags & ZEND_ACC_HAS_TYPE_HINTS) != 0)) {
ZEND_ADD_CALL_FLAG(execute_data, ZEND_CALL_FREE_EXTRA_ARGS);
do {
zend_verify_arg_type(EX(func), arg_num, param, NULL, CACHE_ADDR(opline->op2.num));
if (Z_OPT_REFCOUNTED_P(param)) Z_ADDREF_P(param);
@@ -3707,6 +3708,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_YIELD_FROM_SPEC_CONST_HANDLER(
}
} else {
zend_throw_error(NULL, "Can use \"yield from\" only with arrays and Traversables");
UNDEF_RESULT();
HANDLE_EXCEPTION();
}
@@ -9207,15 +9209,6 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_DECLARE_LAMBDA_FUNCTION_SPEC_C
zfunc = zend_hash_find_ex(EG(function_table), Z_STR_P(RT_CONSTANT(opline, opline->op1)), 1);
ZEND_ASSERT(zfunc != NULL && Z_FUNC_P(zfunc)->type == ZEND_USER_FUNCTION);
fbc = Z_PTR_P(zfunc);
if (fbc->common.fn_flags & ZEND_ACC_IMMUTABLE) {
zend_function *new_func = zend_arena_alloc(&CG(arena), sizeof(zend_op_array));
memcpy(new_func, fbc, sizeof(zend_op_array));
new_func->common.fn_flags &= ~ZEND_ACC_IMMUTABLE;
Z_PTR_P(zfunc) = fbc = new_func;
}
if (Z_TYPE(EX(This)) == IS_OBJECT) {
called_scope = Z_OBJCE(EX(This));
if (UNEXPECTED((Z_FUNC_P(zfunc)->common.fn_flags & ZEND_ACC_STATIC) ||
@@ -18346,6 +18339,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_YIELD_FROM_SPEC_TMP_HANDLER(ZE
}
} else {
zend_throw_error(NULL, "Can use \"yield from\" only with arrays and Traversables");
zval_ptr_dtor_nogc(free_op1);
UNDEF_RESULT();
HANDLE_EXCEPTION();
}
@@ -21672,6 +21666,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_YIELD_FROM_SPEC_VAR_HANDLER(ZE
}
} else {
zend_throw_error(NULL, "Can use \"yield from\" only with arrays and Traversables");
zval_ptr_dtor_nogc(free_op1);
UNDEF_RESULT();
HANDLE_EXCEPTION();
}
@@ -37896,6 +37891,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_YIELD_FROM_SPEC_CV_HANDLER(ZEN
}
} else {
zend_throw_error(NULL, "Can use \"yield from\" only with arrays and Traversables");
UNDEF_RESULT();
HANDLE_EXCEPTION();
}
+22 -18
View File
@@ -1209,14 +1209,14 @@ AC_DEFUN([PHP_DOES_PWRITE_WORK],[
#include <unistd.h>
#include <errno.h>
$1
main() {
int main() {
int fd = open("conftest_in", O_WRONLY|O_CREAT, 0600);
if (fd < 0) exit(1);
if (pwrite(fd, "text", 4, 0) != 4) exit(1);
if (fd < 0) return 1;
if (pwrite(fd, "text", 4, 0) != 4) return 1;
/* Linux glibc breakage until 2.2.5 */
if (pwrite(fd, "text", 4, -1) != -1 || errno != EINVAL) exit(1);
exit(0);
if (pwrite(fd, "text", 4, -1) != -1 || errno != EINVAL) return 1;
return 0;
}
]])],[
@@ -1239,14 +1239,14 @@ AC_DEFUN([PHP_DOES_PREAD_WORK],[
#include <unistd.h>
#include <errno.h>
$1
main() {
int main() {
char buf[3];
int fd = open("conftest_in", O_RDONLY);
if (fd < 0) exit(1);
if (pread(fd, buf, 2, 0) != 2) exit(1);
if (fd < 0) return 1;
if (pread(fd, buf, 2, 0) != 2) return 1;
/* Linux glibc breakage until 2.2.5 */
if (pread(fd, buf, 2, -1) != -1 || errno != EINVAL) exit(1);
exit(0);
if (pread(fd, buf, 2, -1) != -1 || errno != EINVAL) return 1;
return 0;
}
]])],[
ac_cv_pread=yes
@@ -1347,25 +1347,26 @@ AC_DEFUN([PHP_READDIR_R_TYPE],[
#define _REENTRANT
#include <sys/types.h>
#include <dirent.h>
#include <unistd.h>
#ifndef PATH_MAX
#define PATH_MAX 1024
#endif
main() {
int main() {
DIR *dir;
char entry[sizeof(struct dirent)+PATH_MAX];
struct dirent *pentry = (struct dirent *) &entry;
dir = opendir("/");
if (!dir)
exit(1);
return 1;
if (readdir_r(dir, (struct dirent *) entry, &pentry) == 0) {
close(dir);
exit(0);
return 0;
}
close(dir);
exit(1);
return 1;
}
]])],[
ac_cv_what_readdir_r=POSIX
@@ -1693,6 +1694,7 @@ AC_DEFUN([PHP_BROKEN_GLIBC_FOPEN_APPEND], [
AC_CACHE_VAL(_cv_have_broken_glibc_fopen_append,[
AC_RUN_IFELSE([AC_LANG_SOURCE([[
#include <stdio.h>
#include <unistd.h>
int main(int argc, char *argv[])
{
FILE *fp;
@@ -1702,7 +1704,7 @@ int main(int argc, char *argv[])
fp = fopen(filename, "w");
if (fp == NULL) {
perror("fopen");
exit(2);
return 2;
}
fputs("foobar", fp);
fclose(fp);
@@ -1812,13 +1814,13 @@ int seeker(void *cookie, __off64_t *position, int whence)
cookie_io_functions_t funcs = {reader, writer, seeker, closer};
main() {
int main() {
struct cookiedata g = { 0 };
FILE *fp = fopencookie(&g, "r", funcs);
if (fp && fseek(fp, 8192, SEEK_SET) == 0 && g.pos == 8192)
exit(0);
exit(1);
return 0;
return 1;
}
]])], [
@@ -2252,6 +2254,8 @@ AC_DEFUN([PHP_SETUP_ICU],[
fi
fi
fi
ICU_CFLAGS="$ICU_CFLAGS -DU_DEFINE_FALSE_AND_TRUE=1"
])
dnl
+1 -5
View File
@@ -978,10 +978,6 @@ else
# endif
#endif
#ifdef __cplusplus
extern "C" void exit (int);
#endif
void fnord() { int i=42;}
int main ()
{
@@ -997,7 +993,7 @@ int main ()
else
puts (dlerror ());
exit (status);
return (status);
}]
EOF
if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} 2>/dev/null; then
+8 -7
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=22
PHP_EXTRA_VERSION="-dev"
PHP_RELEASE_VERSION=26
PHP_EXTRA_VERSION=""
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`
@@ -716,6 +716,7 @@ dnl Also check for working getaddrinfo
AC_CACHE_CHECK([for getaddrinfo], ac_cv_func_getaddrinfo,
[AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <netdb.h>]],
[[struct addrinfo *g,h;g=&h;getaddrinfo("","",g,&g);]])],[AC_RUN_IFELSE([AC_LANG_SOURCE([[
#include <string.h>
#include <netdb.h>
#include <sys/types.h>
#ifndef AF_INET
@@ -728,11 +729,11 @@ int main(void) {
hints.ai_flags = AI_NUMERICHOST;
if (getaddrinfo("127.0.0.1", 0, &hints, &ai) < 0) {
exit(1);
return 1;
}
if (ai == 0) {
exit(1);
return 1;
}
pai = ai;
@@ -740,16 +741,16 @@ int main(void) {
while (pai) {
if (pai->ai_family != AF_INET) {
/* 127.0.0.1/NUMERICHOST should only resolve ONE way */
exit(1);
return 1;
}
if (pai->ai_addr->sa_family != AF_INET) {
/* 127.0.0.1/NUMERICHOST should only resolve ONE way */
exit(1);
return 1;
}
pai = pai->ai_next;
}
freeaddrinfo(ai);
exit(0);
return 0;
}
]])],[ac_cv_func_getaddrinfo=yes], [ac_cv_func_getaddrinfo=no], [ac_cv_func_getaddrinfo=no])],
[ac_cv_func_getaddrinfo=no])])
+2 -2
View File
@@ -83,12 +83,12 @@ bool(false)
resource(%d) of type (stream)
resource(%d) of type (stream)
Warning: fopen(bz_open_002.txt): failed to open stream: Bad file %s in %s on line %d
Warning: fopen(bz_open_002.txt): failed to open stream: `br' is not a valid mode for fopen in %s on line %d
Warning: bzopen(): first parameter has to be string or file-resource in %s on line %d
bool(false)
Warning: fopen(bz_open_002.txt): failed to open stream: Bad file %s in %s on line %d
Warning: fopen(bz_open_002.txt): failed to open stream: `br' is not a valid mode for fopen in %s on line %d
Warning: bzopen(): first parameter has to be string or file-resource in %s on line %d
bool(false)
+10 -5
View File
@@ -23,20 +23,25 @@
#include "sdncal.h"
#include <time.h>
#define SECS_PER_DAY (24 * 3600)
/* {{{ proto int unixtojd([int timestamp])
Convert UNIX timestamp to Julian Day */
PHP_FUNCTION(unixtojd)
{
time_t ts = 0;
zend_long tl = 0;
struct tm *ta, tmbuf;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l", &ts) == FAILURE) {
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l", &tl) == FAILURE) {
return;
}
if (!ts) {
if (!tl) {
ts = time(NULL);
} else if (ts < 0) {
} else if (tl >= 0) {
ts = (time_t) tl;
} else {
RETURN_FALSE;
}
@@ -59,11 +64,11 @@ PHP_FUNCTION(jdtounix)
}
uday -= 2440588 /* J.D. of 1.1.1970 */;
if (uday < 0 || uday > 24755) { /* before beginning of unix epoch or behind end of unix epoch */
if (uday < 0 || uday > ZEND_LONG_MAX / SECS_PER_DAY) { /* before beginning of unix epoch or greater than representable */
RETURN_FALSE;
}
RETURN_LONG(uday * 24 * 3600);
RETURN_LONG(uday * SECS_PER_DAY);
}
/* }}} */
+17
View File
@@ -0,0 +1,17 @@
--TEST--
Bug #80185 (jdtounix() fails after 2037)
--SKIPIF--
<?php
if (!extension_loaded('calendar')) die('skip ext/calendar required');
if (PHP_INT_SIZE != 8) die("skip for 64bit platforms only");
?>
--FILE--
<?php
var_dump(jdtounix(2465712));
var_dump(jdtounix(PHP_INT_MAX / 86400 + 2440588));
var_dump(jdtounix(PHP_INT_MAX / 86400 + 2440589));
?>
--EXPECT--
int(2170713600)
int(9223372036854720000)
bool(false)
+17
View File
@@ -0,0 +1,17 @@
--TEST--
Bug #80185 (jdtounix() fails after 2037)
--SKIPIF--
<?php
if (!extension_loaded('calendar')) die('skip ext/calendar required');
if (PHP_INT_SIZE != 4) die("skip for 32bit platforms only");
?>
--FILE--
<?php
var_dump(jdtounix(2465712));
var_dump(jdtounix(PHP_INT_MAX / 86400 + 2440588));
var_dump(jdtounix(PHP_INT_MAX / 86400 + 2440589));
?>
--EXPECT--
bool(false)
int(2147472000)
bool(false)
+4 -3
View File
@@ -61,7 +61,7 @@ PHP_FUNCTION(com_create_instance)
&module_name, &module_name_len, &server_name, &server_name_len,
&cp, &typelib_name, &typelib_name_len) &&
FAILURE == zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET,
ZEND_NUM_ARGS(), "sa|ls",
ZEND_NUM_ARGS(), "sa/|ls",
&module_name, &module_name_len, &server_params, &cp,
&typelib_name, &typelib_name_len)) {
@@ -221,7 +221,6 @@ PHP_FUNCTION(com_create_instance)
if (server_name) {
if (info.pwszName) efree(info.pwszName);
if (authid.User) efree(authid.User);
}
efree(moniker);
@@ -440,8 +439,9 @@ HRESULT php_com_get_id_of_name(php_com_dotnet_object *obj, char *name,
if (obj->typeinfo) {
hr = ITypeInfo_GetIDsOfNames(obj->typeinfo, &olename, 1, dispid);
if (FAILED(hr)) {
HRESULT hr1 = hr;
hr = IDispatch_GetIDsOfNames(V_DISPATCH(&obj->v), &IID_NULL, &olename, 1, LOCALE_SYSTEM_DEFAULT, dispid);
if (SUCCEEDED(hr)) {
if (SUCCEEDED(hr) && hr1 != E_NOTIMPL) {
/* fall back on IDispatch direct */
ITypeInfo_Release(obj->typeinfo);
obj->typeinfo = NULL;
@@ -589,6 +589,7 @@ int php_com_do_invoke_byref(php_com_dotnet_object *obj, zend_internal_function *
}
}
efree(vargs);
if (byref_vals) efree(byref_vals);
}
return SUCCEEDED(hr) ? SUCCESS : FAILURE;
+4 -2
View File
@@ -114,6 +114,8 @@ static zval *saproxy_read_dimension(zval *object, zval *offset, int type, zval *
Z_STRLEN(proxy->indices[0]), DISPATCH_METHOD|DISPATCH_PROPERTYGET, &v,
proxy->dimensions, args, 0);
efree(args);
if (res == SUCCESS) {
php_com_zval_from_variant(rv, &v, proxy->obj->code_page);
VariantClear(&v);
@@ -387,7 +389,7 @@ static zend_object* saproxy_clone(zval *object)
memcpy(cloneproxy, proxy, sizeof(*cloneproxy));
Z_ADDREF_P(cloneproxy->zobj);
cloneproxy->indices = safe_emalloc(cloneproxy->dimensions, sizeof(zval *), 0);
cloneproxy->indices = safe_emalloc(cloneproxy->dimensions, sizeof(zval), 0);
clone_indices(cloneproxy, proxy, proxy->dimensions);
return &cloneproxy->std;
@@ -437,7 +439,7 @@ int php_com_saproxy_create(zval *com_object, zval *proxy_out, zval *index)
}
Z_ADDREF_P(proxy->zobj);
proxy->indices = safe_emalloc(proxy->dimensions, sizeof(zval *), 0);
proxy->indices = safe_emalloc(proxy->dimensions, sizeof(zval), 0);
if (rel) {
clone_indices(proxy, rel, rel->dimensions);
+23 -19
View File
@@ -267,18 +267,20 @@ ITypeInfo *php_com_locate_typeinfo(char *typelibname, php_com_dotnet_object *obj
if (obj) {
if (dispname == NULL && sink) {
IProvideClassInfo2 *pci2;
IProvideClassInfo *pci;
if (V_VT(&obj->v) == VT_DISPATCH) {
IProvideClassInfo2 *pci2;
IProvideClassInfo *pci;
if (SUCCEEDED(IDispatch_QueryInterface(V_DISPATCH(&obj->v), &IID_IProvideClassInfo2, (void**)&pci2))) {
gotguid = SUCCEEDED(IProvideClassInfo2_GetGUID(pci2, GUIDKIND_DEFAULT_SOURCE_DISP_IID, &iid));
IProvideClassInfo2_Release(pci2);
}
if (!gotguid && SUCCEEDED(IDispatch_QueryInterface(V_DISPATCH(&obj->v), &IID_IProvideClassInfo, (void**)&pci))) {
/* examine the available interfaces */
/* TODO: write some code here */
php_error_docref(NULL, E_WARNING, "IProvideClassInfo: this code not yet written!");
IProvideClassInfo_Release(pci);
if (SUCCEEDED(IDispatch_QueryInterface(V_DISPATCH(&obj->v), &IID_IProvideClassInfo2, (void**)&pci2))) {
gotguid = SUCCEEDED(IProvideClassInfo2_GetGUID(pci2, GUIDKIND_DEFAULT_SOURCE_DISP_IID, &iid));
IProvideClassInfo2_Release(pci2);
}
if (!gotguid && SUCCEEDED(IDispatch_QueryInterface(V_DISPATCH(&obj->v), &IID_IProvideClassInfo, (void**)&pci))) {
/* examine the available interfaces */
/* TODO: write some code here */
php_error_docref(NULL, E_WARNING, "IProvideClassInfo: this code not yet written!");
IProvideClassInfo_Release(pci);
}
}
} else if (dispname == NULL) {
if (obj->typeinfo) {
@@ -295,15 +297,17 @@ ITypeInfo *php_com_locate_typeinfo(char *typelibname, php_com_dotnet_object *obj
/* get the library from the object; the rest will be dealt with later */
ITypeInfo_GetContainingTypeLib(obj->typeinfo, &typelib, &idx);
} else if (typelibname == NULL) {
IDispatch_GetTypeInfo(V_DISPATCH(&obj->v), 0, LANG_NEUTRAL, &typeinfo);
if (dispname) {
unsigned int idx;
/* get the library from the object; the rest will be dealt with later */
ITypeInfo_GetContainingTypeLib(typeinfo, &typelib, &idx);
if (V_VT(&obj->v) == VT_DISPATCH) {
IDispatch_GetTypeInfo(V_DISPATCH(&obj->v), 0, LANG_NEUTRAL, &typeinfo);
if (dispname) {
unsigned int idx;
/* get the library from the object; the rest will be dealt with later */
ITypeInfo_GetContainingTypeLib(typeinfo, &typelib, &idx);
if (typelib) {
ITypeInfo_Release(typeinfo);
typeinfo = NULL;
if (typelib) {
ITypeInfo_Release(typeinfo);
typeinfo = NULL;
}
}
}
}
+14
View File
@@ -0,0 +1,14 @@
--TEST--
Bug #62474 (com_event_sink crashes on certain arguments)
--SKIPIF--
<?php
if (!extension_loaded('com_dotnet')) die('skip com_dotnet extension not available');
?>
--FILE--
<?php
var_dump(com_event_sink(new variant, function() {}, array()));
var_dump(com_event_sink(new variant, new variant, 'a'));
?>
--EXPECT--
bool(false)
bool(false)
+27
View File
@@ -0,0 +1,27 @@
--TEST--
Bug #64130 (COM obj parameters passed by reference are not updated)
--SKIPIF--
<?php
if (!extension_loaded('com_dotnet')) die('skip com_dotnet extension not available');
if (PHP_INT_SIZE != 4) die('skip for 32bit platforms only');
try {
$ie = new com('InternetExplorer.Application');
} catch (com_exception $ex) {
die("skip {$ex->getMessage()}");
}
$ie->quit();
?>
--FILE--
<?php
$ie = new com('InternetExplorer.Application');
$x = 0;
$y = 0;
try {
$ie->clientToWindow($x, $y);
} catch (com_exception $ex) {}
var_dump($x > 0, $y > 0);
$ie->quit();
?>
--EXPECT--
bool(true)
bool(true)
+4 -4
View File
@@ -7,7 +7,7 @@ TestFest 2009 - AFUP - Perrick Penet <perrick@noparking.net>
--FILE--
<?php
$url = uniqid()."://www.".uniqid().".".uniqid();
$url = substr(uniqid(),0,7)."://www.".uniqid().".".uniqid();
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
@@ -18,6 +18,6 @@ curl_close($ch);
?>
--EXPECTREGEX--
string\(\d+\) "([^\r\n]*rotocol[^\r\n]+|Could not resolve host: .+)"
int\(\d\)
--EXPECTF--
string(%d) "%Srotocol%s"
int(1)
+1
View File
@@ -1,6 +1,7 @@
// vim:ft=javascript
EXTENSION("date", "php_date.c", false, "/Iext/date/lib /DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 /DHAVE_TIMELIB_CONFIG_H=1");
PHP_DATE = "yes";
ADD_SOURCES("ext/date/lib", "astro.c timelib.c dow.c parse_date.c parse_tz.c tm2unixtime.c unixtime2tm.c parse_iso_intervals.c interval.c", "date");
AC_DEFINE('HAVE_DATE', 1, 'Have date/time support');
+20028 -22817
View File
File diff suppressed because it is too large. Load diff
+1 -1
View File
@@ -1001,7 +1001,7 @@ reltextnumber = 'first'|'second'|'third'|'fourth'|'fifth'|'sixth'|'seventh'|'eig
reltexttext = 'next'|'last'|'previous'|'this';
reltextunit = 'ms' | 'µs' | (('msec'|'millisecond'|'µsec'|'microsecond'|'usec'|'sec'|'second'|'min'|'minute'|'hour'|'day'|'fortnight'|'forthnight'|'month'|'year') 's'?) | 'weeks' | daytext;
relnumber = ([+-]*[ \t]*[0-9]+);
relnumber = ([+-]*[ \t]*[0-9]{1,13});
relative = relnumber space? (reltextunit | 'week' );
relativetext = (reltextnumber|reltexttext) space reltextunit;
relativetextweek = reltexttext space 'week';
File diff suppressed because it is too large. Load diff
+3 -3
View File
@@ -322,9 +322,9 @@ typedef struct _timelib_tzdb {
# define timelib_free free
#endif
#define TIMELIB_VERSION 201803
#define TIMELIB_EXTENDED_VERSION 20180301
#define TIMELIB_ASCII_VERSION "2018.03"
#define TIMELIB_VERSION 201804
#define TIMELIB_EXTENDED_VERSION 20180401
#define TIMELIB_ASCII_VERSION "2018.04"
#define TIMELIB_NONE 0x00
#define TIMELIB_OVERRIDE_TIME 0x01
+795 -923
View File
File diff suppressed because it is too large. Load diff
+8
View File
@@ -367,6 +367,14 @@ static timelib_sll do_years(timelib_sll year)
timelib_sll eras;
eras = (year - 1970) / 40000;
/* Hack to make sure we don't overflow. Right now, we can't easily thrown a
* warning in this case, so we'll just return some rubbish. Sucks, but at
* least it doesn't show UBSAN warnings anymore */
if (eras < -1000000 || eras > 1000000) {
return eras > 0 ? LLONG_MAX/10 : LLONG_MIN/10;
}
if (eras != 0) {
year = year - (eras * 40000);
res += (SECS_PER_ERA * eras * 100);
+3 -3
View File
@@ -6,12 +6,12 @@ Handling of large year values
<?php
date_default_timezone_set("America/Toronto");
$t = mktime(0,0,0,1,1,292277026596);
$t = mktime(0,0,0,1,1,2922770265);
var_dump(date("r", $t));
echo "OK\n";
?>
--EXPECT--
string(39) "Fri, 01 Jan 292277026596 00:00:00 -0500"
--EXPECTF--
string(%d) "%s, 01 Jan 2922770265 00:00:00 -0500"
OK
+7 -7
View File
@@ -4,7 +4,7 @@ Bug #48097 (date_timezone_set function produces wrong datetime result)
date.timezone=UTC
--FILE--
<?php
$d = date_create( "Mon, 23 May 1955 00:00:00 +0200" );
$d = date_create( "Sun, 22 May 1955 02:00:00 +0200" );
var_dump( $d );
echo $d->format( DATE_ISO8601 ), "\n";
echo $d->format( 'U' ), "\n\n";
@@ -16,23 +16,23 @@ echo $d->format( 'U' ), "\n\n";
--EXPECT--
object(DateTime)#1 (3) {
["date"]=>
string(26) "1955-05-23 00:00:00.000000"
string(26) "1955-05-22 02:00:00.000000"
["timezone_type"]=>
int(1)
["timezone"]=>
string(6) "+02:00"
}
1955-05-23T00:00:00+0200
-461124000
1955-05-22T02:00:00+0200
-461203200
object(DateTime)#1 (3) {
["date"]=>
string(26) "1955-05-22 23:00:00.000000"
string(26) "1955-05-22 01:00:00.000000"
["timezone_type"]=>
int(3)
["timezone"]=>
string(15) "Europe/Budapest"
}
1955-05-22T23:00:00+0100
1955-05-22T01:00:00+0100
-461124000
-461203200
-1
View File
@@ -2024,7 +2024,6 @@ static void dom_load_html(INTERNAL_FUNCTION_PARAMETERS, int mode) /* {{{ */
}
ctxt = htmlCreateFileParserCtxt(source, NULL);
} else {
source_len = xmlStrlen((xmlChar *) source);
if (ZEND_SIZE_T_INT_OVFL(source_len)) {
php_error_docref(NULL, E_WARNING, "Input string is too long");
RETURN_FALSE;
+24
View File
@@ -0,0 +1,24 @@
--TEST--
Bug #80268 (loadHTML() truncates at NUL bytes)
--SKIPIF--
<?php require_once('skipif.inc'); ?>
--FILE--
<?php
$doc = new DOMDocument;
$doc->loadHTML("<p>foo\0bar</p>");
$html = $doc->saveHTML();
var_dump(strpos($html, '<p>foo</p>') !== false);
file_put_contents(__DIR__ . '/80268.html', "<p>foo\0bar</p>");
$doc = new DOMDocument;
$doc->loadHTMLFile(__DIR__ . '/80268.html');
$html = $doc->saveHTML();
var_dump(strpos($html, '<p>foo</p>') !== false);
?>
--CLEAN--
<?php
unlink(__DIR__ . '/80268.html');
?>
--EXPECT--
bool(true)
bool(true)
+40 -16
View File
@@ -66,7 +66,8 @@ typedef unsigned char uchar;
#define EFREE_IF(ptr) if (ptr) efree(ptr)
#define MAX_IFD_NESTING_LEVEL 200
#define MAX_IFD_NESTING_LEVEL 10
#define MAX_IFD_TAGS 1000
/* {{{ arginfo */
ZEND_BEGIN_ARG_INFO(arginfo_exif_tagname, 0)
@@ -1940,6 +1941,7 @@ typedef struct {
int read_thumbnail;
int read_all;
int ifd_nesting_level;
int ifd_count;
/* internal */
file_section_list file;
} image_info_type;
@@ -2674,6 +2676,7 @@ static void exif_process_SOFn (uchar *Data, int marker, jpeg_sof_info *result)
/* forward declarations */
static int exif_process_IFD_in_JPEG(image_info_type *ImageInfo, char *dir_start, char *offset_base, size_t IFDlength, size_t displacement, int section_index, int tag);
static int exif_process_IFD_TAG( image_info_type *ImageInfo, char *dir_entry, char *offset_base, size_t IFDlength, size_t displacement, int section_index, int ReadNextIFD, tag_table_type tag_table);
static int exif_process_IFD_in_TIFF(image_info_type *ImageInfo, size_t dir_offset, int section_index);
/* {{{ exif_get_markername
Get name of marker */
@@ -3246,7 +3249,7 @@ static int exif_process_IFD_in_MAKERNOTE(image_info_type *ImageInfo, char * valu
/* {{{ exif_process_IFD_TAG
* Process one of the nested IFDs directories. */
static int exif_process_IFD_TAG(image_info_type *ImageInfo, char *dir_entry, char *offset_base, size_t IFDlength, size_t displacement, int section_index, int ReadNextIFD, tag_table_type tag_table)
static int exif_process_IFD_TAG_impl(image_info_type *ImageInfo, char *dir_entry, char *offset_base, size_t IFDlength, size_t displacement, int section_index, int ReadNextIFD, tag_table_type tag_table)
{
size_t length;
unsigned int tag, format, components;
@@ -3259,13 +3262,6 @@ static int exif_process_IFD_TAG(image_info_type *ImageInfo, char *dir_entry, cha
int dump_free;
#endif /* EXIF_DEBUG */
/* Protect against corrupt headers */
if (ImageInfo->ifd_nesting_level > MAX_IFD_NESTING_LEVEL) {
exif_error_docref("exif_read_data#error_ifd" EXIFERR_CC, ImageInfo, E_WARNING, "corrupt EXIF header: maximum directory nesting level reached");
return FALSE;
}
ImageInfo->ifd_nesting_level++;
tag = php_ifd_get16u(dir_entry, ImageInfo->motorola_intel);
format = php_ifd_get16u(dir_entry+2, ImageInfo->motorola_intel);
components = php_ifd_get32u(dir_entry+4, ImageInfo->motorola_intel);
@@ -3585,6 +3581,24 @@ static int exif_process_IFD_TAG(image_info_type *ImageInfo, char *dir_entry, cha
}
/* }}} */
static int exif_process_IFD_TAG(image_info_type *ImageInfo, char *dir_entry, char *offset_base, size_t IFDlength, size_t displacement, int section_index, int ReadNextIFD, tag_table_type tag_table)
{
int result;
/* Protect against corrupt headers */
if (ImageInfo->ifd_count++ > MAX_IFD_TAGS) {
exif_error_docref("exif_read_data#error_ifd" EXIFERR_CC, ImageInfo, E_WARNING, "corrupt EXIF header: maximum IFD tag count reached");
return FALSE;
}
if (ImageInfo->ifd_nesting_level > MAX_IFD_NESTING_LEVEL) {
exif_error_docref("exif_read_data#error_ifd" EXIFERR_CC, ImageInfo, E_WARNING, "corrupt EXIF header: maximum directory nesting level reached");
return FALSE;
}
ImageInfo->ifd_nesting_level++;
result = exif_process_IFD_TAG_impl(ImageInfo, dir_entry, offset_base, IFDlength, displacement, section_index, ReadNextIFD, tag_table);
ImageInfo->ifd_nesting_level--;
return result;
}
/* {{{ exif_process_IFD_in_JPEG
* Process one of the nested IFDs directories. */
static int exif_process_IFD_in_JPEG(image_info_type *ImageInfo, char *dir_start, char *offset_base, size_t IFDlength, size_t displacement, int section_index, int tag)
@@ -4018,7 +4032,7 @@ static int exif_scan_thumbnail(image_info_type *ImageInfo)
/* {{{ exif_process_IFD_in_TIFF
* Parse the TIFF header; */
static int exif_process_IFD_in_TIFF(image_info_type *ImageInfo, size_t dir_offset, int section_index)
static int exif_process_IFD_in_TIFF_impl(image_info_type *ImageInfo, size_t dir_offset, int section_index)
{
int i, sn, num_entries, sub_section_index = 0;
unsigned char *dir_entry;
@@ -4027,10 +4041,6 @@ static int exif_process_IFD_in_TIFF(image_info_type *ImageInfo, size_t dir_offse
int entry_tag , entry_type;
tag_table_type tag_table = exif_get_tag_table(section_index);
if (ImageInfo->ifd_nesting_level > MAX_IFD_NESTING_LEVEL) {
return FALSE;
}
if (ImageInfo->FileSize >= 2 && ImageInfo->FileSize - 2 >= dir_offset) {
sn = exif_file_sections_add(ImageInfo, M_PSEUDO, 2, NULL);
#ifdef EXIF_DEBUG
@@ -4174,7 +4184,6 @@ static int exif_process_IFD_in_TIFF(image_info_type *ImageInfo, size_t dir_offse
#ifdef EXIF_DEBUG
exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Next IFD: %s @x%04X", exif_get_sectionname(sub_section_index), entry_offset);
#endif
ImageInfo->ifd_nesting_level++;
exif_process_IFD_in_TIFF(ImageInfo, entry_offset, sub_section_index);
if (section_index!=SECTION_THUMBNAIL && entry_tag==TAG_SUB_IFD) {
if (ImageInfo->Thumbnail.filetype != IMAGE_FILETYPE_UNKNOWN
@@ -4218,7 +4227,6 @@ static int exif_process_IFD_in_TIFF(image_info_type *ImageInfo, size_t dir_offse
#ifdef EXIF_DEBUG
exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Read next IFD (THUMBNAIL) at x%04X", next_offset);
#endif
ImageInfo->ifd_nesting_level++;
exif_process_IFD_in_TIFF(ImageInfo, next_offset, SECTION_THUMBNAIL);
#ifdef EXIF_DEBUG
exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "%s THUMBNAIL @0x%04X + 0x%04X", ImageInfo->Thumbnail.data ? "Ignore" : "Read", ImageInfo->Thumbnail.offset, ImageInfo->Thumbnail.size);
@@ -4255,6 +4263,21 @@ static int exif_process_IFD_in_TIFF(image_info_type *ImageInfo, size_t dir_offse
}
/* }}} */
static int exif_process_IFD_in_TIFF(image_info_type *ImageInfo, size_t dir_offset, int section_index)
{
int result;
if (ImageInfo->ifd_count++ > MAX_IFD_TAGS) {
return FALSE;
}
if (ImageInfo->ifd_nesting_level > MAX_IFD_NESTING_LEVEL) {
return FALSE;
}
ImageInfo->ifd_nesting_level++;
result = exif_process_IFD_in_TIFF_impl(ImageInfo, dir_offset, section_index);
ImageInfo->ifd_nesting_level--;
return result;
}
/* {{{ exif_scan_FILE_header
* Parse the marker stream until SOS or EOI is seen; */
static int exif_scan_FILE_header(image_info_type *ImageInfo)
@@ -4410,6 +4433,7 @@ static int exif_read_from_impl(image_info_type *ImageInfo, php_stream *stream, i
ImageInfo->ifd_nesting_level = 0;
ImageInfo->ifd_count = 0;
/* Scan the headers */
ret = exif_scan_FILE_header(ImageInfo);
+10
View File
@@ -0,0 +1,10 @@
--TEST--
Should not cause OOM
--FILE--
<?php
var_dump(@exif_read_data(__DIR__ . '/nesting_level_oom.tiff'));
?>
--EXPECT--
bool(false)
Binary file not shown.
+1
View File
@@ -218,6 +218,7 @@ PHP_MINIT_FUNCTION(finfo)
memcpy(&finfo_object_handlers, &std_object_handlers, sizeof(zend_object_handlers));
finfo_object_handlers.offset = XtOffsetOf(finfo_object, zo);
finfo_object_handlers.free_obj = finfo_objects_free;
finfo_object_handlers.clone_obj = NULL;
le_fileinfo = zend_register_list_destructors_ex(finfo_resource_destructor, NULL, "file_info", module_number);
+27
View File
@@ -0,0 +1,27 @@
--TEST--
Cloning and serializing finfo is not supported
--FILE--
<?php
$finfo = new finfo;
var_dump($finfo->buffer("Test string"));
try {
$finfo2 = clone $finfo;
var_dump($finfo2->buffer("Test string"));
} catch (Error $e) {
echo $e->getMessage(), "\n";
}
try {
$finfo3 = unserialize(serialize($finfo));
var_dump($finfo3->buffer("Test string"));
} catch (Error $e) {
echo $e->getMessage(), "\n";
}
?>
--EXPECTF--
string(%d) "%s"
Trying to clone an uncloneable object of class finfo
Warning: finfo::buffer(): The invalid fileinfo object. in %s on line %d
bool(false)
+8 -4
View File
@@ -1463,6 +1463,8 @@ void gdImageChar (gdImagePtr im, gdFontPtr f, int x, int y, int c, int color)
int cx, cy;
int px, py;
int fline;
const int xuppper = (x > INT_MAX - f->w) ? INT_MAX : x + f->w;
const int yuppper = (y > INT_MAX - f->h) ? INT_MAX : y + f->h;
cx = 0;
cy = 0;
#ifdef CHARSET_EBCDIC
@@ -1472,8 +1474,8 @@ void gdImageChar (gdImagePtr im, gdFontPtr f, int x, int y, int c, int color)
return;
}
fline = (c - f->offset) * f->h * f->w;
for (py = y; (py < (y + f->h)); py++) {
for (px = x; (px < (x + f->w)); px++) {
for (py = y; py < yuppper; py++) {
for (px = x; px < xuppper; px++) {
if (f->data[fline + cy * f->w + cx]) {
gdImageSetPixel(im, px, py, color);
}
@@ -1489,6 +1491,8 @@ void gdImageCharUp (gdImagePtr im, gdFontPtr f, int x, int y, int c, int color)
int cx, cy;
int px, py;
int fline;
const int xuppper = (x > INT_MAX - f->h) ? INT_MAX : x + f->h;
const int ylower = (y < INT_MIN + f->w) ? INT_MIN : y - f->w;
cx = 0;
cy = 0;
#ifdef CHARSET_EBCDIC
@@ -1498,8 +1502,8 @@ void gdImageCharUp (gdImagePtr im, gdFontPtr f, int x, int y, int c, int color)
return;
}
fline = (c - f->offset) * f->h * f->w;
for (py = y; py > (y - f->w); py--) {
for (px = x; px < (x + f->h); px++) {
for (py = y; py > ylower; py--) {
for (px = x; px < xuppper; px++) {
if (f->data[fline + cy * f->w + cx]) {
gdImageSetPixel(im, px, py, color);
}
+2 -2
View File
@@ -1155,7 +1155,7 @@ ZEND_FUNCTION(gmp_export)
FETCH_GMP_ZVAL(gmpnumber, gmpnumber_arg, temp_a);
if (mpz_sgn(gmpnumber) == 0) {
RETURN_EMPTY_STRING();
RETVAL_EMPTY_STRING();
} else {
size_t bits_per_word = size * 8;
size_t count = (mpz_sizeinbase(gmpnumber, 2) + bits_per_word - 1) / bits_per_word;
@@ -1164,7 +1164,7 @@ ZEND_FUNCTION(gmp_export)
mpz_export(ZSTR_VAL(out_string), NULL, order, size, endian, 0, gmpnumber);
ZSTR_VAL(out_string)[ZSTR_LEN(out_string)] = '\0';
RETURN_NEW_STR(out_string);
RETVAL_NEW_STR(out_string);
}
FREE_GMP_TEMP(temp_a);
+4
View File
@@ -50,6 +50,9 @@ foreach ($export as $k => $test) {
var_dump($passed);
// Argument converted from int to GMP
var_dump(bin2hex(gmp_export(0xff)));
// Invalid arguments (zpp failure)
var_dump(gmp_export());
@@ -62,6 +65,7 @@ var_dump(gmp_export(123, 1, GMP_MSW_FIRST | GMP_LSW_FIRST));
var_dump(gmp_export(123, 1, GMP_BIG_ENDIAN | GMP_LITTLE_ENDIAN));
--EXPECTF--
bool(true)
string(2) "ff"
Warning: gmp_export() expects at least 1 parameter, 0 given in %s on line %d
NULL
+1 -1
View File
@@ -129,7 +129,7 @@ int main() {
int main() {
iconv_t cd;
cd = iconv_open( "*blahblah*", "*blahblah*" );
cd = iconv_open( "*blahblah*", "*blahblahblah*" );
if (cd == (iconv_t)(-1)) {
if (errno == EINVAL) {
return 0;
+70 -34
View File
@@ -1315,7 +1315,7 @@ PHP_FUNCTION(imap_reopen)
imap_le_struct->imap_stream = mail_open(imap_le_struct->imap_stream, ZSTR_VAL(mailbox), flags);
if (imap_le_struct->imap_stream == NIL) {
zend_list_delete(Z_RES_P(streamind));
zend_list_close(Z_RES_P(streamind));
php_error_docref(NULL, E_WARNING, "Couldn't re-open stream");
RETURN_FALSE;
}
@@ -2692,8 +2692,9 @@ PHP_FUNCTION(imap_rfc822_write_address)
if (string) {
RETVAL_STR(string);
} else {
RETURN_FALSE;
RETVAL_FALSE;
}
mail_free_address(&addr);
}
/* }}} */
@@ -3074,7 +3075,8 @@ static void php_imap_mutf7(INTERNAL_FUNCTION_PARAMETERS, int mode) /* {{{ */
if (out == NIL) {
RETURN_FALSE;
} else {
RETURN_STRING((char *)out);
RETVAL_STRING((char *)out);
fs_give((void**) &out);
}
}
/* }}} */
@@ -3180,6 +3182,9 @@ PHP_FUNCTION(imap_sort)
} else {
spg = mail_newsearchpgm();
}
if (spg == NIL) {
RETURN_FALSE;
}
mypgm = mail_newsortpgm();
mypgm->reverse = rev;
@@ -3188,6 +3193,7 @@ PHP_FUNCTION(imap_sort)
slst = mail_sort(imap_le_struct->imap_stream, (argc == 6 ? ZSTR_VAL(charset) : NIL), spg, mypgm, (argc >= 4 ? flags : NIL));
mail_free_sortpgm(&mypgm);
if (spg && !(flags & SE_FREE)) {
mail_free_searchpgm(&spg);
}
@@ -3543,7 +3549,7 @@ PHP_FUNCTION(imap_mail_compose)
int toppart = 0;
int first;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "aa", &envelope, &body) == FAILURE) {
if (zend_parse_parameters(ZEND_NUM_ARGS(), "a/a/", &envelope, &body) == FAILURE) {
return;
}
@@ -3601,6 +3607,7 @@ PHP_FUNCTION(imap_mail_compose)
if ((pvalue = zend_hash_str_find(Z_ARRVAL_P(envelope), "custom_headers", sizeof("custom_headers") - 1)) != NULL) {
if (Z_TYPE_P(pvalue) == IS_ARRAY) {
custom_headers_param = tmp_param = NULL;
SEPARATE_ARRAY(pvalue);
ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(pvalue), env_data) {
custom_headers_param = mail_newbody_parameter();
convert_to_string_ex(env_data);
@@ -3620,17 +3627,25 @@ PHP_FUNCTION(imap_mail_compose)
if (Z_TYPE_P(data) != IS_ARRAY) {
php_error_docref(NULL, E_WARNING, "body parameter must be a non-empty array");
RETURN_FALSE;
RETVAL_FALSE;
goto done;
}
SEPARATE_ARRAY(data);
bod = mail_newbody();
topbod = bod;
if ((pvalue = zend_hash_str_find(Z_ARRVAL_P(data), "type", sizeof("type") - 1)) != NULL) {
bod->type = (short) zval_get_long(pvalue);
zend_long type = zval_get_long(pvalue);
if (type >= 0 && type <= TYPEMAX && body_types[type] != NULL) {
bod->type = (short) type;
}
}
if ((pvalue = zend_hash_str_find(Z_ARRVAL_P(data), "encoding", sizeof("encoding") - 1)) != NULL) {
bod->encoding = (short) zval_get_long(pvalue);
zend_long encoding = zval_get_long(pvalue);
if (encoding >= 0 && encoding <= ENCMAX && body_encodings[encoding] != NULL) {
bod->encoding = (short) encoding;
}
}
if ((pvalue = zend_hash_str_find(Z_ARRVAL_P(data), "charset", sizeof("charset") - 1)) != NULL) {
convert_to_string_ex(pvalue);
@@ -3643,7 +3658,9 @@ PHP_FUNCTION(imap_mail_compose)
if ((pvalue = zend_hash_str_find(Z_ARRVAL_P(data), "type.parameters", sizeof("type.parameters") - 1)) != NULL) {
if(Z_TYPE_P(pvalue) == IS_ARRAY) {
disp_param = tmp_param = NULL;
SEPARATE_ARRAY(pvalue);
ZEND_HASH_FOREACH_STR_KEY_VAL(Z_ARRVAL_P(pvalue), key, disp_data) {
if (key == NULL) continue;
disp_param = mail_newbody_parameter();
disp_param->attribute = cpystr(ZSTR_VAL(key));
convert_to_string_ex(disp_data);
@@ -3675,7 +3692,9 @@ PHP_FUNCTION(imap_mail_compose)
if ((pvalue = zend_hash_str_find(Z_ARRVAL_P(data), "disposition", sizeof("disposition") - 1)) != NULL) {
if (Z_TYPE_P(pvalue) == IS_ARRAY) {
disp_param = tmp_param = NULL;
SEPARATE_ARRAY(pvalue);
ZEND_HASH_FOREACH_STR_KEY_VAL(Z_ARRVAL_P(pvalue), key, disp_data) {
if (key == NULL) continue;
disp_param = mail_newbody_parameter();
disp_param->attribute = cpystr(ZSTR_VAL(key));
convert_to_string_ex(disp_data);
@@ -3687,15 +3706,19 @@ PHP_FUNCTION(imap_mail_compose)
bod->disposition.parameter = disp_param;
}
}
if ((pvalue = zend_hash_str_find(Z_ARRVAL_P(data), "contents.data", sizeof("contents.data") - 1)) != NULL) {
convert_to_string_ex(pvalue);
bod->contents.text.data = fs_get(Z_STRLEN_P(pvalue) + 1);
memcpy(bod->contents.text.data, Z_STRVAL_P(pvalue), Z_STRLEN_P(pvalue)+1);
bod->contents.text.size = Z_STRLEN_P(pvalue);
if (bod->type == TYPEMESSAGE && bod->subtype && !strcmp(bod->subtype, "RFC822")) {
bod->nested.msg = mail_newmsg();
} else {
bod->contents.text.data = fs_get(1);
memcpy(bod->contents.text.data, "", 1);
bod->contents.text.size = 0;
if ((pvalue = zend_hash_str_find(Z_ARRVAL_P(data), "contents.data", sizeof("contents.data") - 1)) != NULL) {
convert_to_string_ex(pvalue);
bod->contents.text.data = fs_get(Z_STRLEN_P(pvalue) + 1);
memcpy(bod->contents.text.data, Z_STRVAL_P(pvalue), Z_STRLEN_P(pvalue)+1);
bod->contents.text.size = Z_STRLEN_P(pvalue);
} else {
bod->contents.text.data = fs_get(1);
memcpy(bod->contents.text.data, "", 1);
bod->contents.text.size = 0;
}
}
if ((pvalue = zend_hash_str_find(Z_ARRVAL_P(data), "lines", sizeof("lines") - 1)) != NULL) {
bod->size.lines = zval_get_long(pvalue);
@@ -3707,10 +3730,14 @@ PHP_FUNCTION(imap_mail_compose)
convert_to_string_ex(pvalue);
bod->md5 = cpystr(Z_STRVAL_P(pvalue));
}
} else if (Z_TYPE_P(data) == IS_ARRAY) {
short type = -1;
} else if (Z_TYPE_P(data) == IS_ARRAY && topbod->type == TYPEMULTIPART) {
short type = 0;
SEPARATE_ARRAY(data);
if ((pvalue = zend_hash_str_find(Z_ARRVAL_P(data), "type", sizeof("type") - 1)) != NULL) {
type = (short) zval_get_long(pvalue);
zend_long tmp_type = zval_get_long(pvalue);
if (tmp_type >= 0 && tmp_type <= TYPEMAX && tmp_type != TYPEMULTIPART && body_types[tmp_type] != NULL) {
type = (short) tmp_type;
}
}
if (!toppart) {
@@ -3723,13 +3750,13 @@ PHP_FUNCTION(imap_mail_compose)
}
bod = &mypart->body;
if (type != TYPEMULTIPART) {
bod->type = type;
}
bod->type = type;
if ((pvalue = zend_hash_str_find(Z_ARRVAL_P(data), "encoding", sizeof("encoding") - 1)) != NULL) {
bod->encoding = (short) zval_get_long(pvalue);
zend_long encoding = zval_get_long(pvalue);
if (encoding >= 0 && encoding <= ENCMAX && body_encodings[encoding] != NULL) {
bod->encoding = (short) encoding;
}
}
if ((pvalue = zend_hash_str_find(Z_ARRVAL_P(data), "charset", sizeof("charset") - 1)) != NULL) {
convert_to_string_ex(pvalue);
@@ -3743,7 +3770,9 @@ PHP_FUNCTION(imap_mail_compose)
if ((pvalue = zend_hash_str_find(Z_ARRVAL_P(data), "type.parameters", sizeof("type.parameters") - 1)) != NULL) {
if (Z_TYPE_P(pvalue) == IS_ARRAY) {
disp_param = tmp_param = NULL;
SEPARATE_ARRAY(pvalue);
ZEND_HASH_FOREACH_STR_KEY_VAL(Z_ARRVAL_P(pvalue), key, disp_data) {
if (key == NULL) continue;
disp_param = mail_newbody_parameter();
disp_param->attribute = cpystr(ZSTR_VAL(key));
convert_to_string_ex(disp_data);
@@ -3775,7 +3804,9 @@ PHP_FUNCTION(imap_mail_compose)
if ((pvalue = zend_hash_str_find(Z_ARRVAL_P(data), "disposition", sizeof("disposition") - 1)) != NULL) {
if (Z_TYPE_P(pvalue) == IS_ARRAY) {
disp_param = tmp_param = NULL;
SEPARATE_ARRAY(pvalue);
ZEND_HASH_FOREACH_STR_KEY_VAL(Z_ARRVAL_P(pvalue), key, disp_data) {
if (key == NULL) continue;
disp_param = mail_newbody_parameter();
disp_param->attribute = cpystr(ZSTR_VAL(key));
convert_to_string_ex(disp_data);
@@ -3787,15 +3818,19 @@ PHP_FUNCTION(imap_mail_compose)
bod->disposition.parameter = disp_param;
}
}
if ((pvalue = zend_hash_str_find(Z_ARRVAL_P(data), "contents.data", sizeof("contents.data") - 1)) != NULL) {
convert_to_string_ex(pvalue);
bod->contents.text.data = fs_get(Z_STRLEN_P(pvalue) + 1);
memcpy(bod->contents.text.data, Z_STRVAL_P(pvalue), Z_STRLEN_P(pvalue) + 1);
bod->contents.text.size = Z_STRLEN_P(pvalue);
if (bod->type == TYPEMESSAGE && bod->subtype && !strcmp(bod->subtype, "RFC822")) {
bod->nested.msg = mail_newmsg();
} else {
bod->contents.text.data = fs_get(1);
memcpy(bod->contents.text.data, "", 1);
bod->contents.text.size = 0;
if ((pvalue = zend_hash_str_find(Z_ARRVAL_P(data), "contents.data", sizeof("contents.data") - 1)) != NULL) {
convert_to_string_ex(pvalue);
bod->contents.text.data = fs_get(Z_STRLEN_P(pvalue) + 1);
memcpy(bod->contents.text.data, Z_STRVAL_P(pvalue), Z_STRLEN_P(pvalue) + 1);
bod->contents.text.size = Z_STRLEN_P(pvalue);
} else {
bod->contents.text.data = fs_get(1);
memcpy(bod->contents.text.data, "", 1);
bod->contents.text.size = 0;
}
}
if ((pvalue = zend_hash_str_find(Z_ARRVAL_P(data), "lines", sizeof("lines") - 1)) != NULL) {
bod->size.lines = zval_get_long(pvalue);
@@ -3812,7 +3847,8 @@ PHP_FUNCTION(imap_mail_compose)
if (first) {
php_error_docref(NULL, E_WARNING, "body parameter must be a non-empty array");
RETURN_FALSE;
RETVAL_FALSE;
goto done;
}
if (bod && bod->type == TYPEMULTIPART && (!bod->nested.part || !bod->nested.part->next)) {
@@ -3895,7 +3931,7 @@ PHP_FUNCTION(imap_mail_compose)
bod=&part->body;
spprintf(&tempstring, 0, "%s%s%s", mystring, bod->contents.text.data, CRLF);
spprintf(&tempstring, 0, "%s%s%s", mystring, bod->contents.text.data ? (char *) bod->contents.text.data : "", CRLF);
efree(mystring);
mystring=tempstring;
} while ((part = part->next)); /* until done */
@@ -3905,7 +3941,7 @@ PHP_FUNCTION(imap_mail_compose)
efree(mystring);
mystring=tempstring;
} else if (bod) {
spprintf(&tempstring, 0, "%s%s%s", mystring, bod->contents.text.data, CRLF);
spprintf(&tempstring, 0, "%s%s%s", mystring, bod->contents.text.data ? (char *) bod->contents.text.data : "", CRLF);
efree(mystring);
mystring=tempstring;
} else {
+23
View File
@@ -0,0 +1,23 @@
--TEST--
Bug #64076 (imap_sort() does not return FALSE on failure)
--SKIPIF--
<?php
require_once __DIR__ . '/skipif.inc';
?>
--FILE--
<?php
require_once __DIR__ . '/imap_include.inc';
$stream = setup_test_mailbox('', 2);
imap_errors(); // clear error stack
var_dump(imap_sort($stream, SORTFROM, 0, 0, 'UNSUPPORTED SEARCH CRITERIUM'));
var_dump(imap_errors() !== false);
?>
--CLEAN--
<?php
require_once __DIR__ . '/clean.inc';
?>
--EXPECT--
Create a temporary mailbox and add 2 msgs
.. mailbox '{127.0.0.1:143/norsh}INBOX.phpttest' created
bool(false)
bool(true)
+1 -1
View File
@@ -11,5 +11,5 @@ imap_mail('1', 1, NULL);
===DONE===
--EXPECTF--
Warning: imap_mail(): No message string in mail command in %s on line %d
%s
%A
===DONE===
+21
View File
@@ -0,0 +1,21 @@
--TEST--
Bug #80213 (imap_mail_compose() segfaults on certain $bodies)
--SKIPIF--
<?php
if (!extension_loaded('imap')) die('skip imap extension not available');
?>
--FILE--
<?php
$envelope = [];
$body = [[
'type.parameters' => ['param'],
'disposition' => ['disp'],
], [
'type.parameters' => ['param'],
'disposition' => ['disp'],
]];
imap_mail_compose($envelope, $body);
echo "done\n";
?>
--EXPECT--
done
+69
View File
@@ -0,0 +1,69 @@
--TEST--
Bug #80215 (imap_mail_compose() may modify by-val parameters)
--SKIPIF--
<?php
if (!extension_loaded('imap')) die('skip imap extension not available');
?>
--FILE--
<?php
$envelope = [
"from" => 1,
"to" => 2,
"custom_headers" => [3],
];
$body = [[
"contents.data" => 4,
"type.parameters" => ['foo' => 5],
"disposition" => ['bar' => 6],
], [
"contents.data" => 7,
"type.parameters" => ['foo' => 8],
"disposition" => ['bar' => 9],
]];
imap_mail_compose($envelope, $body);
var_dump($envelope, $body);
?>
--EXPECT--
array(3) {
["from"]=>
int(1)
["to"]=>
int(2)
["custom_headers"]=>
array(1) {
[0]=>
int(3)
}
}
array(2) {
[0]=>
array(3) {
["contents.data"]=>
int(4)
["type.parameters"]=>
array(1) {
["foo"]=>
int(5)
}
["disposition"]=>
array(1) {
["bar"]=>
int(6)
}
}
[1]=>
array(3) {
["contents.data"]=>
int(7)
["type.parameters"]=>
array(1) {
["foo"]=>
int(8)
}
["disposition"]=>
array(1) {
["bar"]=>
int(9)
}
}
}
+17
View File
@@ -0,0 +1,17 @@
--TEST--
Bug #80216 (imap_mail_compose() does not validate types/encodings)
--SKIPIF--
<?php
if (!extension_loaded('imap')) die('skip imap extension not available');
?>
--FILE--
<?php
imap_mail_compose([], [['type' => TYPEMULTIPART], []]);
imap_mail_compose([], [['type' => 12]]);
imap_mail_compose([], [['type' => TYPEMULTIPART], ['type' => 12]]);
imap_mail_compose([], [['encoding' => 8]]);
imap_mail_compose([], [['type' => TYPEMULTIPART], ['encoding' => 8]]);
echo "done\n";
?>
--EXPECT--
done
+34
View File
@@ -0,0 +1,34 @@
--TEST--
Bug #80220 (imap_mail_compose() may leak memory) - message/rfc822 regression
--SKIPIF--
<?php
if (!extension_loaded('imap')) die('skip imap extension not available');
?>
--FILE--
<?php
$bodies = [[
'type' => TYPEMESSAGE,
'subtype' => 'RFC822',
], [
'contents.data' => 'asd',
]];
var_dump(imap_mail_compose([], $bodies));
$bodies = [[
'type' => TYPEMESSAGE,
], [
'contents.data' => 'asd',
]];
var_dump(imap_mail_compose([], $bodies));
?>
--EXPECT--
string(53) "MIME-Version: 1.0
Content-Type: MESSAGE/RFC822
"
string(53) "MIME-Version: 1.0
Content-Type: MESSAGE/RFC822
"
+15
View File
@@ -0,0 +1,15 @@
--TEST--
Bug #80223 (imap_mail_compose() leaks envelope on malformed bodies)
--SKIPIF--
<?php
if (!extension_loaded('imap')) die('skip imap extension not available');
?>
--FILE--
<?php
imap_mail_compose([], []);
imap_mail_compose([], [1]);
?>
--EXPECTF--
Warning: imap_mail_compose(): body parameter must be a non-empty array in %s on line %d
Warning: imap_mail_compose(): body parameter must be a non-empty array in %s on line %d
+13
View File
@@ -0,0 +1,13 @@
--TEST--
Bug #80226 (imap_sort() leaks sortpgm memory)
--SKIPIF--
<?php
require_once(__DIR__.'/skipif.inc');
?>
--FILE--
<?php
require_once(__DIR__.'/imap_include.inc');
$stream = imap_open($default_mailbox, $username, $password);
imap_sort($stream, SORTFROM, 0);
?>
--EXPECT--
+22
View File
@@ -0,0 +1,22 @@
--TEST--
Bug #80242 (imap_mail_compose() segfaults for multipart with rfc822)
--SKIPIF--
<?php
if (!extension_loaded('imap')) die('skip imap extension not available');
?>
--FILE--
<?php
$bodies = [[
'type' => TYPEMULTIPART,
], [
'type' => TYPETEXT,
'contents.data' => 'some text',
], [
'type' => TYPEMESSAGE,
'subtype' => 'RFC822',
]];
imap_mail_compose([], $bodies);
echo "done\n";
?>
--EXPECT--
done
@@ -106,7 +106,7 @@ Create a temporary mailbox and add 1 msgs
.. mailbox '%s.phpttest' created
-- Iteration 1 --
string(71) "From: %s
string(%d) "From: %s
To: %s
Subject: test1
@@ -0,0 +1,12 @@
--TEST--
imap_rfc822_write_address() : basic functionality
--SKIPIF--
<?php
if (!extension_loaded('imap')) die('skip imap extension not available');
?>
--FILE--
<?php
var_dump(imap_rfc822_write_address('me', 'example.com', 'My Name'));
?>
--EXPECT--
string(24) "My Name <me@example.com>"
-3
View File
@@ -57,9 +57,6 @@ elif test "$PHP_MYSQLI" != "no"; then
MYSQL_LIB_CFG='--libmysqld-libs'
dnl mysqlnd doesn't support embedded, so we have to add some extra stuff
mysqli_extra_sources="mysqli_embedded.c"
elif test "$enable_maintainer_zts" = "yes"; then
MYSQL_LIB_CFG='--libs_r'
MYSQL_LIB_NAME='mysqlclient_r'
else
MYSQL_LIB_CFG='--libs'
fi
+1 -1
View File
@@ -686,7 +686,7 @@ PHP_MINIT_FUNCTION(mysqli)
#ifdef MYSQLND_STRING_TO_INT_CONVERSION
REGISTER_LONG_CONSTANT("MYSQLI_OPT_INT_AND_FLOAT_NATIVE", MYSQLND_OPT_INT_AND_FLOAT_NATIVE, CONST_CS | CONST_PERSISTENT);
#endif
#if MYSQL_VERSION_ID > 50110 || defined(MYSQLI_USE_MYSQLND)
#if (MYSQL_VERSION_ID > 50110 && MYSQL_VERSION_ID < 80000) || (MYSQL_VERSION_ID >= 100000) || defined(MYSQLI_USE_MYSQLND)
REGISTER_LONG_CONSTANT("MYSQLI_OPT_SSL_VERIFY_SERVER_CERT", MYSQL_OPT_SSL_VERIFY_SERVER_CERT, CONST_CS | CONST_PERSISTENT);
#endif
+12 -8
View File
@@ -614,7 +614,7 @@ PHP_FUNCTION(mysqli_change_user)
size_t user_len, password_len, dbname_len;
zend_ulong rc;
#if !defined(MYSQLI_USE_MYSQLND) && defined(HAVE_MYSQLI_SET_CHARSET)
const CHARSET_INFO * old_charset;
MY_CHARSET_INFO old_charset;
#endif
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Osss!", &mysql_link, mysqli_link_class_entry, &user, &user_len, &password, &password_len, &dbname, &dbname_len) == FAILURE) {
@@ -623,7 +623,7 @@ PHP_FUNCTION(mysqli_change_user)
MYSQLI_FETCH_RESOURCE_CONN(mysql, mysql_link, MYSQLI_STATUS_VALID);
#if !defined(MYSQLI_USE_MYSQLND) && defined(HAVE_MYSQLI_SET_CHARSET)
old_charset = mysql->mysql->charset;
mysql_get_character_set_info(mysql->mysql, &old_charset);
#endif
#if defined(MYSQLI_USE_MYSQLND)
@@ -643,7 +643,7 @@ PHP_FUNCTION(mysqli_change_user)
5.0 doesn't support it. Support added in 5.1.23 by fixing the following bug :
Bug #30472 libmysql doesn't reset charset, insert_id after succ. mysql_change_user() call
*/
rc = mysql_set_character_set(mysql->mysql, old_charset->csname);
rc = mysql_set_character_set(mysql->mysql, old_charset.csname);
}
#endif
@@ -1716,10 +1716,12 @@ static int mysqli_options_get_option_zval_type(int option)
#endif /* MySQL 4.1.0 */
case MYSQL_OPT_READ_TIMEOUT:
case MYSQL_OPT_WRITE_TIMEOUT:
#ifdef MYSQL_OPT_GUESS_CONNECTION /* removed in MySQL-8.0 */
case MYSQL_OPT_GUESS_CONNECTION:
case MYSQL_OPT_USE_EMBEDDED_CONNECTION:
case MYSQL_OPT_USE_REMOTE_CONNECTION:
case MYSQL_SECURE_AUTH:
#endif
#ifdef MYSQL_OPT_RECONNECT
case MYSQL_OPT_RECONNECT:
#endif /* MySQL 5.0.13 */
@@ -1729,16 +1731,13 @@ static int mysqli_options_get_option_zval_type(int option)
#ifdef MYSQL_OPT_COMPRESS
case MYSQL_OPT_COMPRESS:
#endif /* mysqlnd @ PHP 5.3.2 */
#ifdef MYSQL_OPT_SSL_VERIFY_SERVER_CERT
REGISTER_LONG_CONSTANT("MYSQLI_OPT_SSL_VERIFY_SERVER_CERT", MYSQL_OPT_SSL_VERIFY_SERVER_CERT, CONST_CS | CONST_PERSISTENT);
#endif /* MySQL 5.1.1., mysqlnd @ PHP 5.3.3 */
#if (MYSQL_VERSION_ID >= 50611 && defined(CLIENT_CAN_HANDLE_EXPIRED_PASSWORDS)) || defined(MYSQLI_USE_MYSQLND)
case MYSQL_OPT_CAN_HANDLE_EXPIRED_PASSWORDS:
#endif
return IS_LONG;
#ifdef MYSQL_SHARED_MEMORY_BASE_NAME
case MYSQL_SHARED_MEMORY_BASE_NAME:
case MYSQL_SHARED_MEMORY_BASE_NAME:
#endif /* MySQL 4.1.0 */
#ifdef MYSQL_SET_CLIENT_IP
case MYSQL_SET_CLIENT_IP:
@@ -1955,6 +1954,11 @@ PHP_FUNCTION(mysqli_real_query)
}
/* }}} */
#if defined(MYSQLI_USE_MYSQLND) || MYSQL_VERSION_ID < 50707 || defined(MARIADB_BASE_VERSION)
# define mysql_real_escape_string_quote(mysql, to, from, length, quote) \
mysql_real_escape_string(mysql, to, from, length)
#endif
/* {{{ proto string mysqli_real_escape_string(object link, string escapestr)
Escapes special characters in a string for use in a SQL statement, taking into account the current charset of the connection */
PHP_FUNCTION(mysqli_real_escape_string) {
@@ -1970,7 +1974,7 @@ PHP_FUNCTION(mysqli_real_escape_string) {
MYSQLI_FETCH_RESOURCE_CONN(mysql, mysql_link, MYSQLI_STATUS_VALID);
newstr = zend_string_alloc(2 * escapestr_len, 0);
ZSTR_LEN(newstr) = mysql_real_escape_string(mysql->mysql, ZSTR_VAL(newstr), escapestr, escapestr_len);
ZSTR_LEN(newstr) = mysql_real_escape_string_quote(mysql->mysql, ZSTR_VAL(newstr), escapestr, escapestr_len, '\'');
newstr = zend_string_truncate(newstr, ZSTR_LEN(newstr), 0);
RETURN_NEW_STR(newstr);
+27 -28
View File
@@ -303,7 +303,8 @@ void mysqli_common_connect(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_real_conne
php_mysqli_set_error(mysql_errno(mysql->mysql), (char *) mysql_error(mysql->mysql));
#if !defined(MYSQLI_USE_MYSQLND)
mysql->mysql->reconnect = MyG(reconnect);
char reconnect = MyG(reconnect);
mysql_options(mysql->mysql, MYSQL_OPT_RECONNECT, (char *)&reconnect);
#endif
unsigned int allow_local_infile = MyG(allow_local_infile);
mysql_options(mysql->mysql, MYSQL_OPT_LOCAL_INFILE, (char *)&allow_local_infile);
@@ -1085,45 +1086,43 @@ extern char * mysqli_escape_string_for_tx_name_in_comment(const char * const nam
static int mysqli_begin_transaction_libmysql(MYSQL * conn, const unsigned int mode, const char * const name)
{
int ret;
zend_bool err = FALSE;
smart_str tmp_str = {0};
char * name_esc;
char * query;
unsigned int query_len;
if (mode & TRANS_START_WITH_CONSISTENT_SNAPSHOT) {
if (tmp_str.s) {
smart_str_appendl(&tmp_str, ", ", sizeof(", ") - 1);
}
smart_str_appendl(&tmp_str, "WITH CONSISTENT SNAPSHOT", sizeof("WITH CONSISTENT SNAPSHOT") - 1);
}
if (mode & (TRANS_START_READ_WRITE | TRANS_START_READ_ONLY)) {
if (mysql_get_server_version(conn) < 50605L) {
php_error_docref(NULL, E_WARNING, "This server version doesn't support 'READ WRITE' and 'READ ONLY'. Minimum 5.6.5 is required");
err = TRUE;
} else if (mode & TRANS_START_READ_WRITE) {
if (tmp_str.s) {
smart_str_appendl(&tmp_str, ", ", sizeof(", ") - 1);
}
smart_str_appendl(&tmp_str, "READ WRITE", sizeof("READ WRITE") - 1);
} else if (mode & TRANS_START_READ_ONLY) {
if (tmp_str.s) {
smart_str_appendl(&tmp_str, ", ", sizeof(", ") - 1);
}
smart_str_appendl(&tmp_str, "READ ONLY", sizeof("READ ONLY") - 1);
if (mode & TRANS_START_READ_WRITE) {
if (tmp_str.s) {
smart_str_appendl(&tmp_str, ", ", sizeof(", ") - 1);
}
smart_str_appendl(&tmp_str, "READ WRITE", sizeof("READ WRITE") - 1);
} else if (mode & TRANS_START_READ_ONLY) {
if (tmp_str.s) {
smart_str_appendl(&tmp_str, ", ", sizeof(", ") - 1);
}
smart_str_appendl(&tmp_str, "READ ONLY", sizeof("READ ONLY") - 1);
}
smart_str_0(&tmp_str);
if (err == FALSE){
char * name_esc = mysqli_escape_string_for_tx_name_in_comment(name);
char * query;
unsigned int query_len = spprintf(&query, 0, "START TRANSACTION%s %s",
name_esc? name_esc:"", tmp_str.s? ZSTR_VAL(tmp_str.s):"");
name_esc = mysqli_escape_string_for_tx_name_in_comment(name);
query_len = spprintf(&query, 0, "START TRANSACTION%s %s",
name_esc? name_esc:"", tmp_str.s? ZSTR_VAL(tmp_str.s):"");
smart_str_free(&tmp_str);
if (name_esc) {
efree(name_esc);
}
smart_str_free(&tmp_str);
if (name_esc) {
efree(name_esc);
}
ret = mysql_real_query(conn, query, query_len);
efree(query);
ret = mysql_real_query(conn, query, query_len);
efree(query);
if (ret && mode & (TRANS_START_READ_WRITE | TRANS_START_READ_ONLY) && mysql_errno(conn) == 1064) {
php_error_docref(NULL, E_WARNING, "This server version doesn't support 'READ WRITE' and 'READ ONLY'. Minimum 5.6.5 is required");
}
return ret;
}
@@ -1233,7 +1232,7 @@ PHP_FUNCTION(mysqli_release_savepoint)
#if !defined(MYSQLI_USE_MYSQLND)
if (mysqli_savepoint_libmysql(mysql->mysql, name, TRUE)) {
#else
if (FAIL == mysqlnd_savepoint(mysql->mysql, name)) {
if (FAIL == mysqlnd_release_savepoint(mysql->mysql, name)) {
#endif
RETURN_FALSE;
}
+3 -13
View File
@@ -58,8 +58,6 @@
#define HAVE_ULONG
#endif
#include <my_global.h>
#if !defined(HAVE_MBRLEN) && defined(WE_HAD_MBRLEN)
#define HAVE_MBRLEN 1
#endif
@@ -68,20 +66,12 @@
#define HAVE_MBSTATE_T 1
#endif
/*
We need more than mysql.h because we need CHARSET_INFO in one place.
This order has been borrowed from the ODBC driver. Nothing can be removed
from the list of headers :(
*/
#include <my_sys.h>
#include <mysql.h>
#if MYSQL_VERSION_ID >= 80000 && MYSQL_VERSION_ID < 100000
typedef _Bool my_bool;
#endif
#include <errmsg.h>
#include <my_list.h>
#include <m_string.h>
#include <mysqld_error.h>
#include <my_list.h>
#include <m_ctype.h>
#include "mysqli_libmysql.h"
#endif /* MYSQLI_USE_MYSQLND */
+25 -13
View File
@@ -1,5 +1,5 @@
--TEST--
MySQL 5.6 EXPIRE PASSWORD protocol change
MySQL 5.6 / MariaDB 10.4.3 EXPIRE PASSWORD protocol change
--SKIPIF--
<?php
require_once('skipif.inc');
@@ -14,6 +14,18 @@ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
if ($link->server_version < 50610)
die(sprintf("SKIP Needs MySQL 5.6.10 or newer, found MySQL %s\n", $link->server_info));
if ($link->server_version >= 100000) {
if ($link->server_version < 100403)
die(sprintf("SKIP Needs MariaDB 10.4.3 or newer, found MariaDB %s\n", $link->server_info));
$result = $link->query("select @@disconnect_on_expired_password");
if (!$result)
die("SKIP Failed to query MariaDB @@disconnect_on_expired_password value");
$row = mysqli_fetch_row($result);
if ($row[0] == 0)
die("SKIP Cannot run in MariaDB @@disconnect_on_expired_password=OFF state");
}
if (!$IS_MYSQLND && (mysqli_get_client_version() < 50610)) {
die(sprintf("SKIP Needs libmysql 5.6.10 or newer, found %s\n", mysqli_get_client_version()));
}
@@ -21,15 +33,15 @@ if (!$IS_MYSQLND && (mysqli_get_client_version() < 50610)) {
mysqli_query($link, 'DROP USER expiretest');
mysqli_query($link, 'DROP USER expiretest@localhost');
if (!mysqli_query($link, 'CREATE USER expiretest@"%"') ||
!mysqli_query($link, 'CREATE USER expiretest@"localhost"')) {
if (!mysqli_query($link, 'CREATE USER expiretest IDENTIFIED BY \'expiredpassword\'') ||
!mysqli_query($link, 'CREATE USER expiretest@localhost IDENTIFIED BY \'expiredpassword\'')) {
printf("skip Cannot create second DB user [%d] %s", mysqli_errno($link), mysqli_error($link));
mysqli_close($link);
die("skip CREATE USER failed");
}
if (!mysqli_query($link, 'ALTER USER expiretest@"%" PASSWORD EXPIRE') ||
!mysqli_query($link, 'ALTER USER expiretest@"localhost" PASSWORD EXPIRE')) {
if (!mysqli_query($link, 'ALTER USER expiretest PASSWORD EXPIRE') ||
!mysqli_query($link, 'ALTER USER expiretest@localhost PASSWORD EXPIRE')) {
printf("skip Cannot modify second DB user [%d] %s", mysqli_errno($link), mysqli_error($link));
mysqli_close($link);
die("skip ALTER USER failed");
@@ -54,7 +66,7 @@ if (!mysqli_query($link, sprintf("GRANT SELECT ON TABLE %s.test TO expiretest@'%
require_once('table.inc');
/* default */
if (!$link = my_mysqli_connect($host, 'expiretest', "", $db, $port, $socket)) {
if (!$link = my_mysqli_connect($host, 'expiretest', 'expiredpassword', $db, $port, $socket)) {
printf("[001] Cannot connect [%d] %s\n",
mysqli_connect_errno(), mysqli_connect_error());
} else {
@@ -65,7 +77,7 @@ if (!mysqli_query($link, sprintf("GRANT SELECT ON TABLE %s.test TO expiretest@'%
/* explicitly requesting default */
$link = mysqli_init();
$link->options(MYSQLI_OPT_CAN_HANDLE_EXPIRED_PASSWORDS, 0);
if (!my_mysqli_real_connect($link, $host, 'expiretest', "", $db, $port, $socket)) {
if (!my_mysqli_real_connect($link, $host, 'expiretest', 'expiredpassword', $db, $port, $socket)) {
printf("[003] Cannot connect [%d] %s\n",
mysqli_connect_errno(), mysqli_connect_error());
} else {
@@ -76,7 +88,7 @@ if (!mysqli_query($link, sprintf("GRANT SELECT ON TABLE %s.test TO expiretest@'%
/* allow connect */
$link = mysqli_init();
$link->options(MYSQLI_OPT_CAN_HANDLE_EXPIRED_PASSWORDS, 1);
if (!my_mysqli_real_connect($link, $host, 'expiretest', "", $db, $port, $socket)) {
if (!my_mysqli_real_connect($link, $host, 'expiretest', 'expiredpassword', $db, $port, $socket)) {
printf("[005] Cannot connect [%d] %s\n",
mysqli_connect_errno(), mysqli_connect_error());
} else {
@@ -88,7 +100,7 @@ if (!mysqli_query($link, sprintf("GRANT SELECT ON TABLE %s.test TO expiretest@'%
/* allow connect, fix pw */
$link = mysqli_init();
$link->options(MYSQLI_OPT_CAN_HANDLE_EXPIRED_PASSWORDS, 1);
if (!my_mysqli_real_connect($link, $host, 'expiretest', "", $db, $port, $socket)) {
if (!my_mysqli_real_connect($link, $host, 'expiretest', 'expiredpassword', $db, $port, $socket)) {
printf("[007] Cannot connect [%d] %s\n",
mysqli_connect_errno(), mysqli_connect_error());
} else {
@@ -122,11 +134,11 @@ if (!mysqli_query($link, sprintf("GRANT SELECT ON TABLE %s.test TO expiretest@'%
mysqli_query($link, 'DROP USER expiretest@localhost');
?>
--EXPECTF--
Warning: mysqli%sconnect(): (HY000/1862): %s in %s on line %d
[001] Cannot connect [1862] %s
Warning: mysqli%sconnect(): (HY000/%d): %s in %s on line %d
[001] Cannot connect [%d] %s
Warning: mysqli%sconnect(): (HY000/1862): %s in %s on line %d
[003] Cannot connect [1862] %s
Warning: mysqli%sconnect(): (HY000/%d): %s in %s on line %d
[003] Cannot connect [%d] %s
[006] Connect allowed, query fail, [1820] %s
[008] Connect allowed, pw set, [0%A
array(1) {
+8 -20
View File
@@ -666,7 +666,7 @@ mysqli.allow_local_infile=1
$info = $new_info;
// CREATE, ALTER, RENAME, DROP DATABASE
// CREATE, ALTER, DROP DATABASE
if (mysqli_query($link, "CREATE DATABASE mysqli_get_client_stats")) {
if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info))
@@ -685,25 +685,13 @@ mysqli.allow_local_infile=1
mysqli_get_client_stats_assert_eq('non_result_set_queries', $new_info, (string)($info['non_result_set_queries'] + 1), $test_counter, 'CREATE DATABASE');
$info = $new_info;
if (mysqli_get_server_version($link) > 51700) {
if (!mysqli_query($link, "RENAME DATABASE mysqli_get_client_stats TO mysqli_get_client_stats_"))
printf("[%03d] RENAME DATABASE failed, [%d] %s\n", ++$test_counter,
mysqli_errno($link), mysqli_error($link));
if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info))
printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
++$test_counter, gettype($new_info), $new_info);
mysqli_get_client_stats_assert_eq('non_result_set_queries', $new_info, (string)($info['non_result_set_queries'] + 1), $test_counter, 'CREATE DATABASE');
$info = $new_info;
} else {
if (!mysqli_query($link, "CREATE DATABASE mysqli_get_client_stats_"))
printf("[%03d] CREATE DATABASE failed, [%d] %s\n", ++$test_counter,
mysqli_errno($link), mysqli_error($link));
if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info))
printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
++$test_counter, gettype($new_info), $new_info);
$info = $new_info;
}
if (!mysqli_query($link, "CREATE DATABASE mysqli_get_client_stats_"))
printf("[%03d] CREATE DATABASE failed, [%d] %s\n", ++$test_counter,
mysqli_errno($link), mysqli_error($link));
if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info))
printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
++$test_counter, gettype($new_info), $new_info);
$info = $new_info;
if (!mysqli_query($link, "DROP DATABASE mysqli_get_client_stats_"))
printf("[%03d] DROP DATABASE failed, [%d] %s\n", ++$test_counter,
@@ -0,0 +1,57 @@
--TEST--
Bug #80107 mysqli_query() fails for ~16 MB long query when compression is enabled
--SKIPIF--
<?php
require_once('skipif.inc');
require_once('skipifemb.inc');
require_once("connect.inc");
$link = @my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
if (!$link) {
die(sprintf("skip Can't connect to MySQL Server - [%d] %s", mysqli_connect_errno(), mysqli_connect_error()));
}
$result = $link->query("SHOW VARIABLES LIKE 'max_allowed_packet'");
if ($result->fetch_assoc()['Value'] < 0xffffff) {
die('skip max_allowed_packet is less than 0xffffff');
}
?>
--FILE--
<?php
require_once("connect.inc");
$data_size = 16777174;
// Insert with compression disabled:
$mysqli = mysqli_init();
$result = my_mysqli_real_connect($mysqli, $host, $user, $passwd, $db, $port, $socket);
$mysqli->query("DROP TABLE IF EXISTS test");
$mysqli->query("CREATE TABLE test (`blob` LONGBLOB NOT NULL) ENGINE=MyISAM");
$data = str_repeat("x", $data_size);
$mysqli->query("INSERT INTO $db.test(`blob`) VALUE ('$data')");
var_dump(mysqli_error_list($mysqli));
$mysqli->close();
// Insert with compression enabled:
$mysqli = mysqli_init();
$result = my_mysqli_real_connect($mysqli, $host, $user, $passwd, $db, $port, $socket, MYSQLI_CLIENT_COMPRESS);
$data = str_repeat("x", $data_size);
$mysqli->query("INSERT INTO $db.test(`blob`) VALUE ('$data')");
var_dump(mysqli_error_list($mysqli));
$mysqli->close();
?>
--CLEAN--
<?php
require_once("clean_table.inc");
?>
--EXPECT--
array(0) {
}
array(0) {
}
@@ -50,7 +50,7 @@ if (!have_innodb($link))
printf("[009] Cannot turn off autocommit, expecting true, got %s/%s\n", gettype($tmp), $tmp);
/* note that there is no savepoint my... */
if (true !== ($tmp = mysqli_release_savepoint($link, 'my')))
if (false !== ($tmp = mysqli_release_savepoint($link, 'my')))
printf("[010] Got %s - [%d] %s\n", var_dump($tmp, true), mysqli_errno($link), mysqli_error($link));
if (!mysqli_query($link, 'INSERT INTO test(id) VALUES (1)'))
+14 -16
View File
@@ -2131,23 +2131,16 @@ MYSQLND_METHOD(mysqlnd_conn_data, tx_begin)(MYSQLND_CONN_DATA * conn, const unsi
}
smart_str_appendl(&tmp_str, "WITH CONSISTENT SNAPSHOT", sizeof("WITH CONSISTENT SNAPSHOT") - 1);
}
if (mode & (TRANS_START_READ_WRITE | TRANS_START_READ_ONLY)) {
zend_ulong server_version = conn->m->get_server_version(conn);
if (server_version < 50605L) {
php_error_docref(NULL, E_WARNING, "This server version doesn't support 'READ WRITE' and 'READ ONLY'. Minimum 5.6.5 is required");
smart_str_free(&tmp_str);
break;
} else if (mode & TRANS_START_READ_WRITE) {
if (tmp_str.s && ZSTR_LEN(tmp_str.s)) {
smart_str_appendl(&tmp_str, ", ", sizeof(", ") - 1);
}
smart_str_appendl(&tmp_str, "READ WRITE", sizeof("READ WRITE") - 1);
} else if (mode & TRANS_START_READ_ONLY) {
if (tmp_str.s && ZSTR_LEN(tmp_str.s)) {
smart_str_appendl(&tmp_str, ", ", sizeof(", ") - 1);
}
smart_str_appendl(&tmp_str, "READ ONLY", sizeof("READ ONLY") - 1);
if (mode & TRANS_START_READ_WRITE) {
if (tmp_str.s && ZSTR_LEN(tmp_str.s)) {
smart_str_appendl(&tmp_str, ", ", sizeof(", ") - 1);
}
smart_str_appendl(&tmp_str, "READ WRITE", sizeof("READ WRITE") - 1);
} else if (mode & TRANS_START_READ_ONLY) {
if (tmp_str.s && ZSTR_LEN(tmp_str.s)) {
smart_str_appendl(&tmp_str, ", ", sizeof(", ") - 1);
}
smart_str_appendl(&tmp_str, "READ ONLY", sizeof("READ ONLY") - 1);
}
smart_str_0(&tmp_str);
@@ -2166,6 +2159,11 @@ MYSQLND_METHOD(mysqlnd_conn_data, tx_begin)(MYSQLND_CONN_DATA * conn, const unsi
}
ret = conn->m->query(conn, query, query_len);
mnd_sprintf_free(query);
if (ret && mode & (TRANS_START_READ_WRITE | TRANS_START_READ_ONLY) &&
mysqlnd_stmt_errno(conn) == 1064) {
php_error_docref(NULL, E_WARNING, "This server version doesn't support 'READ WRITE' and 'READ ONLY'. Minimum 5.6.5 is required");
break;
}
}
} while (0);
conn->m->local_tx_end(conn, this_func, ret);
+1 -1
View File
@@ -524,7 +524,7 @@ MYSQLND_METHOD(mysqlnd_debug, set_mode)(MYSQLND_DEBUG * self, const char * const
if (i + 1 < mode_len && mode[i+1] == ',') {
unsigned int j = i + 2;
#ifdef PHP_WIN32
if (i+4 < mode_len && mode[i+3] == ':' && (mode[i+4] == '\\' || mode[i+5] == '/')) {
if (i+4 < mode_len && mode[i+3] == ':' && (mode[i+4] == '\\' || mode[i+4] == '/')) {
j = i + 5;
}
#endif
+65 -40
View File
@@ -50,6 +50,57 @@ MYSQLND_METHOD(mysqlnd_pfc, reset)(MYSQLND_PFC * const pfc, MYSQLND_STATS * cons
#define STORE_HEADER_SIZE(safe_storage, buffer) COPY_HEADER((safe_storage), (buffer))
#define RESTORE_HEADER_SIZE(buffer, safe_storage) STORE_HEADER_SIZE((safe_storage), (buffer))
#ifdef MYSQLND_COMPRESSION_ENABLED
static size_t write_compressed_packet(
const MYSQLND_PFC *pfc, MYSQLND_VIO *vio,
MYSQLND_STATS *conn_stats, MYSQLND_ERROR_INFO *error_info,
zend_uchar *uncompressed_payload, size_t to_be_sent, zend_uchar *compress_buf) {
DBG_ENTER("write_compressed_packet");
/* here we need to compress the data and then write it, first comes the compressed header */
size_t tmp_complen = to_be_sent;
size_t payload_size;
if (PASS == pfc->data->m.encode((compress_buf + COMPRESSED_HEADER_SIZE + MYSQLND_HEADER_SIZE), &tmp_complen,
uncompressed_payload, to_be_sent))
{
int3store(compress_buf + MYSQLND_HEADER_SIZE, to_be_sent);
payload_size = tmp_complen;
} else {
int3store(compress_buf + MYSQLND_HEADER_SIZE, 0);
memcpy(compress_buf + MYSQLND_HEADER_SIZE + COMPRESSED_HEADER_SIZE, uncompressed_payload, to_be_sent);
payload_size = to_be_sent;
}
int3store(compress_buf, payload_size);
int1store(compress_buf + 3, pfc->data->compressed_envelope_packet_no);
DBG_INF_FMT("writing "MYSQLND_SZ_T_SPEC" bytes to the network", payload_size + MYSQLND_HEADER_SIZE + COMPRESSED_HEADER_SIZE);
size_t bytes_sent = vio->data->m.network_write(vio, compress_buf, payload_size + MYSQLND_HEADER_SIZE + COMPRESSED_HEADER_SIZE, conn_stats, error_info);
pfc->data->compressed_envelope_packet_no++;
#ifdef WHEN_WE_NEED_TO_CHECK_WHETHER_COMPRESSION_WORKS_CORRECTLY
if (res == Z_OK) {
size_t decompressed_size = left + MYSQLND_HEADER_SIZE;
zend_uchar * decompressed_data = mnd_malloc(decompressed_size);
int error = pfc->data->m.decode(decompressed_data, decompressed_size,
compress_buf + MYSQLND_HEADER_SIZE + COMPRESSED_HEADER_SIZE, payload_size);
if (error == Z_OK) {
int i;
DBG_INF("success decompressing");
for (i = 0 ; i < decompressed_size; i++) {
if (i && (i % 30 == 0)) {
printf("\n\t\t");
}
printf("%.2X ", (int)*((char*)&(decompressed_data[i])));
DBG_INF_FMT("%.2X ", (int)*((char*)&(decompressed_data[i])));
}
} else {
DBG_INF("error decompressing");
}
mnd_free(decompressed_data);
}
#endif /* WHEN_WE_NEED_TO_CHECK_WHETHER_COMPRESSION_WORKS_CORRECTLY */
DBG_RETURN(bytes_sent);
}
#endif
/* {{{ mysqlnd_pfc::send */
/*
@@ -91,53 +142,27 @@ MYSQLND_METHOD(mysqlnd_pfc, send)(MYSQLND_PFC * const pfc, MYSQLND_VIO * const v
DBG_INF_FMT("packet_no=%u", pfc->data->packet_no);
#ifdef MYSQLND_COMPRESSION_ENABLED
if (pfc->data->compressed == TRUE) {
/* here we need to compress the data and then write it, first comes the compressed header */
size_t tmp_complen = to_be_sent;
size_t payload_size;
zend_uchar * uncompressed_payload = p; /* should include the header */
STORE_HEADER_SIZE(safe_storage, uncompressed_payload);
int3store(uncompressed_payload, to_be_sent);
int1store(uncompressed_payload + 3, pfc->data->packet_no);
if (PASS == pfc->data->m.encode((compress_buf + COMPRESSED_HEADER_SIZE + MYSQLND_HEADER_SIZE), &tmp_complen,
uncompressed_payload, to_be_sent + MYSQLND_HEADER_SIZE))
{
int3store(compress_buf + MYSQLND_HEADER_SIZE, to_be_sent + MYSQLND_HEADER_SIZE);
payload_size = tmp_complen;
if (to_be_sent <= MYSQLND_MAX_PACKET_SIZE - MYSQLND_HEADER_SIZE) {
bytes_sent = write_compressed_packet(
pfc, vio, conn_stats, error_info,
uncompressed_payload, to_be_sent + MYSQLND_HEADER_SIZE, compress_buf);
} else {
int3store(compress_buf + MYSQLND_HEADER_SIZE, 0);
memcpy(compress_buf + MYSQLND_HEADER_SIZE + COMPRESSED_HEADER_SIZE, uncompressed_payload, to_be_sent + MYSQLND_HEADER_SIZE);
payload_size = to_be_sent + MYSQLND_HEADER_SIZE;
/* The uncompressed size including the header would overflow. Split into two
* compressed packets. The size of the first one is relatively arbitrary here. */
const size_t split_off_bytes = 8192;
bytes_sent = write_compressed_packet(
pfc, vio, conn_stats, error_info,
uncompressed_payload, split_off_bytes, compress_buf);
bytes_sent = write_compressed_packet(
pfc, vio, conn_stats, error_info,
uncompressed_payload + split_off_bytes,
to_be_sent + MYSQLND_HEADER_SIZE - split_off_bytes, compress_buf);
}
RESTORE_HEADER_SIZE(uncompressed_payload, safe_storage);
int3store(compress_buf, payload_size);
int1store(compress_buf + 3, pfc->data->packet_no);
DBG_INF_FMT("writing "MYSQLND_SZ_T_SPEC" bytes to the network", payload_size + MYSQLND_HEADER_SIZE + COMPRESSED_HEADER_SIZE);
bytes_sent = vio->data->m.network_write(vio, compress_buf, payload_size + MYSQLND_HEADER_SIZE + COMPRESSED_HEADER_SIZE, conn_stats, error_info);
pfc->data->compressed_envelope_packet_no++;
#if WHEN_WE_NEED_TO_CHECK_WHETHER_COMPRESSION_WORKS_CORRECTLY
if (res == Z_OK) {
size_t decompressed_size = left + MYSQLND_HEADER_SIZE;
zend_uchar * decompressed_data = mnd_malloc(decompressed_size);
int error = pfc->data->m.decode(decompressed_data, decompressed_size,
compress_buf + MYSQLND_HEADER_SIZE + COMPRESSED_HEADER_SIZE, payload_size);
if (error == Z_OK) {
int i;
DBG_INF("success decompressing");
for (i = 0 ; i < decompressed_size; i++) {
if (i && (i % 30 == 0)) {
printf("\n\t\t");
}
printf("%.2X ", (int)*((char*)&(decompressed_data[i])));
DBG_INF_FMT("%.2X ", (int)*((char*)&(decompressed_data[i])));
}
} else {
DBG_INF("error decompressing");
}
mnd_free(decompressed_data);
}
#endif /* WHEN_WE_NEED_TO_CHECK_WHETHER_COMPRESSION_WORKS_CORRECTLY */
} else
#endif /* MYSQLND_COMPRESSION_ENABLED */
{
+37 -17
View File
@@ -1309,7 +1309,7 @@ PHP_FUNCTION(odbc_execute)
int numArgs = ZEND_NUM_ARGS(), i, ne;
RETCODE rc;
if (zend_parse_parameters(numArgs, "r|a", &pv_res, &pv_param_arr) == FAILURE) {
if (zend_parse_parameters(numArgs, "r|a/", &pv_res, &pv_param_arr) == FAILURE) {
return;
}
@@ -1810,6 +1810,9 @@ static void php_odbc_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, int result_type)
if (rc == SQL_SUCCESS_WITH_INFO) {
ZVAL_STRINGL(&tmp, buf, result->longreadlen);
} else if (rc != SQL_SUCCESS) {
php_error_docref(NULL, E_WARNING, "Cannot get data of column #%d (retcode %u)", i + 1, rc);
ZVAL_FALSE(&tmp);
} else if (result->values[i].vallen == SQL_NULL_DATA) {
ZVAL_NULL(&tmp);
break;
@@ -1962,6 +1965,9 @@ PHP_FUNCTION(odbc_fetch_into)
}
if (rc == SQL_SUCCESS_WITH_INFO) {
ZVAL_STRINGL(&tmp, buf, result->longreadlen);
} else if (rc != SQL_SUCCESS) {
php_error_docref(NULL, E_WARNING, "Cannot get data of column #%d (retcode %u)", i + 1, rc);
ZVAL_FALSE(&tmp);
} else if (result->values[i].vallen == SQL_NULL_DATA) {
ZVAL_NULL(&tmp);
break;
@@ -2199,12 +2205,13 @@ PHP_FUNCTION(odbc_result)
RETURN_FALSE;
}
if (result->values[field_ind].vallen == SQL_NULL_DATA) {
if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
zend_string_efree(field_str);
php_error_docref(NULL, E_WARNING, "Cannot get data of column #%d (retcode %u)", field_ind + 1, rc);
RETURN_FALSE;
} else if (result->values[field_ind].vallen == SQL_NULL_DATA) {
zend_string_efree(field_str);
RETURN_NULL();
} else if (rc == SQL_NO_DATA_FOUND) {
zend_string_efree(field_str);
RETURN_FALSE;
}
/* Reduce fieldlen by 1 if we have char data. One day we might
have binary strings... */
@@ -2221,6 +2228,7 @@ PHP_FUNCTION(odbc_result)
if (rc != SQL_SUCCESS_WITH_INFO) {
field_str = zend_string_truncate(field_str, result->values[field_ind].vallen, 0);
}
ZSTR_VAL(field_str)[ZSTR_LEN(field_str)] = '\0';
RETURN_NEW_STR(field_str);
break;
@@ -2249,6 +2257,12 @@ PHP_FUNCTION(odbc_result)
RETURN_FALSE;
}
if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
php_error_docref(NULL, E_WARNING, "Cannot get data of column #%d (retcode %u)", field_ind + 1, rc);
efree(field);
RETURN_FALSE;
}
if (result->values[field_ind].vallen == SQL_NULL_DATA) {
efree(field);
RETURN_NULL();
@@ -2358,6 +2372,11 @@ PHP_FUNCTION(odbc_result_all)
}
if (rc == SQL_SUCCESS_WITH_INFO) {
PHPWRITE(buf, result->longreadlen);
} else if (rc != SQL_SUCCESS) {
php_printf("</td></tr></table>");
php_error_docref(NULL, E_WARNING, "Cannot get data of column #%zu (retcode %u)", i + 1, rc);
efree(buf);
RETURN_FALSE;
} else if (result->values[i].vallen == SQL_NULL_DATA) {
php_printf("<td>NULL</td>");
break;
@@ -2772,6 +2791,7 @@ PHP_FUNCTION(odbc_next_result)
}
efree(result->values);
result->values = NULL;
result->numcols = 0;
}
result->fetched = 0;
@@ -3155,7 +3175,7 @@ PHP_FUNCTION(odbc_tables)
type, SAFE_SQL_NTS(type));
if (rc == SQL_ERROR) {
odbc_sql_error(conn, SQL_NULL_HSTMT, "SQLTables");
odbc_sql_error(conn, result->stmt, "SQLTables");
efree(result);
RETURN_FALSE;
}
@@ -3226,7 +3246,7 @@ PHP_FUNCTION(odbc_columns)
column, (SQLSMALLINT) column_len);
if (rc == SQL_ERROR) {
odbc_sql_error(conn, SQL_NULL_HSTMT, "SQLColumns");
odbc_sql_error(conn, result->stmt, "SQLColumns");
efree(result);
RETURN_FALSE;
}
@@ -3291,7 +3311,7 @@ PHP_FUNCTION(odbc_columnprivileges)
column, SAFE_SQL_NTS(column));
if (rc == SQL_ERROR) {
odbc_sql_error(conn, SQL_NULL_HSTMT, "SQLColumnPrivileges");
odbc_sql_error(conn, result->stmt, "SQLColumnPrivileges");
efree(result);
RETURN_FALSE;
}
@@ -3371,7 +3391,7 @@ PHP_FUNCTION(odbc_foreignkeys)
ftable, SAFE_SQL_NTS(ftable) );
if (rc == SQL_ERROR) {
odbc_sql_error(conn, SQL_NULL_HSTMT, "SQLForeignKeys");
odbc_sql_error(conn, result->stmt, "SQLForeignKeys");
efree(result);
RETURN_FALSE;
}
@@ -3433,7 +3453,7 @@ PHP_FUNCTION(odbc_gettypeinfo)
rc = SQLGetTypeInfo(result->stmt, data_type );
if (rc == SQL_ERROR) {
odbc_sql_error(conn, SQL_NULL_HSTMT, "SQLGetTypeInfo");
odbc_sql_error(conn, result->stmt, "SQLGetTypeInfo");
efree(result);
RETURN_FALSE;
}
@@ -3495,7 +3515,7 @@ PHP_FUNCTION(odbc_primarykeys)
table, SAFE_SQL_NTS(table) );
if (rc == SQL_ERROR) {
odbc_sql_error(conn, SQL_NULL_HSTMT, "SQLPrimaryKeys");
odbc_sql_error(conn, result->stmt, "SQLPrimaryKeys");
efree(result);
RETURN_FALSE;
}
@@ -3564,7 +3584,7 @@ PHP_FUNCTION(odbc_procedurecolumns)
col, SAFE_SQL_NTS(col) );
if (rc == SQL_ERROR) {
odbc_sql_error(conn, SQL_NULL_HSTMT, "SQLProcedureColumns");
odbc_sql_error(conn, result->stmt, "SQLProcedureColumns");
efree(result);
RETURN_FALSE;
}
@@ -3632,7 +3652,7 @@ PHP_FUNCTION(odbc_procedures)
proc, SAFE_SQL_NTS(proc) );
if (rc == SQL_ERROR) {
odbc_sql_error(conn, SQL_NULL_HSTMT, "SQLProcedures");
odbc_sql_error(conn, result->stmt, "SQLProcedures");
efree(result);
RETURN_FALSE;
}
@@ -3668,7 +3688,7 @@ PHP_FUNCTION(odbc_specialcolumns)
SQLUSMALLINT type, scope, nullable;
RETCODE rc;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "rls!ssl", &pv_conn, &vtype, &cat, &cat_len, &schema, &schema_len,
if (zend_parse_parameters(ZEND_NUM_ARGS(), "rls!ssll", &pv_conn, &vtype, &cat, &cat_len, &schema, &schema_len,
&name, &name_len, &vscope, &vnullable) == FAILURE) {
return;
}
@@ -3705,7 +3725,7 @@ PHP_FUNCTION(odbc_specialcolumns)
nullable);
if (rc == SQL_ERROR) {
odbc_sql_error(conn, SQL_NULL_HSTMT, "SQLSpecialColumns");
odbc_sql_error(conn, result->stmt, "SQLSpecialColumns");
efree(result);
RETURN_FALSE;
}
@@ -3775,7 +3795,7 @@ PHP_FUNCTION(odbc_statistics)
reserved);
if (rc == SQL_ERROR) {
odbc_sql_error(conn, SQL_NULL_HSTMT, "SQLStatistics");
odbc_sql_error(conn, result->stmt, "SQLStatistics");
efree(result);
RETURN_FALSE;
}
@@ -3838,7 +3858,7 @@ PHP_FUNCTION(odbc_tableprivileges)
table, SAFE_SQL_NTS(table));
if (rc == SQL_ERROR) {
odbc_sql_error(conn, SQL_NULL_HSTMT, "SQLTablePrivileges");
odbc_sql_error(conn, result->stmt, "SQLTablePrivileges");
efree(result);
RETURN_FALSE;
}
+62
View File
@@ -0,0 +1,62 @@
--TEST--
Bug #44618 (Fetching may rely on uninitialized data)
--SKIPIF--
<?php include 'skipif.inc'; ?>
--FILE--
<?php
include __DIR__ . "/config.inc";
$conn = odbc_connect($dsn, $user, $pass, SQL_CUR_USE_ODBC);
odbc_exec($conn, "CREATE TABLE bug44618(ID INT, real1 REAL, text1 TEXT)");
odbc_exec($conn, "INSERT INTO bug44618 VALUES (1, 10.0199995, 'testing 1,2,3')");
$result = odbc_exec($conn, "SELECT * FROM bug44618");
var_dump(odbc_fetch_array($result));
$result = null;
$result = odbc_exec($conn, "SELECT * FROM bug44618");
odbc_fetch_into($result, $array);
var_dump($array);
$result = null;
$result = odbc_exec($conn, "SELECT * FROM bug44618");
odbc_fetch_row($result);
var_dump(odbc_result($result, "text1"));
$result = null;
$result = odbc_exec($conn, "SELECT * FROM bug44618");
odbc_result_all($result);
$result = null;
?>
--CLEAN--
<?php
include __DIR__ . "/config.inc";
$conn = odbc_connect($dsn, $user, $pass);
odbc_exec($conn, "DROP TABLE bug44618");
?>
--EXPECTF--
Warning: odbc_fetch_array(): Cannot get data of column #3 (retcode 100) in %s on line %d
array(3) {
["ID"]=>
string(1) "1"
["real1"]=>
string(5) "10.02"
["text1"]=>
bool(false)
}
Warning: odbc_fetch_into(): Cannot get data of column #3 (retcode 100) in %s on line %d
array(3) {
[0]=>
string(1) "1"
[1]=>
string(5) "10.02"
[2]=>
bool(false)
}
Warning: odbc_result(): Cannot get data of column #3 (retcode 100) in %s on line %d
bool(false)
<table><tr><th>ID</th><th>real1</th><th>text1</th></tr>
<tr><td>1</td><td>10.02</td><td></td></tr></table>
Warning: odbc_result_all(): Cannot get data of column #3 (retcode 100) in %s on line %d
+27
View File
@@ -0,0 +1,27 @@
--TEST--
Bug #46050 (odbc_next_result corrupts prepared resource)
--SKIPIF--
<?php include 'skipif.inc'; ?>
--FILE--
<?php
include __DIR__ . "/config.inc";
$conn = odbc_connect($dsn, $user, $pass);
$stmt = odbc_prepare($conn, "SELECT 1");
var_dump(odbc_execute($stmt));
var_dump(odbc_fetch_array($stmt));
var_dump(odbc_next_result($stmt));
var_dump(odbc_execute($stmt));
var_dump(odbc_fetch_array($stmt));
?>
--EXPECT--
bool(true)
array(1) {
["1"]=>
string(1) "1"
}
bool(false)
bool(true)
array(1) {
["1"]=>
string(1) "1"
}
+13
View File
@@ -0,0 +1,13 @@
--TEST--
Bug #78470 (odbc_specialcolumns() no longer accepts $nullable)
--SKIPIF--
<?php include 'skipif.inc'; ?>
--FILE--
<?php
include 'config.inc';
$conn = odbc_connect($dsn, $user, $pass);
var_dump(odbc_specialcolumns($conn, SQL_BEST_ROWID, '', '', '', SQL_SCOPE_CURROW, SQL_NO_NULLS));
?>
--EXPECTF--
resource(%d) of type (odbc result)
+27
View File
@@ -0,0 +1,27 @@
--TEST--
Bug #80147 (BINARY strings may not be properly zero-terminated)
--SKIPIF--
<?php include 'skipif.inc'; ?>
--FILE--
<?php
include 'config.inc';
$conn = odbc_connect($dsn, $user, $pass);
odbc_exec($conn, "CREATE TABLE bug80147 (id INT, whatever VARBINARY(50))");
odbc_exec($conn, "INSERT INTO bug80147 VALUES (1, CONVERT(VARBINARY(50), 'whatever'))");
$res = odbc_exec($conn, "SELECT * FROM bug80147");
odbc_binmode($res, ODBC_BINMODE_RETURN);
odbc_fetch_row($res);
var_dump(odbc_result($res, 'whatever'));
?>
--CLEAN--
<?php
include 'config.inc';
$conn = odbc_connect($dsn, $user, $pass);
odbc_exec($conn, "DROP TABLE bug80147");
?>
--EXPECT--
string(8) "whatever"
+26
View File
@@ -0,0 +1,26 @@
--TEST--
Bug #80152 (odbc_execute() moves internal pointer of $params)
--SKIPIF--
<?php include 'skipif.inc'; ?>
--FILE--
<?php
include 'config.inc';
$conn = odbc_connect($dsn, $user, $pass);
odbc_exec($conn,"CREATE TABLE bug80152 (id INT, name CHAR(24))");
$stmt = odbc_prepare($conn,"INSERT INTO bug80152 (id, name) VALUES (?, ?)");
$params = [1, "John", "Lim"];
var_dump(key($params));
odbc_execute($stmt, $params);
var_dump(key($params));
?>
--CLEAN--
<?php
include 'config.inc';
$conn = odbc_connect($dsn, $user, $pass);
odbc_exec($conn, "DROP TABLE bug80152");
?>
--EXPECT--
int(0)
int(0)
+2
View File
@@ -1079,6 +1079,8 @@ uint32_t zend_optimizer_classify_function(zend_string *name, uint32_t num_args)
return ZEND_FUNC_INDIRECT_VAR_ACCESS;
} else if (zend_string_equals_literal(name, "assert")) {
return ZEND_FUNC_INDIRECT_VAR_ACCESS;
} else if (zend_string_equals_literal(name, "db2_execute")) {
return ZEND_FUNC_INDIRECT_VAR_ACCESS;
} else if (zend_string_equals_literal(name, "func_num_args")) {
return ZEND_FUNC_VARARG;
} else if (zend_string_equals_literal(name, "func_get_arg")) {
+21 -1
View File
@@ -487,7 +487,7 @@ zend_string* ZEND_FASTCALL accel_new_interned_string(zend_string *str)
} while (pos != STRTAB_INVALID_POS);
}
if (UNEXPECTED(ZCSG(interned_strings).end - ZCSG(interned_strings).top < STRTAB_STR_SIZE(str))) {
if (UNEXPECTED((char*)ZCSG(interned_strings).end - (char*)ZCSG(interned_strings).top < STRTAB_STR_SIZE(str))) {
/* no memory, return the same non-interned string */
zend_accel_error(ACCEL_LOG_WARNING, "Interned string buffer overflow");
return str;
@@ -2692,6 +2692,9 @@ static void accel_gen_system_id(void)
unsigned char digest[16], c;
char *md5str = ZCG(system_id);
int i;
zend_module_entry *module;
zend_extension *extension;
zend_llist_position pos;
PHP_MD5Init(&context);
PHP_MD5Update(&context, PHP_VERSION, sizeof(PHP_VERSION)-1);
@@ -2702,6 +2705,23 @@ static void accel_gen_system_id(void)
PHP_MD5Update(&context, __DATE__, sizeof(__DATE__)-1);
PHP_MD5Update(&context, __TIME__, sizeof(__TIME__)-1);
}
/* Modules may have changed after restart which can cause dangling pointers from
* custom opcode handlers in the second-level cache files
*/
ZEND_HASH_FOREACH_PTR(&module_registry, module) {
PHP_MD5Update(&context, module->name, strlen(module->name));
if (module->version != NULL) {
PHP_MD5Update(&context, module->version, strlen(module->version));
}
} ZEND_HASH_FOREACH_END();
extension = (zend_extension *) zend_llist_get_first_ex(&zend_extensions, &pos);
while (extension) {
PHP_MD5Update(&context, extension->name, strlen(extension->name));
if (extension->version != NULL) {
PHP_MD5Update(&context, extension->version, strlen(extension->version));
}
extension = (zend_extension *) zend_llist_get_next_ex(&zend_extensions, &pos);
}
PHP_MD5Final(digest, &context);
for (i = 0; i < 16; i++) {
c = digest[i] >> 4;
+5 -5
View File
@@ -6441,11 +6441,6 @@ static int php_openssl_validate_iv(char **piv, size_t *piv_len, size_t iv_requir
{
char *iv_new;
/* Best case scenario, user behaved */
if (*piv_len == iv_required_len) {
return SUCCESS;
}
if (mode->is_aead) {
if (EVP_CIPHER_CTX_ctrl(cipher_ctx, mode->aead_ivlen_flag, *piv_len, NULL) != 1) {
php_error_docref(NULL, E_WARNING, "Setting of IV length for AEAD mode failed");
@@ -6454,6 +6449,11 @@ static int php_openssl_validate_iv(char **piv, size_t *piv_len, size_t iv_requir
return SUCCESS;
}
/* Best case scenario, user behaved */
if (*piv_len == iv_required_len) {
return SUCCESS;
}
iv_new = ecalloc(1, iv_required_len + 1);
if (*piv_len == 0) {
+2 -1
View File
@@ -9,7 +9,8 @@ if (getenv('SKIP_ONLINE_TESTS')) die('skip online test');
default_socket_timeout=-1
--FILE--
<?php
var_dump((bool) file_get_contents('https://php.net'));
$clientCtx = stream_context_create(['ssl' => ['verify_peer' => false]]);
var_dump((bool) file_get_contents('https://www.php.net', false, $clientCtx));
?>
--EXPECT--
bool(true)
+21
View File
@@ -1,5 +1,26 @@
<?php
$php_openssl_cipher_tests = array(
'aes-128-ccm' => array(
array(
'key' => '404142434445464748494a4b4c4d4e4f',
'iv' => '1011121314151617',
'aad' => '000102030405060708090a0b0c0d0e0f',
'tag' => '1fc64fbfaccd',
'pt' => '202122232425262728292a2b2c2d2e2f',
'ct' => 'd2a1f0e051ea5f62081a7792073d593d',
),
array(
'key' => '404142434445464748494a4b4c4d4e4f',
'iv' => '101112131415161718191a1b',
'aad' => '000102030405060708090a0b0c0d0e0f' .
'10111213',
'tag' => '484392fbc1b09951',
'pt' => '202122232425262728292a2b2c2d2e2f' .
'3031323334353637',
'ct' => 'e3b201a9f5b71a7a9b1ceaeccd97e70b' .
'6176aad9a4428aa5',
),
),
'aes-256-ccm' => array(
array(
'key' => '1bde3251d41a8b5ea013c195ae128b21' .
+14 -8
View File
@@ -10,14 +10,16 @@ if (!in_array('aes-256-ccm', openssl_get_cipher_methods()))
--FILE--
<?php
require_once __DIR__ . "/cipher_tests.inc";
$method = 'aes-256-ccm';
$tests = openssl_get_cipher_tests($method);
$methods = ['aes-128-ccm', 'aes-256-ccm'];
foreach ($tests as $idx => $test) {
echo "TEST $idx\n";
$pt = openssl_decrypt($test['ct'], $method, $test['key'], OPENSSL_RAW_DATA,
$test['iv'], $test['tag'], $test['aad']);
var_dump($test['pt'] === $pt);
foreach ($methods as $method) {
$tests = openssl_get_cipher_tests($method);
foreach ($tests as $idx => $test) {
echo "$method - TEST $idx\n";
$pt = openssl_decrypt($test['ct'], $method, $test['key'], OPENSSL_RAW_DATA,
$test['iv'], $test['tag'], $test['aad']);
var_dump($test['pt'] === $pt);
}
}
// no IV
@@ -32,7 +34,11 @@ var_dump(openssl_decrypt($test['ct'], $method, $test['key'], OPENSSL_RAW_DATA,
?>
--EXPECTF--
TEST 0
aes-128-ccm - TEST 0
bool(true)
aes-128-ccm - TEST 1
bool(true)
aes-256-ccm - TEST 0
bool(true)
Warning: openssl_decrypt(): Setting of IV length for AEAD mode failed in %s on line %d
+17 -9
View File
@@ -10,15 +10,17 @@ if (!in_array('aes-256-ccm', openssl_get_cipher_methods()))
--FILE--
<?php
require_once __DIR__ . "/cipher_tests.inc";
$method = 'aes-256-ccm';
$tests = openssl_get_cipher_tests($method);
$methods = ['aes-128-ccm', 'aes-256-ccm'];
foreach ($tests as $idx => $test) {
echo "TEST $idx\n";
$ct = openssl_encrypt($test['pt'], $method, $test['key'], OPENSSL_RAW_DATA,
$test['iv'], $tag, $test['aad'], strlen($test['tag']));
var_dump($test['ct'] === $ct);
var_dump($test['tag'] === $tag);
foreach ($methods as $method) {
$tests = openssl_get_cipher_tests($method);
foreach ($tests as $idx => $test) {
echo "$method - TEST $idx\n";
$ct = openssl_encrypt($test['pt'], $method, $test['key'], OPENSSL_RAW_DATA,
$test['iv'], $tag, $test['aad'], strlen($test['tag']));
var_dump($test['ct'] === $ct);
var_dump($test['tag'] === $tag);
}
}
// Empty IV error
@@ -32,7 +34,13 @@ var_dump(strlen($tag));
var_dump(openssl_encrypt('data', $method, 'password', 0, str_repeat('x', 16), $tag, '', 1024));
?>
--EXPECTF--
TEST 0
aes-128-ccm - TEST 0
bool(true)
bool(true)
aes-128-ccm - TEST 1
bool(true)
bool(true)
aes-256-ccm - TEST 0
bool(true)
bool(true)
+6 -1
View File
@@ -163,6 +163,10 @@ static int dispatch_param_event(pdo_stmt_t *stmt, enum pdo_param_event event_typ
struct pdo_bound_param_data *param;
HashTable *ht;
if (stmt->dbh->skip_param_evt & (1 << event_type)) {
return 1;
}
if (!stmt->methods->param_hook) {
return 1;
}
@@ -1869,7 +1873,8 @@ int pdo_stmt_setup_fetch_mode(INTERNAL_FUNCTION_PARAMETERS, pdo_stmt_t *stmt, in
mode = Z_LVAL(args[skip]);
flags = mode & PDO_FETCH_FLAGS;
retval = pdo_stmt_verify_mode(stmt, mode, 0);
/* pdo_stmt_verify_mode() returns a boolean value */
retval = pdo_stmt_verify_mode(stmt, mode, 0) ? SUCCESS : FAILURE;
}
}
+4 -1
View File
@@ -468,9 +468,12 @@ struct _pdo_dbh_t {
/* when set, convert int/floats to strings */
unsigned stringify:1;
/* bitmap for pdo_param_event(s) to skip in dispatch_param_event */
unsigned skip_param_evt:7;
/* the sum of the number of bits here and the bit fields preceding should
* equal 32 */
unsigned _reserved_flags:21;
unsigned _reserved_flags:14;
/* data source string used to open this handle */
const char *data_source;
+2 -7
View File
@@ -66,13 +66,8 @@ if test "$PHP_PDO_MYSQL" != "no"; then
if test "x$SED" = "x"; then
AC_PATH_PROG(SED, sed)
fi
if test "$enable_maintainer_zts" = "yes"; then
PDO_MYSQL_LIBNAME=mysqlclient_r
PDO_MYSQL_LIBS=`$PDO_MYSQL_CONFIG --libs_r | $SED -e "s/'//g"`
else
PDO_MYSQL_LIBNAME=mysqlclient
PDO_MYSQL_LIBS=`$PDO_MYSQL_CONFIG --libs | $SED -e "s/'//g"`
fi
PDO_MYSQL_LIBNAME=mysqlclient
PDO_MYSQL_LIBS=`$PDO_MYSQL_CONFIG --libs | $SED -e "s/'//g"`
PDO_MYSQL_INCLUDE=`$PDO_MYSQL_CONFIG --cflags | $SED -e "s/'//g"`
elif test -n "$PDO_MYSQL_DIR"; then
AC_MSG_RESULT([not found])
+14 -2
View File
@@ -293,6 +293,11 @@ static char *pdo_mysql_last_insert_id(pdo_dbh_t *dbh, const char *name, size_t *
}
/* }}} */
#if defined(PDO_USE_MYSQLND) || MYSQL_VERSION_ID < 50707 || defined(MARIADB_BASE_VERSION)
# define mysql_real_escape_string_quote(mysql, to, from, length, quote) \
mysql_real_escape_string(mysql, to, from, length)
#endif
/* {{{ mysql_handle_quoter */
static int mysql_handle_quoter(pdo_dbh_t *dbh, const char *unquoted, size_t unquotedlen, char **quoted, size_t *quotedlen, enum pdo_param_type paramtype )
{
@@ -315,13 +320,13 @@ static int mysql_handle_quoter(pdo_dbh_t *dbh, const char *unquoted, size_t unqu
*quoted = safe_emalloc(2, unquotedlen, 3 + (use_national_character_set ? 1 : 0));
if (use_national_character_set) {
*quotedlen = mysql_real_escape_string(H->server, *quoted + 2, unquoted, unquotedlen);
*quotedlen = mysql_real_escape_string_quote(H->server, *quoted + 2, unquoted, unquotedlen, '\'');
(*quoted)[0] = 'N';
(*quoted)[1] = '\'';
++*quotedlen; /* N prefix */
} else {
*quotedlen = mysql_real_escape_string(H->server, *quoted + 1, unquoted, unquotedlen);
*quotedlen = mysql_real_escape_string_quote(H->server, *quoted + 1, unquoted, unquotedlen, '\'');
(*quoted)[0] = '\'';
}
@@ -617,6 +622,13 @@ static int pdo_mysql_handle_factory(pdo_dbh_t *dbh, zval *driver_options)
dbh->driver_data = H;
dbh->skip_param_evt =
1 << PDO_PARAM_EVT_FREE |
1 << PDO_PARAM_EVT_EXEC_POST |
1 << PDO_PARAM_EVT_FETCH_PRE |
1 << PDO_PARAM_EVT_FETCH_POST |
1 << PDO_PARAM_EVT_NORMALIZE;
#ifndef PDO_USE_MYSQLND
H->max_buffer_size = 1024*1024;
#endif
Loaded 100 of 158 files, more files were not shown because too many files have changed in this diff. Show more