Commit Graph

1515 Commits

Author SHA1 Message Date
Cristian Rodríguez
782ffd761b
Use a single version of strnlen (#12015)
* Zend: Make zend_strnlen available for use outside zend_compile

* exif: remove local php_strnlen, use zend_strnlen instead

* main: remove local strnlen, use zend_strnlen instead

* phar: remove local strnlen, use zend_strnlen
2023-08-22 17:40:24 +02:00
Ayesh Karunaratne
1887f02b0b
Add class constant types to Phar extension (#11826) 2023-08-21 07:14:45 +02:00
Kamil Tekiela
f907a009f9
Align highlight_string|file with HTML standard and modern browsers
Closes GH-11913
2023-08-12 15:08:28 +01:00
Ilija Tovilo
fc9266a5fc
Move ASAN built to GitHub actions
Cirrus will no longer offer unlimited free builds starting next month. We don't
have an alternative for FreeBSD and ARM, so move what we can for now.

Closes GH-11898
2023-08-09 14:06:36 +02:00
Niels Dossche
1b092c6aa2 Merge branch 'PHP-8.2'
* PHP-8.2:
  Mark buildFromIterator test as conflicting
2023-08-04 21:09:03 +02:00
Niels Dossche
00ab6bb078 Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Mark buildFromIterator test as conflicting
2023-08-04 21:08:57 +02:00
Niels Dossche
dc586b121a Mark buildFromIterator test as conflicting
Commit 0b2e6bc2b0 started caching the directory entry type to improve
performance. Shortly after, we've seen flaky failures of the
buildFromIterator phar test.

When it fails, it's always a value error in the constructor of
RecursiveDirectoryIterator::__construct() with a "no such file or
directory" error. What's happening here is this:
1) A parallel test creates a subdirectory in the current working dir.
2) This test checks hasChildren() on a directory entry, the cached entry
   returns "yes" on the subdirectory.
3) The parallel test finishes and removes the subdirectory.
4) The constructor mentioned above is called, causing an exception
   because the directory is gone.

This race has always been possible, even before said commit. It's just
that it was very hard to hit before: the expensive stat call made the
race window hard to hit. The race is now easier to hit because of the
caching that is fast.

Since there's many tests that modify the current working directory, it
seems best to mark this as an "all" conflict. We cannot avoid every
TOC-TOU race when working with files with these phar tests.

In particular, mounteddir.phpt caused every conflict I saw on CI, but
there's more tests that create subdirectories in the current working
directory.

Closes GH-11869.
2023-08-04 21:08:39 +02:00
Derick Rethans
86afbe10e2 Merge branch 'PHP-8.2' 2023-07-31 19:57:02 +01:00
Derick Rethans
deddf4692a Merge branch 'PHP-8.1' into PHP-8.2 2023-07-31 19:54:44 +01:00
Derick Rethans
0870ebb862 Merge branch 'PHP-8.0' into PHP-8.1 2023-07-31 19:53:43 +01:00
Niels Dossche
80316123f3 Fix buffer mismanagement in phar_dir_read()
Fixes GHSA-jqcx-ccgc-xwhv.
2023-07-31 19:47:05 +01:00
Máté Kocsis
840d665583 Deprecate Phar::setStub(resource $stub, int $length) 2023-07-18 12:59:21 +02:00
Niels Dossche
15bdc85e00 Merge branch 'PHP-8.2'
* PHP-8.2:
  Add missing check on EVP_VerifyUpdate() in phar util
2023-07-09 23:00:49 +02:00
Niels Dossche
3ee2ade917 Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Add missing check on EVP_VerifyUpdate() in phar util
2023-07-09 22:55:01 +02:00
Niels Dossche
0d07b6d647 Add missing check on EVP_VerifyUpdate() in phar util
Closes GH-11640.
2023-07-09 22:54:27 +02:00
Niels Dossche
0b2e6bc2b0 Cache d_type in directory entry 2023-07-07 18:02:32 +02:00
Ilija Tovilo
7b355e8d34
Revert "Merge branch 'PHP-8.2'"
This reverts commit 45a3f178dc, reversing
changes made to b2a54bc6af.
2023-07-04 09:18:49 +02:00
Máté Kocsis
45a3f178dc
Merge branch 'PHP-8.2'
* PHP-8.2:
  Fix GH-9967 Add support for generating custom function, class const, and property attributes in stubs

