Skip to content

Commit 4d008e3

Browse files
committed
Merge branch 'PHP-8.3' into PHP-8.4
2 parents a7918a7 + f31232e commit 4d008e3

File tree

4 files changed

+27
-3
lines changed

4 files changed

+27
-3
lines changed

NEWS

+2
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ PHP NEWS
4040
- Session:
4141
. Fixed bug GH-16385 (Unexpected null returned by session_set_cookie_params).
4242
(nielsdos)
43+
. Fixed bug GH-16290 (overflow on cookie_lifetime ini value).
44+
(David Carlier)
4345

4446
- SOAP:
4547
. Fixed bug GH-16318 (Recursive array segfaults soap encoding). (nielsdos)

ext/session/session.c

+10-1
Original file line numberDiff line numberDiff line change
@@ -707,9 +707,18 @@ static PHP_INI_MH(OnUpdateCookieLifetime) /* {{{ */
707707
{
708708
SESSION_CHECK_ACTIVE_STATE;
709709
SESSION_CHECK_OUTPUT_STATE;
710-
if (atol(ZSTR_VAL(new_value)) < 0) {
710+
711+
#ifdef ZEND_ENABLE_ZVAL_LONG64
712+
const zend_long maxcookie = ZEND_LONG_MAX - INT_MAX - 1;
713+
#else
714+
const zend_long maxcookie = ZEND_LONG_MAX / 2 - 1;
715+
#endif
716+
zend_long v = (zend_long)atol(ZSTR_VAL(new_value));
717+
if (v < 0) {
711718
php_error_docref(NULL, E_WARNING, "CookieLifetime cannot be negative");
712719
return FAILURE;
720+
} else if (v > maxcookie) {
721+
return SUCCESS;
713722
}
714723
return OnUpdateLongGEZero(entry, new_value, mh_arg1, mh_arg2, mh_arg3, stage);
715724
}

ext/session/tests/gh16290.phpt

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
--TEST--
2+
GH-16290 (overflow on session cookie_lifetime ini)
3+
--EXTENSIONS--
4+
session
5+
--SKIPIF--
6+
<?php include('skipif.inc'); ?>
7+
--FILE--
8+
<?php
9+
session_set_cookie_params(PHP_INT_MAX, '/', null, false, true);
10+
echo "DONE";
11+
?>
12+
--EXPECT--
13+
DONE

ext/session/tests/session_get_cookie_params_basic.phpt

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ var_dump(session_get_cookie_params());
3535
echo "Done";
3636
ob_end_flush();
3737
?>
38-
--EXPECT--
38+
--EXPECTF--
3939
*** Testing session_get_cookie_params() : basic functionality ***
4040
array(6) {
4141
["lifetime"]=>
@@ -69,7 +69,7 @@ array(6) {
6969
bool(true)
7070
array(6) {
7171
["lifetime"]=>
72-
int(1234567890)
72+
int(%d)
7373
["path"]=>
7474
string(5) "/guff"
7575
["domain"]=>

0 commit comments

Comments
 (0)