1
0
mirror of https://github.com/php/php-src.git synced 2026-04-21 23:18:13 +02:00
Commit Graph

62407 Commits

Author SHA1 Message Date
Christoph M. Becker baebb730b4 Merge branch 'PHP-8.1'
* PHP-8.1:
  Initialize blacklist_path_length
2022-07-25 19:12:12 +02:00
Christoph M. Becker 7d36703a8f Initialize blacklist_path_length
For some reason, GCC warns[1]:

| ‘blacklist_path_length’ may be used uninitialized in this function
| [-Werror=maybe-uninitialized]

This looks like a false positive to me, but it doesn't hurt to
explicitly initialize the variable.

[1] <https://github.com/php/php-src/runs/7502212969?check_suite_focus=true>

Closes GH-9129.
2022-07-25 19:10:42 +02:00
Máté Kocsis a05a6c555d Declare ext/soap constants in stubs (#9124) 2022-07-25 16:40:41 +02:00
Christoph M. Becker f78ae8d114 Merge branch 'PHP-8.1'
* PHP-8.1:
  Fix GH-9033: Loading blacklist file can fail due to negative length
2022-07-25 16:33:15 +02:00
Christoph M. Becker 4834cfea1a Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix GH-9033: Loading blacklist file can fail due to negative length
2022-07-25 16:32:18 +02:00
Christoph M. Becker 35fd97c3c9 Fix GH-9033: Loading blacklist file can fail due to negative length
If the blacklist file contains a line with a single double-quote, we
called `zend_strndup(pbuf, -1)` what causes an unnecessary bail out;
instead we just ignore that line.

If the blacklist file contains an empty line, we may have caused an OOB
read; instead we just ignore that line.

Closes GH-9036.
2022-07-25 16:30:19 +02:00
Máté Kocsis 4ad7e7251d Declare ext/sysvmsg constants in stubs (#9125)
Co-authored-by: Christoph M. Becker <cmbecker69@gmx.de>
2022-07-25 16:21:01 +02:00
Dmitry Stogov 87cf05e8be Merge branch 'PHP-8.1'
* PHP-8.1:
  Fix type inference
2022-07-25 15:55:15 +03:00
Dmitry Stogov d50875c822 Fix type inference
Fixes oss-fuzz #49423 and #49474
2022-07-25 15:53:06 +03:00
Dmitry Stogov 9d52081741 Merge branch 'PHP-8.1'
* PHP-8.1:
  JIT: Fix missing type stote
2022-07-25 15:25:08 +03:00
Dmitry Stogov e70d282077 JIT: Fix missing type stote
Fixes oss-fuzz #49402
2022-07-25 15:24:26 +03:00
Dmitry Stogov 4227fddf4d Merge branch 'PHP-8.1'
* PHP-8.1:
  Fix memory leak
2022-07-25 12:08:09 +03:00
Dmitry Stogov cc465ba0bb Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix memory leak
2022-07-25 12:08:00 +03:00
Dmitry Stogov 44b86aee31 Fix memory leak
Fixes oss-fuzz #49272
2022-07-25 12:04:46 +03:00
Tim Düsterhus 60f149f7ad Improve error reporting in random extension (#9071)
* Use `php_random_bytes_throw()` in Secure engine's generate()

This exposes the underlying exception, improving debugging:

    Fatal error: Uncaught Exception: Cannot open source device in php-src/test.php:5
    Stack trace:
    #0 php-src/test.php(5): Random\Engine\Secure->generate()
    #1 {main}

    Next RuntimeException: Random number generation failed in php-src/test.php:5
    Stack trace:
    #0 php-src/test.php(5): Random\Engine\Secure->generate()
    #1 {main}
      thrown in php-src/test.php on line 5

* Use `php_random_int_throw()` in Secure engine's range()

This exposes the underlying exception, improving debugging:

    Exception: Cannot open source device in php-src/test.php:17
    Stack trace:
    #0 php-src/test.php(17): Random\Randomizer->getInt(1, 3)
    #1 {main}

    Next RuntimeException: Random number generation failed in php-src/test.php:17
    Stack trace:
    #0 php-src/test.php(17): Random\Randomizer->getInt(1, 3)
    #1 {main}

* Throw exception when a user engine returns an empty string

This improves debugging, because the actual reason for the failure is available
as a previous Exception:

    DomainException: The returned string must not be empty in php-src/test.php:17
    Stack trace:
    #0 php-src/test.php(17): Random\Randomizer->getBytes(123)
    #1 {main}

    Next RuntimeException: Random number generation failed in php-src/test.php:17
    Stack trace:
    #0 php-src/test.php(17): Random\Randomizer->getBytes(123)
    #1 {main}

* Throw exception when the range selector fails to get acceptable numbers in 50 attempts

This improves debugging, because the actual reason for the failure is available
as a previous Exception:

    RuntimeException: Failed to generate an acceptable random number in 50 attempts in php-src/test.php:17
    Stack trace:
    #0 php-src/test.php(17): Random\Randomizer->getInt(1, 3)
    #1 {main}

    Next RuntimeException: Random number generation failed in php-src/test.php:17
    Stack trace:
    #0 php-src/test.php(17): Random\Randomizer->getInt(1, 3)
    #1 {main}

* Improve user_unsafe test

Select parameters for ->getInt() that will actually lead to unsafe behavior.

* Fix user_unsafe test

If an engine fails once it will be permanently poisoned by setting
`->last_unsafe`. This is undesirable for the test, because it skews the
results.

Fix this by creating a fresh engine for each "assertion".

* Remove duplication in user_unsafe.phpt

* Catch `Throwable` in user_unsafe.phpt

As we print the full stringified exception we implicitly assert the type of the
exception. No need to be overly specific in the catch block.

* Throw an error if an engine returns an empty string

* Throw an Error if range fails to find an acceptable number in 50 attempts
2022-07-25 09:00:49 +02:00
Go Kudo 34b352d121 Fix memory leak on Randomizer::__construct() call twice (#9091)
When Radomizer::__construct() was called with no arguments, Randomizer\Engine\Secure was implicitly instantiate and memory was leaking.
Co-authored-by: Tim Düsterhus <timwolla@googlemail.com>
2022-07-24 03:09:14 +09:00
George Peter Banyard 3c372901bd Add support to pass driver flags to DBA handlers
Currently only LMDB with DBA_LMDB_USE_SUB_DIR/DBA_LMDB_NO_SUB_DIR are supported
2022-07-23 18:38:27 +01:00
George Peter Banyard 79d831ff9f Pass MDB_RDONLY to the LMDB environment for readonly DBs 2022-07-23 18:38:27 +01:00
George Peter Banyard 0887a1d7ab Remove personalisation from write on readonly db DBA error message 2022-07-23 18:38:27 +01:00
George Peter Banyard c8ba00f627 Add comment in GDBM informing to what param the 0 org corresponds to 2022-07-23 18:38:27 +01:00
Tim Düsterhus 395b6a9674 Remove dead code in ext/random/random.c (#9114)
see GH-9070
2022-07-23 13:14:31 +02:00
Máté Kocsis e4d79ce24c Declare ext/reflection constants in stubs (#9111) 2022-07-23 12:59:30 +02:00
Máté Kocsis c854816b65 Declare ext/readline constants in stubs (#9110) 2022-07-23 12:33:44 +02:00
Máté Kocsis a98560ad3f Declare ext/session constants in stubs (#9112) 2022-07-23 12:32:21 +02:00
Máté Kocsis 98be397776 Declare ext/random constants in stubs (#9109) 2022-07-23 12:32:01 +02:00
Michael Voříšek b0c0a2cfb4 Use -1 "precision" in gen_stub.php
Closes GH-8734.
2022-07-23 12:09:37 +02:00
Michael Voříšek fc42098c23 Fix typo in lob_prefetch_ini.phpt test (#9099) 2022-07-22 17:17:03 +01:00
Derick Rethans 1d0e5eddd5 Add test case for bug #80483/#75035 2022-07-22 15:34:57 +01:00
Derick Rethans 6ae86c2358 Fixed bug #80022: Support ISO 8601 years outside 0000-9999 range better 2022-07-22 15:34:57 +01:00
Derick Rethans 8ea587a305 Import timelib 2022.01 2022-07-22 15:34:57 +01:00
Derick Rethans b1575f996c Merge branch 'PHP-8.1' 2022-07-22 13:08:11 +01:00
Derick Rethans 0ae9942801 Merge remote-tracking branch 'derickr/timelib-2021-15-sync' into PHP-8.1 2022-07-22 13:07:28 +01:00
Derick Rethans 7831a1cae6 Add test case for GH-8964 2022-07-22 13:06:32 +01:00
Derick Rethans 0d3061d225 Import timelib 2021.15 2022-07-22 13:06:32 +01:00
George Peter Banyard 4457dba1fb Add support for stubs to declare intersection type class properties (#8751) 2022-07-22 13:04:49 +01:00
David CARLIER 77bd39a116 crc32 Aarch64 add crc feature to crc32_aarch64 from clang
Closes #8916.
2022-07-22 12:46:11 +01:00
Máté Kocsis 6ab897c8d3 Declare ext/phar constants in stubs (#9094) 2022-07-22 13:09:23 +02:00
Máté Kocsis 17f3631d95 Declare ext/posix constants in stubs (#9095) 2022-07-22 13:08:58 +02:00
Máté Kocsis f72d264560 Declare ext/pspell constants in stubs (#9096) 2022-07-22 13:08:44 +02:00
Tim Düsterhus ab5491f505 Fix shift in rand_rangeXX() (#9088)
The previous shifting logic is problematic for two reasons:

1. It invokes undefined behavior when the `->last_generated_size` is at least
as large as the target integer in `result`, because the shift is larger than
the target integer. This was reported in GH-9083.

2. It expands the returned bytes in a big-endian fashion: Earlier bytes are
shifting into the most-significant position. As all the other logic in the
random extension treats byte-strings as little-endian numbers this is
inconsistent.

By fixing the second issue, we can implicitly fix the first one: Instead of
shifting the existing bits by the number of "newly added" bits, we shift the
newly added bits by the number of existing bits. As we stop requesting new bits
once the total_size reached the size of the target integer we can be sure to
never invoke undefined behavior during shifting.

The get_int_user.phpt test was adjusted to verify the little-endian behavior.
It generates a single byte per call and we expect the first byte generated to
appear at the start of the resulting number.

see GH-9056 for a previous fix in the same area.
Fixes GH-9083 which reports the undefined behavior.
Resolves GH-9085 which was an alternative attempt to fix GH-9083.
2022-07-22 10:45:17 +01:00
Máté Kocsis dd00296722 Declare ext/pdo constants in stubs (#9078) 2022-07-22 09:46:47 +02:00
Go Kudo 133b9b08da Avoid signed integer overflow in php_random_range() (#9066) 2022-07-22 10:57:32 +09:00
Go Kudo e4c894984f [ci skip] Update EXTENSIONS and Author(s) in ext/random (#9074)
php.net account is better suited for this cases.
2022-07-21 17:53:32 +02:00
Ilija Tovilo 5c10aa43c2 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix spl test cleanup
2022-07-21 17:21:18 +02:00
Ilija Tovilo 3962f00b01 Fix spl test cleanup 2022-07-21 17:20:30 +02:00
Ilija Tovilo b5ab0e06b8 Assert all test files are cleaned up in CI (#8977)
Closes GH-8427
2022-07-21 16:06:14 +01:00
George Peter Banyard cd640778f7 [skip ci] Add comment about LMDB env_close function call 2022-07-21 14:48:25 +01:00
George Peter Banyard 11c424c9fb Remove unnecessary include in SPL 2022-07-21 14:46:39 +01:00
George Peter Banyard d0542a6b5c Merge branch 'PHP-8.1'
* PHP-8.1:
  Update NEWS
  Fix memory leak in LMDB driver
2022-07-21 14:10:01 +01:00
George Peter Banyard c7a0439d60 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix memory leak in LMDB driver
2022-07-21 14:08:40 +01:00