Skip to content

Commit 6047e4f

Browse files
committed
add test
1 parent 49d3942 commit 6047e4f

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

ext/session/session.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -695,7 +695,7 @@ static PHP_INI_MH(OnUpdateCookieLifetime) /* {{{ */
695695
SESSION_CHECK_ACTIVE_STATE;
696696
SESSION_CHECK_OUTPUT_STATE;
697697

698-
const zend_long maxcookie = ZEND_LONG_MAX - (PHP_TIMEOUT_ULL_MAX / 1000000);
698+
const zend_long maxcookie = ZEND_LONG_MAX - (zend_long)((double)PHP_TIMEOUT_ULL_MAX / 1000000.0);
699699
zend_long v = (zend_long)atol(ZSTR_VAL(new_value));
700700
if (v < 0 || v > maxcookie) {
701701
php_error_docref(NULL, E_WARNING, "CookieLifetime must be between 0 and " ZEND_LONG_FMT, maxcookie);

ext/session/tests/gh16290.phpt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
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+
?>
11+
--EXPECTF--
12+
Warning: session_set_cookie_params(): CookieLifetime must be between 0 and %d in %s on line %d

0 commit comments

Comments
 (0)