Skip to content

Commit f31232e

Browse files
committed
Merge branch 'PHP-8.2' into PHP-8.3
2 parents 631c04e + 84a8fea commit f31232e

File tree

4 files changed

+27
-3
lines changed

4 files changed

+27
-3
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ PHP NEWS
3636
- Session:
3737
. Fixed bug GH-16385 (Unexpected null returned by session_set_cookie_params).
3838
(nielsdos)
39+
. Fixed bug GH-16290 (overflow on cookie_lifetime ini value).
40+
(David Carlier)
3941

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

ext/session/session.c

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

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)