1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 16:22:37 +01:00
Commit Graph

1723 Commits

Author SHA1 Message Date
Gina Peter Banyard
a85666c17b ext/session: Fix GH-17541 (ext/session NULL pointer dereferencement during ID reset)
Closes GH-17541
Closes GH-17546
2025-01-24 14:04:58 +00:00
Niels Dossche
2a2cc2ccce Fix type confusion with session SID constant
Closes GH-17548.
2025-01-23 19:03:04 +01:00
David Carlier
f31232e218 Merge branch 'PHP-8.2' into PHP-8.3 2024-10-13 14:19:33 +01:00
David Carlier
84a8fea251 Fix GH-16290: session cookie_lifetime ini value overflow.
close GH-16295
2024-10-13 14:19:18 +01:00
Niels Dossche
a1f7ce5617 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix GH-16385: Unexpected null returned by session_set_cookie_params
2024-10-12 13:09:06 +02:00
Niels Dossche
7cdd1302c3 Fix GH-16385: Unexpected null returned by session_set_cookie_params
Two issues:
1) The check happened before ZPP checks
2) The `return;` statement caused NULL to be returned while this
   function can only return booleans. An exception seems not acceptable
   in stable versions, but a warning may do.

Closes GH-16386.
2024-10-12 13:08:37 +02:00
Christoph M. Becker
af789afbe8 Fix type incompatibility in assignment.
This partially reverts 0956267c08, which
introduced a type incompatibility where an `int` function is assigned
to a `zend_result` function.  That yields a level 1 C4133 warning on
MSVC, and usually (e.g. in CI) level 1 warnings are elevated to errors,
so the build fails.[1]

The PHP-8.3 branch and up are uneffected by this, so the upward merges
should be empty.

[1] <0956267c08 (r144587696)>
2024-07-26 14:57:16 +02:00
Levi Morrison
e43d9c7469 Merge branch 'PHP-8.2' into PHP-8.3 2024-07-23 16:33:40 -06:00
Levi Morrison
0956267c08 Fix warnings in session/spl
This fixes -Winline errors where the functions are not ever inlined.

Also fixes some signature mismatches which were fixed previously but
for whatever reason were not ported to all maintained branches:

/usr/local/src/php/ext/session/session.c:1299:20:
warning:conflicting types for 'php_session_send_cookie' due to enum/integer mismatch;
have 'zend_result(void)' {aka 'ZEND_RESULT_CODE(void)'} [-Wenum-int-mismatch]
 1299 | static zend_result php_session_send_cookie(void) /* {{{ */
      |                    ^~~~~~~~~~~~~~~~~~~~~~~
/usr/local/src/php/ext/session/session.c:100:12:
note: previous declaration of 'php_session_send_cookie' with type 'int(void)'
  100 | static int php_session_send_cookie(void);
      |            ^~~~~~~~~~~~~~~~~~~~~~~
