Skip to content

Commit b651ca6

Browse files
committed
add test
1 parent 49d3942 commit b651ca6

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

ext/session/session.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
#include "ext/standard/php_var.h"
4141
#include "ext/date/php_date.h"
4242
#include "ext/standard/url_scanner_ex.h"
43-
#include "ext/standard/file.h"
4443
#include "ext/standard/info.h"
4544
#include "zend_smart_str.h"
4645
#include "ext/standard/url.h"
@@ -695,7 +694,7 @@ static PHP_INI_MH(OnUpdateCookieLifetime) /* {{{ */
695694
SESSION_CHECK_ACTIVE_STATE;
696695
SESSION_CHECK_OUTPUT_STATE;
697696

698-
const zend_long maxcookie = ZEND_LONG_MAX - (PHP_TIMEOUT_ULL_MAX / 1000000);
697+
const zend_long maxcookie = ZEND_LONG_MAX / 2 ;
699698
zend_long v = (zend_long)atol(ZSTR_VAL(new_value));
700699
if (v < 0 || v > maxcookie) {
701700
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)