Closes GH-10170
2023-07-03 11:17:08 +02:00
nielsdos
1a5a53709f Merge branch 'PHP-8.2'
* PHP-8.2:
  Fix cross-compilation check in phar generation for FreeBSD
2023-06-13 19:15:30 +02:00
nielsdos
a9c6b840ad Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix cross-compilation check in phar generation for FreeBSD
2023-06-13 19:13:34 +02:00
Peter
4fcb3e0d34 Fix cross-compilation check in phar generation for FreeBSD
FreeBSD's shell is very POSIX strict. This patch makes sure it works
correctly under FreeBSD too.

Closes GH-11441.
2023-06-13 19:09:58 +02:00
Niels Dossche
a94fe872b1 Merge branch 'PHP-8.2'
* PHP-8.2:
  Fix GH-11099: Generating phar.php during cross-compile can't be done
2023-05-20 13:46:18 +02:00
Niels Dossche
ffae350d11 Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix GH-11099: Generating phar.php during cross-compile can't be done
2023-05-20 13:42:21 +02:00
Peter
93fa9613e1 Fix GH-11099: Generating phar.php during cross-compile can't be done
Closes GH-11243.
2023-05-20 13:35:18 +02:00
Ilija Tovilo
38cf52d8aa
Merge branch 'PHP-8.2'
* PHP-8.2:
  Fix use-of-uninitialized value in phar_object.c
2023-05-08 17:07:04 +02:00
Ilija Tovilo
b71a961363
Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix use-of-uninitialized value in phar_object.c
2023-05-08 17:06:57 +02:00
Ilija Tovilo
78ec64af44
Fix use-of-uninitialized value in phar_object.c
resource would stay uninitialized if the first call to zend_parse_parameters
fails, but the value is still passed to phar_add_file(). It's not used there if
cont_str is provided and so didn't cause any issues.

