Commit graph

80 commits

Author SHA1 Message Date
Christoph M. Becker
1675d32261
Fix printf style issues in Windows specific code (GH-17452)
A couple of calls pass strings as formats (`-Wformat-security`), and
some others mix up types (`-Wformat`).
2025-01-13 11:50:05 +01:00
Christoph M. Becker
26bf239e6d
Resolve -Wincompatible-pointer-types warnings (GH-17456)
The phpdbg issue is a real issue, although it's unlikely that harm can
be done due to stack alignment and little-endianess.  The others seem
to be more cosmetic.
2025-01-13 10:54:13 +01:00
Cristian Rodríguez
927adfb1a6
Use a single version of mempcpy(3) (#12257)
While __php_mempcpy is only used by ext/standard/crypt_sha*, the
mempcpy "pattern" is used everywhere.

This commit removes __php_mempcpy, adds zend_mempcpy and transforms
open-coded parts into function calls.
2023-12-20 15:16:32 +00:00
Max Kellermann
263b22f374
Make lots of string pointers const (#10646)
This allows using string literals without implicitly casting away the
`const`.
2023-02-21 14:01:37 +00:00
Max Kellermann
d3facbe283
Mark globals as const (#10303)
This moves them from ``.data`` to ``.rodata`` and allows more compiler optimizations.

* ext/opcache/zend_accelerator_hash: make prime_numbers const

* Zend/zend_signal: make zend_sigs const

* ext/dba: make dba_handler pointers const

* ext/exif: make php_tiff_bytes_per_format and other globals const

* ext/intl/grapheme: make grapheme_extract_iters const

* ext/mstring: make rare_codepoint_bitvec const

* ext/snmp: make objid_mib const

* ext/opcache: make all zend_shared_memory_handlers const
2023-01-23 13:46:58 +00:00
Christoph M. Becker
9a42d2b87b
Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix build
2021-07-04 23:15:14 +02:00
Christoph M. Becker
d86c25d88e
Fix build
`accel_system_id` gas been renamed to `zend_system_id`.
2021-07-04 23:13:50 +02:00
Christoph M. Becker
b09134139e
Merge branch 'PHP-8.0'
* PHP-8.0:
  Avoid OOB reads in create_name_with_username()
2021-07-04 22:56:37 +02:00
Christoph M. Becker
948b83d7ea
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Avoid OOB reads in create_name_with_username()
2021-07-04 22:54:48 +02:00
Christoph M. Becker
b1840737e2
Avoid OOB reads in create_name_with_username()
`accel_uname_id` and `zend_system_id` are MD5 buffers which are not
NUL terminated.  Thus, we must not pass them to `snprintf()`.

Closes GH-6968.
2021-07-04 22:51:55 +02:00
Patrick Allaert
aff365871a Fixed some spaces used instead of tabs 2021-06-29 11:30:26 +02: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
Christoph M. Becker
9f7c6a824a Merge branch 'PHP-8.0'
* PHP-8.0:
  Print error code if CreateMutex() fails
2021-03-05 15:09:26 +01:00
Christoph M. Becker
1c16749eaa Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Print error code if CreateMutex() fails
2021-03-05 15:08:24 +01:00
Christoph M. Becker
e0e167e581 Print error code if CreateMutex() fails
This issue came up recently in a bug report[1]; without the error code,
users can barely guess why the function failed.

[1] <https://bugs.php.net/80812>

Closes GH-6745.
2021-03-05 15:06:18 +01:00
Christoph M. Becker
b1a30d8ab1 Fix typos in comments 2020-11-28 13:52:46 +01:00
Sammy Kaye Powers
12306728c5
Add system ID entropy API
The `zend_system_id` is a (true global) system ID that fingerprints a process state. When extensions add engine hooks during MINIT/startup, entropy is added the system ID for each hook. This allows extensions to identify that changes have been made to the engine since the last PHP process restart.

Closes GH-5871
2020-09-18 14:26:44 -07:00
Christoph M. Becker
88a3bdd1e4 Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix #73060: php failed with error after temp folder cleaned up
2020-07-29 18:31:28 +02:00
Christoph M. Becker
2bcc419800 Fix #73060: php failed with error after temp folder cleaned up
Instead of storing the mapping base address and the address of
`execute_ex()` in a separate file in the temporary folder, we store
them right at the beginning of the memory mapping.
2020-07-29 18:21:05 +02:00
Christoph M. Becker
da0f3279ea Merge branch 'PHP-7.4'
* PHP-7.4:
  Revert "Merge branch 'PHP-7.3' into PHP-7.4"
2020-07-29 13:38:53 +02:00
Christoph M. Becker
826b90a5f0 Revert "Merge branch 'PHP-7.3' into PHP-7.4"
This reverts commit e1f6ab3388, reversing
changes made to e0ebe56ebf.

There are obviously issues with running tests in parallel, maybe
related to the cache ID.  This needs to be investigated.  Revert for
now.
2020-07-29 13:32:59 +02:00
Christoph M. Becker
fc3439a7b3 Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix #73060: php failed with error after temp folder cleaned up
2020-07-29 10:17:22 +02:00
Christoph M. Becker
e1f6ab3388 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix #73060: php failed with error after temp folder cleaned up
2020-07-29 10:11:29 +02:00
Christoph M. Becker
9a744c66e7 Fix #73060: php failed with error after temp folder cleaned up
Instead of storing the mapping base address and the address of
`execute_ex()` in a separate file in the temporary folder, we store
them right at the beginning of the memory mapping.
2020-07-29 10:07:23 +02:00
Christoph M. Becker
e57b2b9465 Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix #79040: Warning Opcode handlers are unusable due to ASLR
2019-12-30 15:18:25 +01:00
Christoph M. Becker
94063619a0 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix #79040: Warning Opcode handlers are unusable due to ASLR
2019-12-30 15:17:41 +01:00
Christoph M. Becker
0cecf83b26 Fix #79040: Warning Opcode handlers are unusable due to ASLR
We must not use the same shared memory OPcache instance for different
SAPIs, since their memory layout is different.  To avoid this, we add
the SAPI name (truncated to at most 20 characters) to the names of the
memory base file, the mutex and the file mapping.
2019-12-30 15:12:58 +01:00
Christoph M. Becker
39d04f15f8 Fix ASLR related invalid opline handler issues
Opcache stores `opline->handler`s in shared memory.  These pointers are
invalid, if the main PHP DLL is loaded at another base address due to
ASLR.  We therefore store the address of `execute_ex` in the mmap base
file, and check on startup whether it matches its current address.  If
not, we fall back on the file cache if enabled, and bail out otherwise.

This still does not address cases where the opline handler is located
inside of another DLL (e.g. for some profilers, debuggers), but there
seems to be no general solution for now.

(cherry picked from commit 8ba10b8fbc)
2019-11-15 09:46:58 +01:00
Christoph M. Becker
54401001a8 Merge branch 'PHP-7.4'
* PHP-7.4:
  Allow multiple cache instances per user/host on Windows
2019-07-17 19:52:49 +02:00
Christoph M. Becker
e2ed7e6716 Allow multiple cache instances per user/host on Windows
Formerly, there was at most a single OPcache instance per user and the
so called system ID (which is determined from the PHP version).
Sometimes multiple OPcaches might be desired, though, particularly for
unrelated CLI scripts, which may even be necessary (e.g. for our test
suite in parallel mode).

We therefore introduce a new INI directive `opcache.cache_id` which
allows to configure independent OPcache instances for the same user.

We also use `GetUserNameW()` instead of `php_win32_get_username()`,
because the latter retrieves the user name encoded in the
`default_charset`, which can obviously yield different results for
different charsets, leading to OPcache "incompatibilities".  Slightly
worse, some characters may not even be encodeable in the
`default_charset` and would be replaced by question marks, which could
result in different users sharing the same OPcache.

We also refactor, and re-use existing APIs to avoid duplicated code.
2019-07-17 19:51:07 +02:00
Joe Watkins
41067a22e9
Merge branch 'PHP-7.4'
* PHP-7.4:
  Turn system_id into a true global
2019-06-18 10:27:50 +02:00
Christoph M. Becker
04a6aac59b
Turn system_id into a true global
The system_id is identical for all threads and can be computed during
module startup, so there is no need to calculate and store it for each
thread.
2019-06-18 10:27:35 +02:00
Christoph M. Becker
68e6c1542e Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix ASLR related invalid opline handler issues
2019-05-21 14:34:55 +02:00
Christoph M. Becker
8ba10b8fbc Fix ASLR related invalid opline handler issues
Opcache stores `opline->handler`s in shared memory.  These pointers are
invalid, if the main PHP DLL is loaded at another base address due to
ASLR.  We therefore store the address of `execute_ex` in the mmap base
file, and check on startup whether it matches its current address.  If
not, we fall back on the file cache if enabled, and bail out otherwise.

This still does not address cases where the opline handler is located
inside of another DLL (e.g. for some profilers, debuggers), but there
seems to be no general solution for now.
2019-05-21 14:33:33 +02:00
Dmitry Stogov
9a06876072 Added JIT compiler for x86 and x86_64 2019-04-01 10:27:11 +03:00
Dmitry Stogov
da919a8b65 Remove copyright years. 2019-02-05 10:33:28 +03:00
Zeev Suraski
9afce019e0 Future-proof email addresses 2018-11-01 18:35:32 +02:00
Zeev Suraski
67e0138c0d Future-proof email addresses... 2018-11-01 18:30:28 +02:00
Anatol Belski
321c0cc349 Fix localized error messages and memory leaks
The FormatMessage API needs to LocalFree the delivered error messages.
In cases where messages are delivered in non ASCII compatible encoding,
the messages might be unreadable. This aligns the error message encoding
with the encoding settings in PHP, the focus is UTF-8 as default.

Initialize error buffer

Avoid code duplication
2018-09-17 10:56:50 +02:00
Anatol Belski
f26172f934 Fixed bug #76832 ZendOPcache.MemoryBase periodically deleted by the OS 2018-09-03 15:09:23 +02:00
Anatol Belski
eaa5b1f911 Use string literal as format 2018-03-12 15:17:08 +01:00
Dmitry Stogov
350082ed71 Fixed "opcache.file_cache_fallback" mode.
It's not safe to change value of ZCG(accel_directives).file_cache_only, becuse it might be altered by INI subsystem.
Use global variable instead.
2018-03-05 16:01:43 +03:00
Xinchen Hui
ccd4716ec7 year++ 2018-01-02 12:53:31 +08:00
Anatol Belski
67f063e3ac Merge branch 'PHP-7.0' into PHP-7.1
* PHP-7.0:
  Split requested size as expected by CreateFileMapping.
2017-06-20 15:45:05 +02:00
Anatol Belski
6a854e2740 Split requested size as expected by CreateFileMapping.
Thus fixing ext\opcache\tests\log_verbosity_bug.phpt fails on 64-bit.
2017-06-20 15:40:25 +02:00
Anatol Belski
039ef0143b Merge branch 'PHP-7.0' into PHP-7.1
* PHP-7.0:
  improve/fix error handling
2017-04-15 19:35:13 +02:00
Anatol Belski
ca543ff01c improve/fix error handling
GetLastError() should not be called, if the function didn't fail.
2017-04-15 19:32:04 +02:00
Anatol Belski
a7b20894e5 Merge branch 'PHP-7.0' into PHP-7.1
* PHP-7.0:
  ensure the end path wouldn't contain double slashes
2017-01-13 16:54:10 +01:00
Anatol Belski
8e993b427c ensure the end path wouldn't contain double slashes 2017-01-13 16:50:05 +01:00
Sammy Kaye Powers
dac6c639bb Update copyright headers to 2017 2017-01-04 11:23:42 -06:00