@@ -709,19 +709,19 @@ static PHP_INI_MH(OnUpdateCookieLifetime)
709709 zend_long lval = 0 ;
710710 int oflow = 0 ;
711711 uint8_t type = is_numeric_string_ex (ZSTR_VAL (new_value ), ZSTR_LEN (new_value ), & lval , NULL , false, & oflow , NULL );
712- if (type == 0 ) {
713- php_error_docref (NULL , E_WARNING , "Invalid value for CookieLifetime" );
714- return FAILURE ;
715- } else if (type == IS_DOUBLE && oflow == 0 ) {
716- php_error_docref (NULL , E_WARNING , "CookieLifetime must be an integer" );
712+ if (UNEXPECTED (type != IS_LONG )) {
713+ if (oflow != 0 ) {
714+ php_error_docref (NULL , E_WARNING , "session.cookie_lifetime must be between 0 and " ZEND_LONG_FMT , maxcookie );
715+ } else {
716+ php_error_docref (NULL , E_WARNING , "session.cookie_lifetime must be an integer" );
717+ }
717718 return FAILURE ;
718719 }
719- zend_long v = lval ;
720- if (oflow < 0 || v < 0 ) {
721- php_error_docref (NULL , E_WARNING , "CookieLifetime cannot be negative" );
720+ if (lval < 0 ) {
721+ php_error_docref (NULL , E_WARNING , "session.cookie_lifetime must be between 0 and " ZEND_LONG_FMT , maxcookie );
722722 return FAILURE ;
723- } else if (oflow > 0 || v > maxcookie ) {
724- php_error_docref (NULL , E_WARNING , "CookieLifetime value too large, value was set to the maximum of " ZEND_LONG_FMT , maxcookie );
723+ } else if (lval > maxcookie ) {
724+ php_error_docref (NULL , E_WARNING , "session.cookie_lifetime must be between 0 and " ZEND_LONG_FMT ", value clamped to maximum" , maxcookie );
725725 zend_long * p = ZEND_INI_GET_ADDR ();
726726 * p = maxcookie ;
727727 entry -> value = zend_long_to_str (maxcookie );
0 commit comments