Commit graph

391 commits

Author SHA1 Message Date
Levi Morrison
6406d5f792
zlib: use zend_string_{extend,truncate} over *_realloc (#18462)
These cases seemed obvious enough to me to confidently change as an
outsider to zlib.
2025-04-30 08:18:04 -06:00
David CARLIER
df39586a88
ext/zlib: gzfile() files list as packed array (#18380) 2025-04-21 14:47:52 +01:00
Niels Dossche
78d934ad8e
Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix memory leak when encoding check fails
2025-02-13 19:11:08 +01:00
Niels Dossche
902e01f4f9
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix memory leak when encoding check fails
2025-02-13 19:10:46 +01:00
ndossche
a54af45a41
Fix memory leak when encoding check fails
zlib_create_dictionary_string() allocates memory, so we can leak memory
if there's an early exit before the assignment to the return value.
Solve this by moving all validation upwards.

Closes GH-17788.
2025-02-13 19:10:17 +01:00
Niels Dossche
34e1c590cb
Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix GH-17747: Exception on reading property in register-based FETCH_OBJ_R breaks JIT
  Fix GH-17745: zlib extension incorrectly handles object arguments
2025-02-11 21:55:51 +01:00
Niels Dossche
0e0d2d21b7
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-17745: zlib extension incorrectly handles object arguments
2025-02-11 21:53:52 +01:00
Niels Dossche
4b5c29ef50
Fix GH-17745: zlib extension incorrectly handles object arguments
Because of the "H" modifier in ZPP, there are two bugs:

1) The stub is wrong and will cause a crash in debug mode.
2) Non-dynamic properties are not read correctly because they are not
   DEINDIRECTed.

Closes GH-17750.
2025-02-11 21:52:53 +01:00
Niels Dossche
f926c5ce81
Fix GH-16883: gzopen() does not use the default stream context when opening HTTP URLs
Otherwise it's not possible to control the context; it's also consistent
with how the standard open functions work.

Closes GH-17589.
2025-01-27 19:25:52 +01:00
Christoph M. Becker
b7fd773cc6
Refactor zlib dictionary processing (GH-16407)
Co-authored-by: Tim Düsterhus <tim@bastelstu.be>
2024-10-16 12:21:50 +02:00
David Carlier
6d1881b42d
ext/zlib: gzfile/gzopen/readgzfile converting use_include_path argument to actual boolean.
close GH 16424
2024-10-14 12:40:57 +01:00
Christoph M. Becker
a7918a7ac3
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-16326: Memory management is broken for bad dictionaries
2024-10-13 02:30:38 +02:00
Christoph M. Becker
631c04e690
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix GH-16326: Memory management is broken for bad dictionaries
2024-10-13 02:29:22 +02:00
Christoph M. Becker
d94be24f30
Fix GH-16326: Memory management is broken for bad dictionaries
We must not `efree()` `zend_string`s, since they may have a refcount
greater than one, and may even be interned.

We also must not confuse `zend_string *` with `zend_string **`.

And we should play it safe by using `safe_emalloc()` to avoid
theoretical integer overflows.

We also simplify a bit, according to suggestions of @TimWolla.

