Skip to content

Commit ecccb36

Browse files
committed
Merge branch 'PHP-8.4'
2 parents 150599e + 4d008e3 commit ecccb36

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

ext/session/session.c

Lines changed: 10 additions & 1 deletion
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

Lines changed: 13 additions & 0 deletions
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

Lines changed: 2 additions & 2 deletions
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)