Commit Graph

582 Commits

Author SHA1 Message Date
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
cf6bbdfb0c
Autotools: Improve ftp and mysqlnd SSL configure options (#15164)
This makes the configure log messages and help text more intuitive what
is being enabled and when.
2024-08-03 22:13:36 +02:00
Peter Kokot
f66feaec0f
Sync HAVE_<extension> help texts (#15167)
This syncs all help texts of extension preprocessor macros to the same
style "Define to 1 if the PHP extension '<ext>' is available.".
[skip ci]
2024-08-02 01:41:47 +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
a1b45bb87a
Autotools: Sync PHP_SETUP_* M4 macros (#15117)
- arguments quoted
- MYSQLND_HAVE_SSL help text synced
2024-07-27 11:20:07 +02:00
Christoph M. Becker
f590b34530
Drop support for OpenSSL < 1.1.0 on Windows
PR #13498 bumped the required OpenSSL version to 1.1.1, but apparently
only for non Windows system.  We catch up somewhat by dropping support
for OpenSSL < 1.1.0 on Windows; besides completely removing detection
of old OpenSSL versions in `SETUP_OPENSSL`, we also ensure that all
bundled extension using this function do no longer accept OpenSSL <
1.1.0, to avoid to still be able to build these extensions with older
`phpize` scripts.

We do not cater to `--phar-native-ssl` yet; that might better be
addressed by #14578.

Closes GH-14973.
2024-07-17 12:22:59 +02:00
Peter Kokot
bee84c0468
Autotools: Quote PHP_SUBST arguments in extensions (#14748) 2024-07-02 06:56:18 +02:00
Peter Kokot
c44834d8ad
Trim trailing whitespace (#14721) 2024-06-29 18:41:45 +02:00
Arnaud Le Blanc
11accb5cdf
Preferably include from build dir (#13516)
* Include from build dir first

This fixes out of tree builds by ensuring that configure artifacts are included
from the build dir.

Before, out of tree builds would preferably include files from the src dir, as
the include path was defined as follows (ignoring includes from ext/ and sapi/) :

    -I$(top_builddir)/main
    -I$(top_srcdir)
    -I$(top_builddir)/TSRM
    -I$(top_builddir)/Zend
    -I$(top_srcdir)/main
    -I$(top_srcdir)/Zend
    -I$(top_srcdir)/TSRM
    -I$(top_builddir)/

As a result, an out of tree build would include configure artifacts such as
`main/php_config.h` from the src dir.

After this change, the include path is defined as follows:

    -I$(top_builddir)/main
    -I$(top_builddir)
    -I$(top_srcdir)/main
    -I$(top_srcdir)
    -I$(top_builddir)/TSRM
    -I$(top_builddir)/Zend
    -I$(top_srcdir)/Zend
    -I$(top_srcdir)/TSRM

* Fix extension include path for out of tree builds

* Include config.h with the brackets form

`#include "config.h"` searches in the directory containing the including-file
before any other include path. This can include the wrong config.h when building
out of tree and a config.h exists in the source tree.

Using `#include <config.h>` uses exclusively the include path, and gives
priority to the build dir.
2024-06-26 00:26:43 +02:00
Peter Kokot
44ed17cab5
Replace configure option --with-openssl-dir (#14028)
This is a leftover from the refactoring of the --with-openssl-dir option
that once accepted the path to OpenSSL but wasn't renamed back then.

Instead of --with-openssl-dir, SSL support in ext/ftp and ext/mysqlnd
can be enabled implicitly when building with ext/openssl enabled
(--with-openssl) or explicitly by using new separate configure options
--with-ftp-ssl and --with-mysqlnd-ssl.
2024-05-13 22:54:54 +02:00
Niels Dossche
55dfd45581
Fix bug #63937: Upload speed 10 times slower with PHP (#13041)
There are two slow parts in the upload logic:
- Reading from the input stream character by character
- Checking each character one by one to normalize line endings

First of all, the line normalization isn't necessary for binary
transfers, so we can use a simple read while loop to read bytes into the
transfer buffer.

Second, for the ASCII transfer where we do have to normalize line
endings, we can be smarter than reading one character at a time. There's
a php_stream_get_line() function that we can repurpose if the flags for
the stream are set up properly.

This patch implements these fixes.

Results: I tested this on an 850 MiB file, transferring this to an FTP
server running locally.

Results before patch:
Binary/ASCII transfer (same code path): 8.21s

Results after patch:
Binary transfer: 0.65s
ASCII transfer: 0.74s

Further improvement is probably possible by having a larger send buffer.
2024-04-13 01:39:31 +02:00
Niels Dossche
93d3ae28e1
Remove obsolete OpenSSL code in ext/ftp MINIT (#13793)
Follow-up on GH-13498.
These functions inside this #if block are either deprecated
or do nothing anymore on OpenSSL versions >= 1.1.0.
2024-03-23 19:32:44 +01:00
Ayesh Karunaratne
3de3e137bf ext/openssl: Bump minimum required OpenSSL version to 1.1.1
Bumps the minimum required OpenSSL version from 1.0.2 to 1.1.1.

OpenSSL 1.1.1 is an LTS release, but has reached[^1] EOL from upstream. However, Linux distro/OS vendors
continue to ship OpenSSL 1.1.1, so 1.1.1 was picked as the minimum. The current minimum 1.0.2 reached
EOL in 2018.

Bumping the minimum required OpenSSL version makes it possible for ext-openssl to remove a bunch of
conditional code, and assume that TLS 1.3 (shipped with OpenSSL 1.1.1) will be supported everywhere.

 - Debian buster: 1.1.1[^2]
 - Ubuntu 20.04: 1.1.1[^3]
 - CentOS/RHEL 7: 1.0.2
 - RHEL 8/Rocky 8/EL 8: 1.1.1
 - Fedora 38: 3.0.9 (`openssl11` provides OpenSSL 1.1 as well)

RHEL/CentOS 7 reaches EOL mid 2024, so for PHP 8.4 scheduled towards the end of this year, we can safely
bump the minimum OpenSSL version.

[^1]: https://www.openssl.org/blog/blog/2023/03/28/1.1.1-EOL/index.html
[^2]: https://packages.debian.org/buster/libssl-dev
[^3]: https://packages.ubuntu.com/focal/libssl-dev
2024-03-23 15:12:06 +00: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
Jorg Adam Sowa
e630aacf79
Remove HAVE_INET_PTON (#13410) 2024-02-21 00:43:56 +00: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
Niels Dossche
d751e61504
Struct-pack stream-related data in ftpbuf (#12877) 2023-12-06 04:39:00 +00:00
Ilija Tovilo
289073b452
Merge branch 'PHP-8.3'
* PHP-8.3:
  Fix compilation of ftp without openssl
2023-12-05 11:59:04 +01:00
Ilija Tovilo
b4b157edab
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix compilation of ftp without openssl
2023-12-05 11:56:15 +01:00
Ilija Tovilo
4f934cb7f7
Fix compilation of ftp without openssl
Closes GH-12866
2023-12-05 11:55:44 +01:00
Niels Dossche
f3cddbb831 Remove redundant assignments to ftp->data
ftp_getdata() already does this.

Closes GH-12849.
2023-12-03 00:59:17 +01:00
Niels Dossche
35cf7abec7 Cleanup internal data_close API
This always returns NULL. Also passing in data is not necessary as it is
always equal to ftp->data.
2023-12-03 00:58:50 +01:00
Niels Dossche
f601963d4f Merge branch 'PHP-8.3'
* PHP-8.3:
  Fix GH-9348: FTP & SSL session reuse
2023-12-03 00:52:15 +01:00
Niels Dossche
addb6e463a Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix GH-9348: FTP & SSL session reuse
2023-12-03 00:52:08 +01:00
Niels Dossche
ac8a58fab1 Fix GH-9348: FTP & SSL session reuse
The issue referenced here doesn't contain a reproducer, but I recently
received an email of a user with the exact same problem. I was able to
recreate the scenario locally using vsftpd and setting
`require_ssl_reuse=YES` in the vsftpd configuration.

It turns out that our session resumption code is broken. It only works a
single time: the first time a data connection opens. Subsequent data
connections fail to reuse the session. This is because on every data
connection a new session is negotiated, but the current code always
tries to reuse the (stale) session of the control connection.

To fix this, we use SSL_CTX_sess_set_new_cb() to setup a callback that
gets called every time a new session is negotiated. We take a strong
reference using SSL_get1_session() and store it in the ftpbuf_t struct.
Every time we open a data connection we'll take that session.
This works because every control connection has at most a single
associated data connection.

Also disable internal session caching storage to not fill the cache up
with useless sessions.

There is no phpt for this because PHP does not support enforcing SSL
session reuse.
It is however testable manually by setting up vsftpd and setting the
`require_ssl_reuse=YES` function from before.

Closes GH-12851.
2023-12-03 00:47:33 +01:00
David CARLIER
931a8b0739
inet_ntop requirement check at configure time instead (#12700) 2023-11-17 16:01:46 +00:00
David Carlier
44f9c226aa following-up on GH-12551: removing inet_ntoa usage
Close GH-12554
2023-11-06 12:05:56 +00:00
Ilija Tovilo
f39b5c4c25
Close PHP tags in tests
Closes GH-12422
2023-10-18 17:34:10 +02:00
Niels Dossche
eacfbd9ae8 Merge branch 'PHP-8.2'
* PHP-8.2:
  Fix GH-10562: Memory leak and invalid state with consecutive ftp_nb_fget
2023-07-07 18:01:53 +02:00
Niels Dossche
4dcb5af3a9 Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix GH-10562: Memory leak and invalid state with consecutive ftp_nb_fget
2023-07-07 17:59:00 +02:00
Niels Dossche
c962a96c34 Fix GH-10562: Memory leak and invalid state with consecutive ftp_nb_fget
When the user does not fully consume the data stream, but instead opens
a new one, a memory leak occurs. Moreover, the state is invalid: when
more commands arrive they'll be handled out-of-sync because the state of
the client does not match what the server is doing.
This leads to all sorts of weirdness, for example:
  Warning: ftp_nb_fget(): OK.

Fix it by gracefully closing the old data stream when a new data stream
is started.

Closes GH-11606.
2023-07-07 17:55:53 +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
Niels Dossche
84bd4e497a Merge branch 'PHP-8.2'
* PHP-8.2:
  Fix GH-10521: ftp_get/ftp_nb_get resumepos offset is maximum 10GB
2023-03-20 23:31:04 +01:00
Niels Dossche
57442f8f35 Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix GH-10521: ftp_get/ftp_nb_get resumepos offset is maximum 10GB
2023-03-20 23:27:46 +01:00
Niels Dossche
301418284d Fix GH-10521: ftp_get/ftp_nb_get resumepos offset is maximum 10GB
The char arrays were too small for a long on 64-bit systems, which
resulted in cutting off the string at the end with a NUL byte. Use a
size of MAX_LENGTH_OF_LONG to fix this issue instead of a fixed size
of 11 chars.

Closes GH-10525.
2023-03-20 23:20:21 +01: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
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
Ilija Tovilo
4c2ee6fa21
Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Propagate success status of ftp_close() to userland
2023-03-03 15:26:45 +01:00
nielsdos
abc6fe8f2e
Propagate success status of ftp_close() to userland
The docs say that this function returns true on success, and false on
error. This function always returns true in the current implementation
because the success return value from ftp_close() is never propagated to
userland. This affects one test: since the test server exits after an
invalid login, the ftp close correctly fails (because the server has
gone away).
2023-03-03 15:26:11 +01:00
Máté Kocsis
a981ad7ad2
Merge branch 'PHP-8.2'
* PHP-8.2:
  Add support for generating namespaced constant
2023-02-23 10:49:40 +01:00
SATO Kentaro
7fccdf72a4
Add support for generating namespaced constant
Closes GH-10552
2023-02-23 10:05:30 +01:00
Máté Kocsis
7936c8085e
Fix GH-8329 Print true/false instead of bool in error and debug messages (#8385) 2023-01-23 10:52:14 +01: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
e328c68305
Rename @cname to @cvalue in stubs (#9043)
@cname currently refers to the constant name in C. However, it is not always a (constant) name, but sometimes a function invocation, so naming it as @cvalue would be more appropriate.
2022-07-19 15:11:42 +02:00
Remi Collet
55a88f36b6
add SensitiveParameter as known string and use it in arginfo 2022-07-18 11:43:33 +02:00
jcm
928624ed8a
QA - ftp_rawlist - check list return value
Co-authored-by: Christoph M. Becker <cmbecker69@gmx.de>

Closes GH-9012.
2022-07-15 17:42:44 +02:00
Juan Morales
492093ac3d
QA - ftp_connect - error behavior when connection fails
Co-authored-by: Christoph M. Becker <cmbecker69@gmx.de>

Closes GH-9002.
2022-07-14 13:16:56 +02:00