1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 08:12:21 +01:00

1015 Commits

Author SHA1 Message Date
Alexandre Daubois
a8543dfdd2 Convert remaining zend_parse_parameters_none() to ZPP (#21343) 2026-03-16 09:28:08 +01:00
Arshid
45157d24ea ext/zip: Remove unreachable break after RETURN_STRING (#21458) 2026-03-16 07:37:43 +00:00
ndossche
c197fada93 Merge branch 'PHP-8.5'
* PHP-8.5:
  ext/zip: Fix const-generic compile warning
2026-03-14 15:07:26 +01:00
ndossche
e0ac74fb52 Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  ext/zip: Fix const-generic compile warning
2026-03-14 15:07:06 +01:00
ndossche
b95f0ebc47 ext/zip: Fix const-generic compile warning 2026-03-14 15:06:57 +01:00
Tim Starling
605c0756c9 ext/zip: add ZipArchive::openString() method
Fixes to GH-14078:

* Rename ZipArchive::openBuffer() to ::openString().
* For consistency with ::open(), return int|bool, don't throw an
  exception on error. Provide error information via existing properties
  and accessors.
* Fix memory leak when ::openString() is called but ::close() is not
  called. Add test.
* Fix memory leak when a call to ::open() is followed by a call to
  ::openString(). Add test.
* Let libzip own the source, don't call zip_source_keep().
* Share buffer handling with ZipArchive::addFromString().

Elsewhere:

* If there is an error from zip_close() during a call to
  ZipArchive::open(), emit a warning but proceed to open the archive,
  don't return early. Add test.
* When buffers are saved by ZipArchive::addFromString(), release them
  in ZipArchive::close() and ::open(), don't accumulate buffers until
  the free_obj handler is called.
* Factor out buffer handling and reuse it in ZipArchive::openString()

Closes GH-21205.
Closes GH-14078.

Co-authored-by: Soner Sayakci <s.sayakci@shopware.com>
Co-authored-by: Ghaith Olabi <24876890+Gaitholabi@users.noreply.github.com>
2026-03-14 15:03:36 +01:00
Remi Collet
806e0d0c03 Merge branch 'PHP-8.5'
* PHP-8.5:
  zip is now 1.22.8
2026-03-06 09:55:12 +01:00
Remi Collet
1d7cddd3ce Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  zip is now 1.22.8
2026-03-06 09:54:55 +01:00
Remi Collet
fb80f35fdc zip is now 1.22.8 2026-03-06 09:54:32 +01:00
Peter Kokot
f17c5ad83b Windows build: Add new function CHECK_HEADER() (#21191)
The current function `CHECK_HEADER_ADD_INCLUDE()` automatically defines
`HAVE_<HEADER_NAME_H>` preprocessor macros, which makes it difficult to
sync with other build systems. Specially, if some `HAVE_` macro is used
in the code and this function defines this macro but Autotools doesn't.

The new `CHECK_HEADER()` function behaves similar except it doesn't
define the `HAVE_<HEADER_NAME_H>` preprocessor macro.

This removes the following unused compile definitions:

HAVE_ARGON2_H
HAVE_AVIF_H
HAVE_BZLIB_H
HAVE_CAPSTONE_CAPSTONE_H
HAVE_CURL_EASY_H
HAVE_DB_H
HAVE_DECODE_H
HAVE_DEPOT_H
HAVE_EDITLINE_READLINE_H
HAVE_ENCHANT_H
HAVE_ENCODE_H
HAVE_FFI_H
HAVE_FIREBIRD_INTERFACE_H
HAVE_FT2BUILD_H
HAVE_GD_H
HAVE_GLIB_H
HAVE_GMP_H
HAVE_HTTPD_H
HAVE_IBASE_H
HAVE_IR_IR_H
HAVE_KECCAKHASH_H
HAVE_LBER_H
HAVE_LDAP_H
HAVE_LIBEXSLT_EXSLT_H
HAVE_LIBINTL_H
HAVE_LIBPQ_FE_H
HAVE_LIBTIDY_TIDY_H
HAVE_LIBXML_PARSER_H
HAVE_LIBXML_TREE_H
HAVE_LIBXML_XMLWRITER_H
HAVE_LIBXSLT_XSLT_H
HAVE_LMDB_H
HAVE_MBSTRING_H
HAVE_MYSQL_H
HAVE_ONIGURUMA_H
HAVE_OPENSSL_SSL_H
HAVE_PNG_H
HAVE_SNMP_H
HAVE_SODIUM_H
HAVE_SQLITE3_H
HAVE_SQLITE3EXT_H
HAVE_SYBFRONT_H
HAVE_TIDY_H
HAVE_TIDY_TIDY_H
HAVE_TIDYBUFFIO_H
HAVE_TIMELIB_CONFIG_H
HAVE_UNICODE_USPOOF_H
HAVE_UNICODE_UTF_H
HAVE_XPM_H
HAVE_ZIP_H
HAVE_ZIPCONF_H
HAVE_ZLIB_H

The following compile definitions are defined explicitly:

- HAVE_ICONV_H
- HAVE_MSCOREE_H
- HAVE_SQL_H
- HAVE_SQLEXT_H

Additionally, the `SETUP_OPENSSL()` function doesn't accept the 6th
argument anymore.
2026-03-03 20:06:40 +01:00
Tim Starling
e7f022b3fc Remove ifdef guards for ZIP_RDONLY (#21195)
ZIP_RDONLY was introduced in libzip 1.0.0 which is required since
a979e9f897
2026-02-15 14:10:00 -08:00
Peter Kokot
8032d6fa16 Autotools: Check struct stat.st_blocks with AC_CHECK_MEMBERS (#13562)
The AC_STRUCT_ST_BLOCKS expects fileblocks object to be compiled with
AC_LIBOBJ if stat.st_blocks is missing on the system. This can be
simplified with the usual AC_CHECK_MEMBERS since PHP is using the
stat.st_blocks (and stat.st_blksize) conditionally.

These members are mostly present on all POSIX-based systems except on
Windows these days.

This also removes the obsolete HAVE_ST_BLOCKS symbol:
https://git.savannah.gnu.org/cgit/autoconf.git/tree/lib/autoconf/types.m4?h=v2.72#n1055

Additionally, the st_blksize and st_blocks members are checked
conditionally with HAVE_ preprocessor macros. Instead of filtering
Windows specifically here, the preprocessor macros
HAVE_STRUCT_STAT_ST_BLKSIZE and HAVE_STRUCT_STAT_ST_BLOCKS can be used.
2026-02-10 19:59:10 +01:00
Arnaud Le Blanc
65b4073922 Include the actual stub name in generated arginfo headers (#20993) 2026-01-21 20:57:00 +01:00
Niels Dossche
9762c446f0 Merge branch 'PHP-8.5'
* PHP-8.5:
  zip: Don't truncate return value of zip_fread() with user sizes
2025-11-18 20:32:15 +01:00
Niels Dossche
a21783c73c Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  zip: Don't truncate return value of zip_fread() with user sizes
2025-11-18 20:31:31 +01:00
Niels Dossche
4eacb6de83 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  zip: Don't truncate return value of zip_fread() with user sizes
2025-11-18 20:31:15 +01:00
Niels Dossche
2f05830a5f zip: Don't truncate return value of zip_fread() with user sizes
The return type has been zip_int64_t since 2009, so we shouldn't
truncate to an int because the user may have requested a size that won't
fit in an int.

Closes GH-20509.
2025-11-18 20:30:42 +01:00
Ilija Tovilo
f411e7fd0f Fix 32-bit failure of ext-zip oo_setcompression.phpt (GH-20511) 2025-11-17 15:18:14 +01:00
Niels Dossche
3977650820 Merge branch 'PHP-8.5'
* PHP-8.5:
  Fix crash in property existence test in ext/zip
2025-11-16 21:30:39 +01:00
Niels Dossche
75cd8fbb55 Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  Fix crash in property existence test in ext/zip
2025-11-16 21:29:16 +01:00
Niels Dossche
9db074d2ad Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix crash in property existence test in ext/zip
2025-11-16 21:28:57 +01:00
Niels Dossche
46a15ed439 Fix crash in property existence test in ext/zip
When type == 2, the zval is not initialized, so zval_ptr_dtor() on it
will crash.
Unfortunately couldn't test with property_exists() or Reflection because
they have fast paths that go through the property info, but fortunately
there are paths that don't implement a fast path (e.g. because it
doesn't make sense at that point), like with array_column().
So we use array_column() to trigger the crash.

Closes GH-20496.
2025-11-16 21:28:30 +01:00
David CARLIER
ac7fddfacc ext/zip: further micro optimisations. (#20362)
- earlier return on invalid inputs from some ZipArchive methods.
- apply comp_flags type check for setCompressionName()/setCompressionIndex().
and throw exception for these
- add comp_flags check when passed as userland array option.
- adding a wrapper for zip_file_set_encryption workaround.
2025-11-16 14:35:37 +00:00
Niels Dossche
5bed2a8920 Avoid string copy in ZipArchive::addFromString() (#20497)
Instead of copying the data we increment the refcount of the string.
2025-11-16 14:57:00 +01:00
David Carlier
7a93d2ca6a Merge branch 'PHP-8.5'
* PHP-8.5:
  ext/zip: fix memory leak when encryption is passed as userland array option.
2025-11-02 21:17:19 +00:00
David Carlier
0e9c39deb9 Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  ext/zip: fix memory leak when encryption is passed as userland array option.
2025-11-02 21:17:05 +00:00
David Carlier
6d12688c9e Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  ext/zip: fix memory leak when encryption is passed as userland array option.
2025-11-02 21:16:55 +00:00
David Carlier
55f7303d73 ext/zip: fix memory leak when encryption is passed as userland array option.
Similar issue fixed in GH-19936.

close GH-20363
2025-11-02 21:15:07 +00:00
Peter Kokot
8d1a42fd10 ext/zip: Sync remaining parts for libzip >= 1.0.0 (#20365)
Follow up of GH-20355
2025-11-02 20:45:04 +01:00
David Carlier
a979e9f897 ext/zip: lifting libzip minimum support.
0.11 dates back from 2013 whereas 1.0.0 is from 2015.
Thus, simplifying the extension removing unlikely old api code usage.
centos 7 can always uses an alternative repository (e.g. remi's);
solaris 10 can access the 1.5.2 release via OpenCSW.

close GH-20355
2025-11-01 23:37:54 +00:00
David Carlier
6c1402031d ext/zip: code refactoring.
- change few helpers signatures.
- ZipArchive::extractTo now accepts only string entries for the files
  list.

close GH-20218
2025-10-27 21:19:52 +00:00
David Carlier
bac62bf31a Merge branch 'PHP-8.5'
* PHP-8.5:
  ext/zip: ZipArchive callback missing zend_release_fcall_info_cache
2025-10-25 21:51:38 +01:00
David Carlier
3884438fe3 ext/zip: ZipArchive callback missing zend_release_fcall_info_cache
during FCC conversion (79b9fe3) in the rare cases where the lib
fails to allocate the memory for these callbacks, we return false
directly.

close GH-20293
2025-10-25 21:50:43 +01:00
Ilija Tovilo
e2da92b15c Fix ZipArchive callback being called after executor has shut down
free_obj() for objects referenced in the main symbol table may be called only
once the executor has already shut down. php_zip_cancel_callback() may attempt
to invoke a user callback, which will terminate the process because user code is
not expected to be executed at this point. We solve this by calling the callback
in dtor_obj(), which is called earlier in the shutdown sequence.

dtor_obj() will actually attempt to call it again if the object was
reinitialized in the destructor, so we also avoid calling the callback when the
executor has shut down in the first place. This should never matter in practice.

Closes GH-19602
2025-10-14 23:17:33 +02:00
Niels Dossche
57ce245e1e Reduce code bloat in arginfo by using specialised string releases (#20016)
* Reduce code bloat in arginfo by using specialised string releases

Comparing this patch to master (c7da728574),
with a plain configure command without any options:

```
   text	   data	    bss	    dec	    hex	filename
20683738	1592400	 137712	22413850	156021a	sapi/cli/php
20688522	1592400	 137712	22418634	15614ca	sapi/cli/php_old
```

We see a minor reduction of 0.023% in code size.

* Also use true for the other initialization line

* Also use specialized code for consts
2025-10-02 22:00:20 +02:00
David Carlier
590785ed21 Merge branch 'PHP-8.5' 2025-09-29 22:12:01 +01:00
David Carlier
2c4f4e0ee6 Merge branch 'PHP-8.4' into PHP-8.5 2025-09-29 22:11:49 +01:00
David Carlier
4e00b14029 Merge branch 'PHP-8.3' into PHP-8.4 2025-09-29 22:10:46 +01:00
David Carlier
3ee56f68ed Fix GH-19932: Zip::setEncryptionName()/setEncryptionIndex() memory leak.
On successive usage, the password is copied as much but the older
address is never freed. Thus, we are hinting a password reset to address
it.

close GH-19936
2025-09-29 22:10:17 +01:00
Remi Collet
65b930654b Merge branch 'PHP-8.5'
* PHP-8.5:
  zip is now 1.22.7
2025-09-25 12:19:53 +02:00
Remi Collet
8a1014128d Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  zip is now 1.22.7
2025-09-25 12:19:39 +02:00
Remi Collet
6118c19ab8 zip is now 1.22.7 2025-09-25 12:19:27 +02:00
Tim Düsterhus
eddb0f5e8a zip: Use true / false instead of 1 / 0 when assigning to bool
Changes done with Coccinelle:

    @@
    bool b;
    @@

    - b = 0
    + b = false

    @@
    bool b;
    @@

    - b = 1
    + b = true
2025-09-24 18:51:40 +02:00
Niels Dossche
2d545dd1b7 Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix GH-19688: Remove pattern overflow in zip addGlob()
2025-09-10 23:48:22 +02:00
Niels Dossche
98aba6c165 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-19688: Remove pattern overflow in zip addGlob()
2025-09-10 23:48:16 +02:00
Niels Dossche
901f71e6e3 Fix GH-19688: Remove pattern overflow in zip addGlob()
memcmp() can overread the filename if the filename is shorter than the
pattern.

Closes GH-19689.
2025-09-10 23:47:52 +02:00
Niels Dossche
8cd085a179 Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix memory leak in zip when encountering empty glob result
2025-09-05 18:57:31 +02:00
Niels Dossche
1b49d0eb58 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix memory leak in zip when encountering empty glob result
2025-09-05 18:57:26 +02:00
Niels Dossche
216e87ad7e Fix memory leak in zip when encountering empty glob result
The case of returning 0 is inconsistent in when it returns an empty
array, furthermore the caller already returns an empty array.
Because the caller overwrites the return value in these cases, it can
cause a memory leak.

This is easier to trigger on master in some cases as different code paths
are taken with the new bundled glob. On some platforms it is also
triggerable on 8.3.

Closes GH-19715.
2025-09-05 18:56:27 +02:00
Gina Peter Banyard
0992265611 main: refactor userstream method calling
Closes GH-19312
2025-08-15 18:41:17 +02:00