Closes GH-16335.
2024-10-13 02:28:07 +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
Gina Peter Banyard
25a5146180
Clean-up unused headers (#14365)
* ext/mbstring.c: clean-up headers and include intrinsics
2024-06-01 17:12:42 +01:00
Gina Peter Banyard
2447cb25c6
main/output.c: Refine int return type to bool or zend_result (#13997) 2024-04-19 10:46:40 +01:00
David Carlier
1c62c60c94 Merge branch 'PHP-8.2' 2023-02-23 18:49:19 +00:00
David Carlier
bb2177e248 Merge branch 'PHP-8.1' into PHP-8.2 2023-02-23 18:48:25 +00:00
Niels Dossche
c510083c8c Fix incorrect string length for output_handler in zlib ini code
The length of "output_handler" is supposed to be passed, but as sizeof
is used, the resulting number includes the NUL character, so the length
is off-by-one. Subtract one to pass the correct length.

Closes GH-10667.
2023-02-23 18:47:26 +00: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
Bob Weinand
a01dd9feda Revert "Port all internally used classes to use default_object_handlers"
This reverts commit 94ee4f9834.

The commit was a bit too late to be included in PHP 8.2 RC1. Given it's a massive ABI break, we decide to postpone the change to PHP 8.3.
2022-09-14 11:13:23 +02: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
Bob Weinand
94ee4f9834 Port all internally used classes to use default_object_handlers
Signed-off-by: Bob Weinand <bobwei9@hotmail.com>
2022-08-31 16:45:27 +02:00
Máté Kocsis
1362fefc85
Declare ext/zlib constants in stubs (#9147) 2022-07-27 00:42:19 +02:00
Arnaud Le Blanc
efc8f0ebf8
Deprecate zend_atol() / add zend_ini_parse_quantity() (#7951)
Add zend_ini_parse_quantity() and deprecate zend_atol(), zend_atoi()

zend_atol() and zend_atoi() don't just do number parsing.
They also check for a 'K', 'M', or 'G' at the end of the string,
and multiply the parsed value out accordingly.

Unfortunately, they ignore any other non-numerics between the
numeric component and the last character in the string.
This means that numbers such as the following are both valid
and non-intuitive in their final output.

* "123KMG" is interpreted as "123G" -> 132070244352
* "123G " is interpreted as "123 " -> 123
* "123GB" is interpreted as "123B" -> 123
* "123 I like tacos." is also interpreted as "123." -> 123

Currently, in php-src these functions are used only for parsing ini values.

In this change we deprecate zend_atol(), zend_atoi(), and introduce a new
function with the same behavior, but with the ability to report invalid inputs
to the caller. The function's name also makes the behavior less unexpected:
zend_ini_parse_quantity().

Co-authored-by: Sara Golemon <pollita@php.net>
2022-06-17 14:12:53 +02:00
Christoph M. Becker
e063243d2e
Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix GH-8218: ob_end_clean does not reset Content-Encoding header
2022-04-25 14:29:44 +02:00
Christoph M. Becker
30f4c725cb
Fix GH-8218: ob_end_clean does not reset Content-Encoding header
The fix for GH-7953 introduced a regression by being to deliberate
adding the respective headers.  These must only be added, if the
handler starts, but is not finalizing.

Closes GH-8353.
2022-04-25 14:26:56 +02:00
Christoph M. Becker
8009b216e9
Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix GH-7953: ob_clean() only does not set Content-Encoding
2022-02-03 16:13:11 +01:00
Christoph M. Becker
9bd468da63
Fix GH-7953: ob_clean() only does not set Content-Encoding
If an output handler has not yet been started, calling `ob_clean()`
causes it to start.  If that happens, we must not forget to set the
`Content-Encoding` and `Vary` headers.

Closes GH-7960.
2022-02-03 16:09:00 +01:00
Joe Watkins
570d9b63e9
Not serializable flag permeation 2021-07-20 12:28:35 +02:00
Nikita Popov
a733b1ada7 Restore zend_atoi()
I dropped this in preparation for changes that I didn't end up
doing. Restore the function for now to avoid unnecessary churn for
extensions.
2021-07-16 14:46:56 +02:00
Nikita Popov
1cba7764b4
Remove zend_atoi() (#7232)
It's the same as (int) zend_atol() -- it doesn't try to do anything
integer size specific. Canonicalize to one function in preparation
for renaming zend_atol() to something less misleading.

FFI test is adjusted to use a zend_test function. It just calls
zend_atol() internally, but could really be anything.

Co-authored-by: Christoph M. Becker <cmbecker69@gmx.de>
2021-07-13 09:22:31 +02:00
Patrick Allaert
aff365871a Fixed some spaces used instead of tabs 2021-06-29 11:30:26 +02:00
George Peter Banyard
aca6aefd85
Remove 'register' type qualifier (#6980)
The compiler should be smart enough to optimize this on its own
2021-05-14 13:38:01 +01:00
KsaR
01b3fc03c3
Update http->https in license (#6945)
1. Update: http://www.php.net/license/3_01.txt to https, as there is anyway server header "Location:" to https.
2. Update few license 3.0 to 3.01 as 3.0 states "php 5.1.1, 4.1.1, and earlier".
3. In some license comments is "at through the world-wide-web" while most is without "at", so deleted.
4. fixed indentation in some files before |
2021-05-06 12:16:35 +02:00
Nikita Popov
4ce5d2ea88 Add known strings for jit autoglobals
We always create interned strings for all autoglobals anyway, so
we might as well add known strings to make them more widely usable.
2021-04-09 15:37:59 +02:00
George Peter Banyard
09efad615b
Use zend_string_equals_(literal_)ci() API more often
Also drive-by usage of zend_ini_parse_bool()

Closes GH-6844
2021-04-09 02:34:50 +01:00
George Peter Banyard
5caaf40b43
Introduce pseudo-keyword ZEND_FALLTHROUGH
And use it instead of comments
2021-04-07 00:46:29 +01:00
George Peter Banyard
8a86fe11da
Add missing break; in Zlib extension 2021-04-07 00:46:17 +01:00
Levi Morrison
8d743d5281
Revert "Revert "Revert "[skip-ci] Fix typo"""
This reverts commit 2b0f239b21.
2021-03-28 11:53:30 -06:00
Nikita Popov
2b0f239b21 Revert "Revert "[skip-ci] Fix typo""
This reverts commit 046827a7e8.
2021-03-28 18:15:57 +02:00
Nikita Popov
046827a7e8 Revert "[skip-ci] Fix typo"
This reverts commit c730aa26bd.

This looks like the result of a compromised git account. Commit
access has already been revoked.
2021-03-28 11:16:39 +02:00
Rasmus Lerdorf
c730aa26bd [skip-ci] Fix typo
Fixes minor typo.

Signed-off-by: Rasmus Lerdorf <rasmus@lerdorf.com>
2021-03-28 05:57:07 +02:00
Máté Kocsis
4c6533c257
Generate class entries from stubs for com, standard, xmlreader, xmlwriter, xsl, zip, Zend
Closes GH-6706
2021-02-22 15:24:03 +01:00
Nikita Popov
ce0bc58c22 Merge branch 'PHP-8.0'
* PHP-8.0:
  Mark resource-like objects as non-comparable
2021-02-16 14:22:03 +01:00
Nikita Popov
b63ea1047a Mark resource-like objects as non-comparable
As these hold on to some internal resource, there can't be two
"equal" objects with different identity. Make sure the lack of
public properties doesn't result in these being treated as always
equal.
2021-02-16 14:20:45 +01:00
Nikita Popov
3e01f5afb1 Replace zend_bool uses with bool
We're starting to see a mix between uses of zend_bool and bool.
Replace all usages with the standard bool type everywhere.

Of course, zend_bool is retained as an alias.
2021-01-15 12:33:06 +01:00
Máté Kocsis
e950ca13ea
Consolidate the usage of "either" and "one of" in error messages
Closes GH-6173
2020-09-20 19:41:47 +02:00
Máté Kocsis
d30cd7d7e7
Review the usage of apostrophes in error messages
Closes GH-5590
2020-07-10 21:05:28 +02:00