Commit Graph

131540 Commits

Author SHA1 Message Date
George Peter Banyard
3b06618813
RFC: Saner array_(sum|product)() (#10161)
RFC: https://wiki.php.net/rfc/saner-array-sum-product

Moreover, the internal fast_add_function() function was removed.
2023-03-07 15:40:17 +00:00
Michael Orlitzky
88b30e08cc ext/iconv/config.m4: add missing stdio.h include.
The next generation of C compilers is going to enforce the C standard
more strictly:

  https://wiki.gentoo.org/wiki/Modern_C_porting

One warning that will eventually become an error is
-Wimplicit-function-declaration. This is relatively easy to catch in
most code (it will fail to compile), but inside of autoconf tests it
can go unnoticed because many feature-test compilations fail by
design. For example,

  AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <iconv.h>]],
                 [[iconv_ccs_init(NULL, NULL);]])]...

is designed to fail if iconv_ccs_init() is not in iconv.h. On the
other hand,

  AC_RUN_IFELSE([AC_LANG_SOURCE([[
  #include <iconv.h>
  int main() {
    printf("%d", _libiconv_version);
    return 0;
  }

should pass if _libiconv_version is defined. If the user has
-Werror=implicit-function-declaration in his CFLAGS, however,
it will not:

  $ export CFLAGS="$CFLAGS -Werror=implicit-function-declaration"
  $ ./configure
  ...
  checking if using GNU libiconv... no

This is because the stdio.h header that defines printf() is missing:

  conftest.c:240:3: error: implicit declaration of function 'printf'
  [-Werror=implicit-function-declaration]
    240 |   printf("%d", _libiconv_version);
        |   ^~~~~~
  conftest.c:239:1: note: include '<stdio.h>' or provide a declaration
  of 'printf'

This commit adds the include, correcting the test with any compiler
that balks at implicit function definitions.

Closes GH-10751
2023-03-07 15:32:30 +00:00
Michael Orlitzky
fa65873502 */*.m4: update main() signatures.
The next generation of C compilers is going to enforce the C standard
more strictly:

  https://wiki.gentoo.org/wiki/Modern_C_porting

One warning that will soon become an error is -Wstrict-prototypes.
This is relatively easy to catch in most code (it will fail to
compile), but inside of autoconf tests it can go unnoticed because
many feature-test compilations fail by design. For example,

  $ export CFLAGS="$CFLAGS -Werror=strict-prototypes"
  $ ./configure
  ...
  checking if iconv supports errno... no
  configure: error: iconv does not support errno

(this is on a system where iconv *does* support errno). If errno
support were optional, that test would have "silently" disabled
it. The underlying issue here, from config.log, is

  conftest.c:211:5: error: function declaration isn't a prototype
  [-Werror=strict-prototypes]
    211 | int main() {

This commit goes through all of our autoconf tests, replacing main()
with main(void). Up to equivalent types and variable renamings, that's
one of the two valid signatures, and satisfies the compiler (gcc-12 in
this case).

Fixes GH-10751
2023-03-07 15:32:30 +00:00
Ilija Tovilo
3f7dadfeca
Fix readonly+clone JIT issues
Closes GH-10748
2023-03-07 13:20:52 +01:00
Ilija Tovilo
ff71c9e159
Merge branch 'PHP-8.2'
* PHP-8.2:
  Enable GitHub actions cancel-in-progress for PRs
2023-03-07 11:03:07 +01:00
Ilija Tovilo
805dafddbb
Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Enable GitHub actions cancel-in-progress for PRs
  mb_encode_mimeheader does not crash if provided encoding has no MIME name set
2023-03-07 11:02:00 +01:00
Ilija Tovilo
cfe1aab865
Enable GitHub actions cancel-in-progress for PRs
Pushing many commits to a pull request in a short amount of time can stall the
merge builds and also wastes energy unnecessarily. Enable concurrency to cancel
workflows of old commits in pull requests. Generate a common group name for pull
requests using github.event.pull_request.url with github.run_id as a fallback
for branches, which is unique and always available.

Closes GH-10799
2023-03-07 11:00:35 +01:00
Alex Dowad
17f72502d9 Merge branch 'PHP-8.2'
* PHP-8.2:
  mb_encode_mimeheader does not crash if provided encoding has no MIME name set
2023-03-07 11:32:44 +02:00
Alex Dowad
d60833b079 Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  mb_encode_mimeheader does not crash if provided encoding has no MIME name set
2023-03-07 11:31:07 +02:00
Alex Dowad
7c1ee5a02a mb_encode_mimeheader does not crash if provided encoding has no MIME name set 2023-03-07 11:30:21 +02:00
Máté Kocsis
368febbf89
Remove unnecessary workaround for the true type 2023-03-07 09:08:16 +01:00
George Peter Banyard
648e896d0e
Fix [-Wstrict-prototypes] in DBA
I've missed this case while doing all the other ones.
2023-03-06 17:03:41 +00:00
Tim Düsterhus
08bae7f370
Merge branch 'PHP-8.2'
* PHP-8.2:
  random: Add missing `php.h` include to php_random.h (#10764)
2023-03-06 17:34:24 +01:00
Tim Düsterhus
5087931963
random: Add missing php.h include to php_random.h (#10764)
`PHPAPI` is defined in `php.h`. It appears that without the explicit include,
recent versions of Visual Studio Code’s intellisense (rightfully) no longer
detect `PHPAPI`. This will then lead to a misparsing of the file, because
`PHPAPI` is assumed to be the return type and the actual return type is assumed
to be the function name, thus expecting a semicolon after the actual return
type. This in turn colors the entire header in red due to the detected syntax
error(s), making development very hard / impossible.

This did not cause issues outside of the IDE use case, because apparently all
users of `php_random.h` include `php.h` before including `php_random.h`.
2023-03-06 17:33:52 +01:00
Ilija Tovilo
9f591c9bf6
Revert "Throw on negative setcookie expiration timestamp"
This reverts commit 82dfd93b9d.
2023-03-06 16:32:46 +01:00
Ilija Tovilo
486fb80947
[skip ci] Remove accidental run-tests.php line 2023-03-06 15:05:11 +01:00
Ilija Tovilo
9944f58d3f
Merge branch 'PHP-8.2'
* PHP-8.2:
  Fix GH-10709: UAF in recursive AST evaluation
2023-03-06 15:03:19 +01:00
Ilija Tovilo
1978a7b393
Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix GH-10709: UAF in recursive AST evaluation
2023-03-06 14:58:25 +01:00
Ilija Tovilo
7202fe16b7
Fix GH-10709: UAF in recursive AST evaluation
Fixes https://oss-fuzz.com/testcase-detail/6445949468934144
Closes GH-10718
2023-03-06 14:55:34 +01:00
Ilija Tovilo
87e3513274
Re-add missing EXPECTHEADERS sections
--bless removes them when there are changes in the expect section...
2023-03-06 14:46:58 +01:00
Ilija Tovilo
2110398dee
Fix missing return FAILURE 2023-03-06 14:44:36 +01:00
Ilija Tovilo
82dfd93b9d
Throw on negative setcookie expiration timestamp
Fixes GH-10765
2023-03-06 14:01:17 +01:00
Niels Dossche
aef5250eae Merge branch 'PHP-8.2'
* PHP-8.2:
  Add missing error check on PEM_write_bio_PKCS7()
  Add missing error check on PEM_write_bio_CMS()
  Add missing error check on i2d_PKCS12_bio()
  Add missing error checks on EVP_MD_CTX_create() and EVP_VerifyInit()
2023-03-05 22:16:23 +01:00
Niels Dossche
a13cca8a81 Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Add missing error check on PEM_write_bio_PKCS7()
  Add missing error check on PEM_write_bio_CMS()
  Add missing error check on i2d_PKCS12_bio()
  Add missing error checks on EVP_MD_CTX_create() and EVP_VerifyInit()
2023-03-05 22:12:36 +01:00
Niels Dossche
22c9e7e27e Add missing error check on PEM_write_bio_PKCS7()
Closes GH-10752.
2023-03-05 22:07:43 +01:00
nielsdos
51ea4a680d Add missing error check on PEM_write_bio_CMS()
On failure, this function returns 0. 2 other callers of this function
already check the return value, but this one was missed.
2023-03-05 22:06:23 +01:00
nielsdos
d2ef1561fb Add missing error check on i2d_PKCS12_bio()
This function returns 0 on error and 1 on success. The error case was
not checked and the function therefore would've returned true.
The only other caller of i2d_PKCS12_bio() in the file has
a correct error check.

Closes GH-10761.
2023-03-05 22:05:53 +01:00
Niels Dossche
30ebecb1d4 Add missing error checks on EVP_MD_CTX_create() and EVP_VerifyInit()
The first one returns NULL on error, and the second one returns 0 on
error. These weren't checked.

Closes GH-10762.
2023-03-05 22:05:11 +01:00
Ilija Tovilo
6a7115359e
Fix gcc warnings in zend_API.c with --disable-debug (#10786)
-Warray-bounds complains about malloc(sizeof(zend_arg_info) * num_args) being
smaller than zend_function when dereferencing reg_function.
2023-03-05 21:38:05 +01:00
Ilija Tovilo
95fbd2039f
Fix -Wmaybe-uninitialized warning in JIT 2023-03-05 21:35:22 +01:00
Ilija Tovilo
ad7b90b674
Ignore -Warray-bounds compiler warning in JIT (#10789)
The out-of-bounds pointer is intentional.
2023-03-05 21:30:03 +01:00
Ilija Tovilo
9f1269a34e
[skip ci] fix typo in comment 2023-03-05 21:28:50 +01:00
Ilija Tovilo
5904952af9
Fix metaphone encode compiler warning
warning: array subscript -65 is below array bounds of ‘const char[26]‘
[-Warray-bounds]

Errors like these sometimes only appear with optimizations when inlining/loop
unrolling.

Closes GH-10788
2023-03-05 21:27:25 +01:00
Ilija Tovilo
9fadf6d96b
Merge branch 'PHP-8.2'
* PHP-8.2:
  Update windows action to checkout@v3
2023-03-05 17:50:50 +01:00
Ilija Tovilo
256d23ca26
Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Update windows action to checkout@v3
2023-03-05 17:50:40 +01:00
Ilija Tovilo
28ef654648
Update windows action to checkout@v3 2023-03-05 17:50:22 +01:00
Niels Dossche
43c71dfe52 Merge branch 'PHP-8.2'
* PHP-8.2:
  Fix GH-10766: PharData archive created with Phar::Zip format does not keep files metadata (datetime)
2023-03-05 00:05:42 +01:00
Niels Dossche
d8294f2824 Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix GH-10766: PharData archive created with Phar::Zip format does not keep files metadata (datetime)
2023-03-04 23:57:03 +01:00
Niels Dossche
e633be3e87 Fix GH-10766: PharData archive created with Phar::Zip format does not keep files metadata (datetime)
Due to an incorrect check, the datetime was never actually set.
To test this we need to write the file using phar, but read the file
using a different method to not get a cached, or a value that's been
transformed twice and is therefore accidentally correct.

Closes GH-10769
2023-03-04 23:43:48 +01:00
Alex Dowad
86ec0bc55c Fix failure of AVX2-accelerated mb_check_encoding on 32-bit MS Windows
Thanks to Ilija Tovilo for noticing and reporting this problem. Thanks
also to Michael Voříšek for finding the StackOverflow post which
explained the reason for the failure.
2023-03-04 20:42:41 +02:00
Tim Düsterhus
8abea1b3c2
random: Convert php_random_(bytes|int)_(silent|throw) into inline functions (#10763)
Compared to macros, inline functions are more robust and easier to debug.

Also, use true/false at the same time instead of 1 and 0.
2023-03-04 03:33:22 +00:00
David CARLIER
3310463484 Revert "Zend/zend_type_code: remove hard-coded integer values and"
This reverts commit c7637ed1c0.
2023-03-03 21:19:58 +00:00
David Carlier
244b883c07 Merge branch 'PHP-8.2' 2023-03-03 21:12:27 +00:00
David Carlier
eb9d556fd4 Merge branch 'PHP-8.1' into PHP-8.2 2023-03-03 21:12:04 +00:00
David Carlier
574a7e7ef8 ext/ftp fix ftp_nb_get signature (for failure).
ref: https://github.com/php/doc-en/pull/2331#issuecomment-1448984096

Closes GH-10760.
2023-03-03 21:08:16 +00:00
Máté Kocsis
e053ba0a3a
Do not allow side-effects when readonly property modification fails (#10757) 2023-03-03 19:53:42 +01:00
Derick Rethans
792400bc68 Merge branch 'PHP-8.2' 2023-03-03 16:52:51 +00:00
Derick Rethans
bbcc1dadea Merge branch 'PHP-8.1' into PHP-8.2 2023-03-03 16:52:26 +00:00
Derick Rethans
7fcea9d260 Add missing ZEND_ARG_VARIADIC_OBJ_TYPE_MASK macro, and use consistent class_name variable name 2023-03-03 16:51:51 +00:00
Ilija Tovilo
cfba9cd4bd
Merge branch 'PHP-8.2'
* PHP-8.2:
  Propagate success status of ftp_close() to userland
2023-03-03 15:26:51 +01:00