1
0
mirror of https://github.com/php/php-src.git synced 2026-04-28 02:33:17 +02:00
Commit Graph

1003 Commits

Author SHA1 Message Date
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
Daniel Scherzer ff810d5e36 Arginfo: reuse zend_string objects for initializing attribute values (#19241)
Avoid initializing the same string content multiple times and make use of the
fact that the strings created to initialize attribute values are not freed by
simply making use of an existing zend_string with the same content if one is
available.
2025-07-27 17:27:22 -07:00
DanielEScherzer 1eadf553f1 Arginfo: avoid using temporary zvals for initializing attribute values (#19141)
Instead of
* adding a zval on the stack
* initializing it
* copying the value to the attribute

Just initialize the value directly in the zend_attribute_arg
2025-07-21 13:33:51 -07:00
Daniel Scherzer 142e378618 Arginfo: add and use known strings for attribute values 2025-07-14 17:31:22 -07:00
Niels Dossche 51149b65ad Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix GH-18990, bug #81029, bug #47314: SOAP HTTP socket not closing on object destruction
  Fix leak when path is too long in ZipArchive::extractTo()
  curl: Remove incorrect string release on error
2025-07-02 18:47:53 +02:00
Niels Dossche 764154dc75 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-18990, bug #81029, bug #47314: SOAP HTTP socket not closing on object destruction
  Fix leak when path is too long in ZipArchive::extractTo()
  curl: Remove incorrect string release on error
2025-07-02 18:46:37 +02:00
Niels Dossche 09c223de00 Fix leak when path is too long in ZipArchive::extractTo()
I did not find an easy way to trigger this branch without also
triggering some other error conditions earlier.

Closes GH-19002.
2025-07-02 18:43:25 +02:00
DanielEScherzer ddd33fd7e4 Generated arginfo headers: combine preprocessor conditional blocks (2) (#18667)
When global constants' or class constants' 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.
2025-06-22 14:35:28 -07:00
Niels Dossche 029a78813d Simplify callers of zval_try_get_long() (#18830)
Since 2b383848 references are handled properly by the Zend API, so we
can simplify the callers by removing reference handling from there.
2025-06-12 17:49:22 +02:00
Calvin Buckley 76791e90b9 Use win32 glob implementation on all platforms (#18164)
* Move glob to main/ from win32/

In preparation to make the Win32 reimplementation the standard
cross-platform one. Currently, it doesn't do that and just passes
through the original glob implementation. We could consider also having
an option to use the standard glob for systems that have a sufficient
one.

* Enable building with win32 glob on non-windows

Kind of broken. We're namespacing the function and struct, but not yet
the GLOB_* defines. There are a lot of places callers check if i.e.
NOMATCH is defined that would likely become redundant.

Currently it also has php_glob and #defines glob php_glob (etc.) - I
suspect doing the opposite and changing the callers would make more
sense, just doing MVP to geet it to build (even if it fails tests).

* Massive first pass at conversion to internal glob

Have not tested yet. the big things are:

- Should be invisible to userland PHP code.
- A lot of :%s/GLOB_/PHP_GLOB_/g; the diff can be noisy as a result,
  especially in comments.
- Prefixes everything with PHP_ to avoid conflicts with system glob in
  case it gets included transitively.
- A lot of weird shared definitions that were sprawled out to other
  headers are now included in php_glob.h.
- A lot of (but not yet all cases) of HAVE_GLOB are removed, since we
  can always fall back to php_glob.
- Using the system glob is not wired up yet; it'll need more shim
  ifdefs for each flag type than just glob_t/glob/globfree defs.

* Fix inclusion of GLOB_ONLYDIR

This is a GNU extension, but we don't need to implement it, as the GNU
implementation is flawed enough that callers have to manually filter it
anyways; just provide a stub definition for the constant.

We could consideer implementing this properly later. For now, fixes the
basic glob constant tests.

* Remove HAVE_GLOBs

We now always have a glob implementation that works. HAVE_GLOB should
only be used to check if we have a system implementation, for if we
decide to wrap the system implementation instead.

* We don't need to care about being POSIXly correct for internal glob

* Check for reallocarray

Ideally temporary until GH-17433.

* Forgot to move this file from win32/ to main/

* Check for issetugid (BSD function)

* Allow using the system glob with --enable-system-glob

* Style fix after removing ifdef

* Remove empty case for system glob
2025-05-20 16:20:59 -03:00
Remi Collet e3715cddf0 Merge branch 'PHP-8.4'
* PHP-8.4:
  bump zip extension version to 1.22.6
2025-05-07 14:24:22 +02:00
Remi Collet 71ffa9596a bump zip extension version to 1.22.6 2025-05-07 14:24:07 +02:00
Niels Dossche 5f97728780 Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix IntlDateFormatter::parseToCalendar() reference type system breaks
  datefmt_parse/datefmt_localtime references type system fixes
  Fix GH-18438: Handling of empty data and errors in ZipArchive::addPattern
2025-04-27 11:33:33 +02:00