1
0
mirror of https://github.com/php/php-src.git synced 2026-04-23 07:58:20 +02:00
Commit Graph

227 Commits

Author SHA1 Message Date
DanielEScherzer 5dd0575698 Generated arginfo header files: combine preprocessor conditional blocks (#15736)
When functions' or class methods' availability is based on some preprocessor
condition, the generated arginfo header files wrap the declarations in the
preprocessor `#if` conditional blocks, one per declaration, even if they are in
the same conditional block based on comments in the stub file. Instead of
having multiple conditional blocks one after the other with the same condition,
combine them into a single conditional block.
2024-09-04 13:04:22 +02:00
DanielEScherzer 53cb89670c Generated arginfo header files: remove empty zend_function_entry arrays (#15705)
When a class (or enum) has no methods, rather than using an array that only
contains `ZEND_FE_END`, use `NULL` for the functions. The implementation of
class registration for internal classes, `do_register_internal_class()` in
zend_API.c, already skips classes where the functions are `NULL`. By removing
these unneeded arrays, we can reduce the size of the header files, while also
removing an unneeded call to zend_register_functions() for each internal class
with no extra methods.
2024-09-03 23:19:53 +02:00
Máté Kocsis 8d12f666ae Fix registration of internal readonly child classes (#15459)
Currently, internal classes are registered with the following code:

INIT_CLASS_ENTRY(ce, "InternalClass", class_InternalClass_methods);
class_entry = zend_register_internal_class_ex(&ce, NULL);
class_entry->ce_flags |= ...;

This has worked well so far, except if InternalClass is readonly. It is because some inheritance checks are run by zend_register_internal_class_ex before ZEND_ACC_READONLY_CLASS is added to ce_flags.

The issue is fixed by adding a zend_register_internal_class_with_flags() zend API function that stubs can use from now on. This function makes sure to add the flags before running any checks. Since the new API is not available in lower PHP versions, gen_stub.php has to keep support for the existing API for PHP 8.3 and below.
2024-08-24 12:36:54 +02:00
Peter Kokot bb35da336d Autotools: Sync CS in extensions (#15343)
- Redundant double quotes removed
- AS_* macros used
- Few nits adjusted here and there
2024-08-11 17:42:26 +02:00
Peter Kokot f661223685 Update ext/sodium preprocessor macro help texts (#15270)
The sodium extension was initially named "libsodium" in PECL and was
renamed to sodium when it was bundled to php-src. The HAVE_LIBSODIUMLIB
symbol here could indicate that PHP extension sodium is available.

Otherwise the macro is not used in the current code base. Header
php_libsodium.h became "installed"/public as of PHP-8.4.

[skip ci]
2024-08-08 08:27:22 +02:00
Peter Kokot 1ceadaed52 Autotools: Normalize and quote all PHP_NEW_EXTENSION arguments (#15144)
This adds Autoconf quote characters to all PHP_NEW_EXTENSION arguments
and syncs the CS across the php-src Autotools build system.
2024-07-29 00:14:59 +02:00
Peter Kokot 68ae477796 Autotools: Quote M4 arguments (#15033)
- PHP_ADD_INCLUDE
- PHP_EVAL_INCLINE
- PHP_EVAL_LIBLINE
2024-07-20 07:21:44 +02:00
Peter Kokot bee84c0468 Autotools: Quote PHP_SUBST arguments in extensions (#14748) 2024-07-02 06:56:18 +02:00
Peter Kokot aae237aad5 Add missing sodium.h header (#14515)
The php_libsodium.h uses SODIUM_LIBRARY_VERSION_* macros from the
sodium.h (sodium/version.h) header.
2024-06-09 07:17:46 +02:00
Gina Peter Banyard fd2d869642 Clean-up some more headers (#14416)
Remove unused headers (such as php_ini.h for extensions that don't define INI settings)
Use more specific headers when possible
2024-06-08 17:15:36 +01:00
Niels Dossche 8faaf3faac Merge branch 'PHP-8.3'
* PHP-8.3:
  Fix memory leaks in ext/sodium on failure of some functions
2024-05-23 22:41:03 +02:00
Niels Dossche af444f97e1 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix memory leaks in ext/sodium on failure of some functions
2024-05-23 22:40:54 +02:00
Niels Dossche 4da46107c4 Fix memory leaks in ext/sodium on failure of some functions
Infallible in practice right now, but should be fixed as infallible today does not mean infallible tomorrow:
- sodium_crypto_sign_publickey_from_secretkey
- sodium_crypto_kx_seed_keypair
- sodium_crypto_kx_keypair
- sodium_crypto_auth
- sodium_crypto_sign_ed25519_sk_to_curve25519
- sodium_pad

Fallible today:
- sodium_crypto_sign_ed25519_pk_to_curve25519

Closes GH-14309.
2024-05-23 22:40:28 +02:00
Peter Kokot 39b48f8473 Add -Wno-type-limits and -Wno-logical-op only on 32-bit (#14271)
For ext/sodium these two flags can be added conditionally only for the
32-bit target architecture.
2024-05-20 12:31:07 +02:00
Máté Kocsis f2e199e878 Implement "support doc comments for internal classes and functions" (#13266)
Fixes #13130
2024-02-25 08:41:31 +01:00
Máté Kocsis 10957e498c Do not generate frameless info items when func info generation is disabled
While here, I fixed newlines around arginfo and function entry generation. Previously, newlines were repeated.
2024-02-18 11:39:00 +01:00
haszi 20c49f8524 Move PASSWORD constants to stubs (#13349) 2024-02-12 22:37:32 +01:00
Peter Kokot 52dba99d47 Sync headers installation
This syncs the installed sapi and extension headers on *nix and Windows
systems by installing only what is intended outside of php-src.

- ext/gd: without gd_arginfo.h and gd_compat.h
- ext/hash: php_hash_joaat.h and php_hash_fnv.h added also on Windows
  installation; xxhash/xxhash.h added on both installations as it is
  included in php_hash_xxhash.h; Include path for xxhash.h changed to
  relative so the php_hash_xxhash.h can be included outside of php-src;
  Redundant include flags removed
- ext/iconv: without iconv_arginfo.h
- ext/mysqli: mysqli_mysqlnd.h was missing on Windows
- ext/phar: php_phar.h was missing on Windows
- ext/sodium: php_libsodium.h was missing on *nix
- ext/xml: without xml_arginfo.h
- sapi/cli: cli.h was missing on Windows

Closes GH-13210
Closes GH-13213
2024-01-28 19:50:55 +01:00
Frank Denis 1816403d84 [sodium] Add AEGIS-128L and AEGIS-256 (#12867)
Also don't prevent usage of AES-GCM on aarch64, it's been supported since libsodium 1.0.18.

Fixes #12312
2023-12-07 01:31:42 +01:00
Ilija Tovilo f39b5c4c25 Close PHP tags in tests
Closes GH-12422
2023-10-18 17:34:10 +02:00
Ilija Tovilo 692cea5cbc Use zend_error_noreturn for E_ERROR consistently
To be clear, these already don't return. zend_error_noreturn just hints at this
fact through the ZEND_NORETURN attribute.

Closes GH-12204
2023-09-14 11:44:55 +02:00
George Peter Banyard d5ad75108e More usage of known zend_str instead of C string (#11381) 2023-06-08 13:03:29 +01:00
Ilija Tovilo 9d5f2f1343 Use new ZSTR_INIT_LITERAL macro (#10879) 2023-03-20 16:19:05 +01:00
Jorg Adam Sowa 77ee92a50c Remove unnecessary usage of CONST_CS
Closes GH-9685.
2022-11-28 17:12:07 +01:00
Tim Düsterhus 03fd405423 Use php_info_print_table_header for actual column headers only (#9485)
Using php_info_print_table_header() for "Foo: bar" looks odd and out of place,
because the whole line is colored. It is also questionable from a HTML
semantics point of view, because it does not described the columns that follow.

The use of this across extensions is inconsistent. It was part of the skeleton,
but ext/date or ext/json already use a regular row.
2022-09-06 08:48:22 +02:00
Máté Kocsis b4ec3e9bc0 Do not generate CONST_CS when registering constants (#9439) 2022-08-28 08:27:19 +02:00
Máté Kocsis 4679805cd6 Declare ext/sodium constants in stubs (#9225) 2022-08-02 13:57:52 +02:00
Remi Collet 55a88f36b6 add SensitiveParameter as known string and use it in arginfo 2022-07-18 11:43:33 +02:00
Tim Düsterhus 342e18f105 Support the actual #[\SensitiveParameter] attribute in stubs (#8836) 2022-07-12 12:43:44 +02:00
Máté Kocsis 49d3dde211 Declare true return types (#8759) 2022-06-18 22:06:50 +02:00
Pierrick Charron 6fd2b39397 Indent with TAB in .h files generated by gen_stub 2022-06-13 08:55:54 -04:00
Tim Düsterhus 8f8243318d Mark parameter in ext/sodium as sensitive 2022-06-13 11:09:12 +02:00
Christoph M. Becker d03a94a0a6 Use proper types in sodium_crypto_stream_xchacha20_xor_ic()
Most importantly, `ic` needs to be of type `zend_long`, not `zend_long*`.

Closes GH-8302.
2022-04-05 16:34:12 +02:00
George Peter Banyard 2fe35cf807 Regenerate optimized func infos
Using the --generate-optimizer-info option for ./build/gen_stubs.php
2022-04-05 13:36:14 +01:00
Paragon Initiative Enterprises afd8f84c1a Add sodium_crypto_stream_xchacha20_xor_ic()
There are many use-cases where a PHP user is currently using sodium_compat's implementation of this low-level XChaCha20 API. For example, multi-part message processing (in low-memory settings) for a ciphertext that was encrypted with XChaCha20-Poly1305 (rather than the secretstream API).

Adding this function to ext/sodium offers better performance and lowers users' memory usage with the polyfill, and ensures that users coming from other languages that provide libsodium bindings have a more consistent experience with our bindings. This is a win-win.

This patch follows the libsodium precedent of adding functions instead of optional parameters to existing functions. The parameter order is also consistent with the C API.

https://doc.libsodium.org/advanced/stream_ciphers/xchacha20#usage

Closes GH-8276.
2022-04-04 15:43:42 +02:00
Máté Kocsis f7d9594dbd Merge branch 'PHP-8.1'
* PHP-8.1:
  Remove extra space before return type
2021-10-18 14:29:35 +02:00
Máté Kocsis 10a2079b13 Remove extra space before return type
For consistency and searchability reasons
2021-10-18 14:28:46 +02:00
Nikita Popov bce040ddf2 Merge branch 'PHP-8.1'
* PHP-8.1:
  Set opline before calling undef op helper
  Add more specific array return type hints for various extensions - part 6 (#7474)
2021-10-07 14:40:48 +02:00
Máté Kocsis d9e5e63032 Add more specific array return type hints for various extensions - part 6 (#7474) 2021-10-07 14:29:29 +02:00
Máté Kocsis ad471fb22d Merge branch 'PHP-8.1'
* PHP-8.1:
  Remove extra space before param default values
  Fix class synopsis generation for interfaces
2021-09-08 12:25:13 +02:00
Máté Kocsis a5e5483439 Remove extra space before param default values 2021-09-08 12:24:47 +02:00
Máté Kocsis a1a8e9032c Remove unnecessary PHP_FUNCTION() declarations (#7472) 2021-09-07 10:04:00 +02:00
Máté Kocsis 765aec8623 Generate optimizer func info from stubs for ext/sodium (#7404) 2021-08-26 10:44:38 +02:00
Nikita Popov 2addab1561 Comment out ristretto255 scalar invert test
This fails intermittently depending on which random scalar is
picked.
2021-08-10 12:04:47 +02:00
Nikita Popov 98184afd92 Improve ristretto255 scalarmult exception messages
These fail due to bad inputs, not internal errors.
2021-08-10 11:19:29 +02:00
Nikita Popov f31db20956 Add missing parts of previous commit 2021-08-10 11:12:08 +02:00
Nikita Popov 9168aab381 Fix ristretto255 tests
Both tests were skipped because of a typo in the checked constant
name.

The scalarmult test was using illegal test vectors. The new test
is based on:
https://github.com/jedisct1/libsodium/blob/6d566070b48efd2fa099bbe9822914455150aba9/test/default/scalarmult_ristretto255.c

The $L value contained one extra null byte. The number of "false"
return values was too small.

scalar_invert() doesn't return a valid point -- not sure on that
one.
2021-08-10 11:10:55 +02:00
Nikita Popov 6600ad6067 Add some missing EXTENSIONS sections to misc tests 2021-06-14 14:52:44 +02:00
Nikita Popov 39131219e8 Migrate more SKIPIF -> EXTENSIONS (#7139)
This is a mix of more automated and manual migration. It should remove all applicable extension_loaded() checks outside of skipif.inc files.
2021-06-11 12:58:44 +02:00
Nikita Popov a9695aa155 Merge branch 'PHP-8.0'
* PHP-8.0:
  Correct the argument names for ext/sodium functions
2021-05-10 17:22:41 +02:00