2024-07-23 16:25:11 -06:00
Niels Dossche
2b1097a87d Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix reading zlib ini settings in ext-soap
  Fix memory leak if calling SoapServer::setClass() twice
  Fix memory leak if calling SoapServer::setObject() twice
  Fix missing error restore code in ext-soap (#14379)
  Fix GH-14368: Test failure in ext/session/tests/gh13856.phpt (#14378)
2024-05-31 18:26:22 +02:00
Niels Dossche
d7aa0be3a8 Fix GH-14368: Test failure in ext/session/tests/gh13856.phpt (#14378)
If the runner overrides session.save_path, the test fails.
Manually set it to a value known to trigger the issue.
2024-05-31 18:18:40 +02:00
David Carlier
2636104a83 Merge branch 'PHP-8.2' into PHP-8.3 2024-04-20 17:11:33 +01:00
David Carlier
42443b4c2e ext/session: fix _read/_write buffer limit.
MSDN pages mention the buffer size upper limit is INT_MAX not UINT_MAX.
inspired by GH-13205.

Close GH-14017
2024-04-20 17:11:03 +01:00
Niels Dossche
eb244fcb49 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  [ci skip] NEWS
  Fix GH-13891: memleak and segfault when using ini_set with session.trans_sid_hosts (#13892)
2024-04-06 13:45:00 +02:00
Niels Dossche
5ce9687cb2 Fix GH-13891: memleak and segfault when using ini_set with session.trans_sid_hosts (#13892)
The hash tables used are allocated via the persistent allocator.
When using ini_set, the allocation happens via the non-persistent
allocator. When the table is then freed in GSHUTDOWN, we get a crash
because the allocators are mismatched.

As a side note, it is strange that this is designed this way, because it
means that ini_sets persist between requests...

Co-authored-by: Kamil Tekiela <tekiela246@gmail.com>
2024-04-06 13:43:26 +02:00
Niels Dossche
3f598a3073 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix GH-13856: Member access within null pointer of type 'ps_files' in ext/session/mod_files.c
2024-04-01 14:16:23 +02:00
Niels Dossche
46f45a51b4 Fix GH-13856: Member access within null pointer of type 'ps_files' in ext/session/mod_files.c
We should not mark the session as opened when there was a failure in
open.

Closes GH-13858.
2024-04-01 14:15:51 +02:00
Niels Dossche
b58dc6fd1a Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix GH-13680: Segfault with session_decode and compilation error
2024-03-13 17:49:31 +01:00
Niels Dossche
6985aff7c3 Fix GH-13680: Segfault with session_decode and compilation error
It's illegal to return from a bailout because that doesn't restore the
original bailout data. Return outside of it.

Test by YuanchengJiang

Closes GH-13689.
2024-03-13 17:47:25 +01:00
Niels Dossche
d50393e242 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix GH-12504: Corrupted session written when there's a fatal error in autoloader
2024-01-22 22:02:28 +01:00
Niels Dossche
7f7031eb72 Fix GH-12504: Corrupted session written when there's a fatal error in autoloader
For details and reasoning, see [1] and following.

[1] https://github.com/php/php-src/issues/12504#issuecomment-1790870399

Closes GH-13207.
2024-01-22 21:59:11 +01:00
Ilija Tovilo
9bcdf219ec Resolve open_basedir paths on ini update
Closes GH-10987
2023-07-18 14:43:40 +02:00
Michael Orlitzky
092e090cf0 ext/session/tests: more lenient expected output checks. (#11631)
Several session tests incidentally check the values of INI variables
like session.name and session.save_path. This isn't the point of the
tests, and it can cause spurious failures if (for example) you want to
override your temporary directory while testing. So here, we make the
expected output patterns more lenient.
2023-07-10 09:25:25 +01:00
nielsdos
c0147a0588 Fix GH-11529: Crash after dealing with an Apache request
In an MPM worker scenario we have 1 module, N threads. Each thread must
have their globals initialised. If we only initialise the filename
fields in MINIT, then the threads have an uninitialized value. If the
uninitialized value is not NULL, this leads to segfaults upon access.

Closes GH-11530.
2023-06-26 19:43:56 +02:00
Ilija Tovilo
2b3dbe0054 Merge branch 'PHP-8.2'
* PHP-8.2:
  Remove session ID set through REQUEST_URI
2023-06-22 12:36:58 +02:00
Ilija Tovilo
1441f30a8d Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Remove session ID set through REQUEST_URI
2023-06-22 12:36:52 +02:00
Ilija Tovilo
f160eff441 Remove session ID set through REQUEST_URI 2023-06-22 12:35:55 +02:00
George Peter Banyard
d5ad75108e More usage of known zend_str instead of C string (#11381) 2023-06-08 13:03:29 +01:00
Remi Collet
0561783903 ensure session.sid_length have proper value for test 2023-06-07 07:33:36 +02:00
Mikhail Galanin
2eee46e989 ext/session: pass ini options to extra processes in tests (#11294) 2023-05-24 12:05:09 +02:00
Ilija Tovilo
6f63d4b274 Fix -Wenum-int-mismatch warnings on gcc 13
Closes GH-11103
2023-04-20 16:04:59 +02:00
Calvin Buckley
180f785404 Note where a session was already started (#10736)
* Note where a session was already started

Duplicated session starts can be annoying to debug. The error that
occurs when a session is already active doesn't tell you where it
was initialized, so figuring out the callsite involves manual
debugging to find it out.

This keeps track of the call site of session_start as a request
global, and frees at the end of the request. It should make it
easier to find these instances for PHP users.

The resulting message can look like:
Notice: session_start(): Ignoring session_start() because a session is already active (started from /home/calvin/src/php-src/inc.php on line 4) in /home/calvin/src/php-src/index.php on line 9

Fixes GH-10721

* Convert to using zend_string for session start location

* Fix leak with session start callsite filename

If this was already initialized, we'd forget it. Have shared free
between session_start and RSHUTDOWN.

* For sessions that are automatically started, note that

Easy to forget that you have this set, in which case, session start
is done at RINIT outside of user code. Because this config option
can't change at runtime, we can check for it and make the error
more specific if that's the case.
2023-03-28 15:14:21 +01:00
Ilija Tovilo
9d5f2f1343 Use new ZSTR_INIT_LITERAL macro (#10879) 2023-03-20 16:19:05 +01:00
Niels Dossche
4177257178 3 minor cleanups in ext/session (#10722)
* sid can never be NULL because it was NULL-checked earlier

* Change namelen to size_t because it is always unsigned and less in size than size_t

* Remove redundant check on ser

It can't be NULL, and even if it could, the ser++ would be UB.
2023-02-28 12:29:40 +01:00
David Carlier
dfec0e4e36 Merge branch 'PHP-8.2' 2023-02-21 16:12:17 +00:00
David Carlier
9995514718 Merge branch 'PHP-8.1' into PHP-8.2 2023-02-21 16:10:32 +00:00
nielsdos
da3ce6015d Propagate errors correctly in ps_files_cleanup_dir()
In SessionHandler::gc, we use a virtual call to PS(default_mod)->s_gc to
call the gc implementation. That return value is checked against
FAILURE (-1).
One of the call targets of PS(default_mod)->s_gc is ps_gc_files().
ps_gc_files() calls to ps_files_cleanup_dir(). The latter function has
some error checks and outputs a notice if something goes wrong. In cases
of errors, the function returns 0. This means that the check in
SessionHandler::gc will misinterpret this as a success and report that 0
files have been *successfully* cleaned up. Fix it by returning -1 to
indicate something *did* go wrong.

Closes GH-10644.
2023-02-21 16:09:22 +00:00
Tim Düsterhus
d9c2cf7e3d session: Remove PS_EXTRA_RAND_BYTES (#10394)
This was introduced in 3467526a65 and the
corresponding RFC gives some reasoning. However the CSPRNG being “not secure
enough” is not a thing and reading these extra bytes is just security theater:

If the CSPRNG would hypothetically be broken, then PHP’s session IDs are the
least of one’s concerns, because we already trust it in `random_bytes()` and
might generate long-term secrets using that.
2023-01-23 14:42:32 +01: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
Tim Düsterhus
dd8de1e726 Promote unserialize() notices to warning (#9629)
* Unserialize: Migrate "Unexpected end of serialized data" to E_WARNING

* Unserialize: Migrate "Error at offset %d of %d bytes" to E_WARNING

* Unserialize: Migrate "%s is returned from __sleep() multiple times" to E_WARNING

* Add NEWS for “Promote unserialize() notices to warning”
2022-11-15 19:36:38 +01:00
David Carlier
da47547809 Merge branch 'PHP-8.2' 2022-11-15 12:31:33 +00:00
David Carlier
65782fbbe8 Merge branch 'PHP-8.1' into PHP-8.2 2022-11-15 12:30:04 +00:00
David Carlier
a4298c14c1 Fix GH-9932: Discards further characters for session name.
As those are converted, it s better to make aware of the code caller of the naming inadequacy.
Closes GH-9940.
2022-11-15 12:27:44 +00:00
George Peter Banyard
8e9fa2bd23 Convert mod user FINISH macro to static function 2022-10-22 12:47:34 +01:00
George Peter Banyard
3917018806 Inline macros and add argument to FINISH macro 2022-10-22 12:47:34 +01:00
George Peter Banyard
2ad96b0812 Assert that mandatory user handlers are defined 2022-10-22 12:47:34 +01:00
George Peter Banyard
51888425da Drop struct union as access is now always named 2022-10-22 12:47:34 +01:00
George Peter Banyard
2ddd68aa20 Free handles by name directly 2022-10-22 12:47:34 +01:00
George Peter Banyard
5b40d06680 Refactor session_set_save_handler()
Use proper ZPP callables with FCI/FCC
2022-10-22 12:47:34 +01:00
George Peter Banyard
15c0df76b5 Add regression test for not setting optional closures again 2022-10-22 12:47:34 +01:00