Closes GH-11202
2023-05-08 17:06:44 +02:00
Michael Voříšek
f89fe830f2
Minor conditions simplify (#10397) 2023-04-26 15:12:01 +02:00
George Peter Banyard
aae20cd119
ext/phar: Fix recently introduced potential NULL dereferencement segfaults (#11065) 2023-04-12 17:05:03 +01:00
George Peter Banyard
4082d425a9
ext/phar: Remove duplicate cleaning-up code 2023-04-10 13:23:08 +01:00
George Peter Banyard
a72778b45d
ext/phar: Prevent unnecessary known string length computation
Closes GH-11033
2023-04-10 13:23:08 +01:00
George Peter Banyard
7d93ef067f Convert char* + size_t parameters to zend_string* in phar_find_in_include_path() 2023-04-06 14:56:42 +01:00
George Peter Banyard
8e51cfe0ae Use zend_string_concat helper instead of strpprintf 2023-04-06 14:56:42 +01:00
George Peter Banyard
06896d1c45 Improve locality of stream variable 2023-04-06 14:56:42 +01:00
George Peter Banyard
96ffdd492c size variable is only used once, move closer to usage
Also change type to ssize_t as this is what the function returns
2023-04-06 14:56:42 +01:00
George Peter Banyard
3fb63f7fa2 Extract common code for phar IO intercept functions
Also convert filename to a zend_string*.

This in preparation for refactoring phar_find_in_include_path() to use a zend_string*
2023-04-06 14:56:42 +01:00
Niels Dossche
44b1619370
Cleanup pubkey checks in ext/phar (#11009)
These checks are always true because we bail out early if pubkey is
NULL or empty.
But by having these checks, it makes the code more confusing because it
implies pubkey can be false, while it can in fact not.
2023-04-04 10:04:59 +02:00
Niels Dossche
0b212ab5ab Merge branch 'PHP-8.2'
* PHP-8.2:
  Fix undefined behaviour in GENERATE_SEED()
  Fix undefined behaviour when writing 32-bit values in phar/tar.c
2023-03-26 16:16:26 +02:00
Niels Dossche
22040f5a8f Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix undefined behaviour in GENERATE_SEED()
  Fix undefined behaviour when writing 32-bit values in phar/tar.c
2023-03-26 16:15:57 +02:00
Niels Dossche
19ddc62778 Fix undefined behaviour when writing 32-bit values in phar/tar.c
As shown on the CI runs on my fork (which runs with UBSAN),
the pointers can sometimes be unaligned when trying to write.
This is UB and on platforms like ARM this *can* result in a bus error.
Replace it with memcpy, which at least on x86 and powerpc
architectures does result in the same assembly code.

Closes GH-10940.
2023-03-26 16:06:29 +02:00
Ilija Tovilo
9d5f2f1343
Use new ZSTR_INIT_LITERAL macro (#10879) 2023-03-20 16:19:05 +01:00
Su, Tao
edae24313d
Fix GH-10755: Memory leak in phar_rename_archive()
In phar_renmae_archive() context, added one reference but immediately
destroyed another, so do not need to increase refcount. With removal of
refcount++ line, PHP/Zend no longer reports memory leak.
Updated bug69958.phpt test file accordingly.

Closes GH-10856
2023-03-20 13:27:33 +01:00
Niels Dossche
aef5250eae Merge branch 'PHP-8.2'
* PHP-8.2:
  Add missing error check on PEM_write_bio_PKCS7()
  Add missing error check on PEM_write_bio_CMS()
  Add missing error check on i2d_PKCS12_bio()
  Add missing error checks on EVP_MD_CTX_create() and EVP_VerifyInit()
2023-03-05 22:16:23 +01:00
Niels Dossche
a13cca8a81 Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Add missing error check on PEM_write_bio_PKCS7()
  Add missing error check on PEM_write_bio_CMS()
  Add missing error check on i2d_PKCS12_bio()
  Add missing error checks on EVP_MD_CTX_create() and EVP_VerifyInit()
2023-03-05 22:12:36 +01:00
Niels Dossche
30ebecb1d4 Add missing error checks on EVP_MD_CTX_create() and EVP_VerifyInit()
The first one returns NULL on error, and the second one returns 0 on
error. These weren't checked.

Closes GH-10762.
2023-03-05 22:05:11 +01:00
Niels Dossche
43c71dfe52 Merge branch 'PHP-8.2'
* PHP-8.2:
  Fix GH-10766: PharData archive created with Phar::Zip format does not keep files metadata (datetime)
2023-03-05 00:05:42 +01:00
Niels Dossche
d8294f2824 Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix GH-10766: PharData archive created with Phar::Zip format does not keep files metadata (datetime)
2023-03-04 23:57:03 +01:00
Niels Dossche
e633be3e87 Fix GH-10766: PharData archive created with Phar::Zip format does not keep files metadata (datetime)
Due to an incorrect check, the datetime was never actually set.
To test this we need to write the file using phar, but read the file
using a different method to not get a cached, or a value that's been
transformed twice and is therefore accidentally correct.

Closes GH-10769
2023-03-04 23:43:48 +01:00
Max Kellermann
d46dea169c
Make globals const (part 2) (#10610)
* Zend/zend_enum: make `forbidden_methods` static+const

* main/php_syslog: make `xdigits` static

* sapi/fpm: make several globals `const`

* sapi/phpdbg: make `OPTIONS` static

* sapi/phpdbg/help: make help texts const

* sapi/cli: make `template_map` const

* ext/ffi: make `zend_ffi_types` static

* ext/bcmath: make `ref_str` const

* ext/phar: make several globals static+const
2023-02-18 19:52:53 +00:00
George Peter Banyard
231ffaf394
Merge branch 'PHP-8.2'
* PHP-8.2:
  Fix incorrect check in phar tar parsing
2023-01-29 17:17:32 +00:00