Skip to content

ext/session: fix cookie_lifetime overflow#21704

Open
jorgsowa wants to merge 3 commits intophp:masterfrom
jorgsowa:fix/session-cookie-lifetime-overflow
Open

ext/session: fix cookie_lifetime overflow#21704
jorgsowa wants to merge 3 commits intophp:masterfrom
jorgsowa:fix/session-cookie-lifetime-overflow

Conversation

@jorgsowa
Copy link
Copy Markdown
Contributor

@jorgsowa jorgsowa commented Apr 10, 2026

When session.cookie_lifetime was set to a value larger than maxcookie, OnUpdateCookieLifetime returned SUCCESS without updating the internal long value, causing ini_get() string and PS(cookie_lifetime) to go out of sync.

Now the value is properly clamped to maxcookie with both the string and internal long updated consistently, and a warning is emitted.

Edit:
Added validation of value of maxcookie, only numeric strings are allowed.

When session.cookie_lifetime was set to a value larger than maxcookie,
OnUpdateCookieLifetime returned SUCCESS without updating the internal
long value, causing ini_get() string and PS(cookie_lifetime) to go
out of sync.

Now the value is properly clamped to maxcookie with both the string
and internal long updated consistently, and a warning is emitted.
Copy link
Copy Markdown
Member

@Girgias Girgias left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While at it could you fix the way we parse the string as well? As this probably allows non numeric strings and float strings.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably shouldn't be using atol() here. Possibly is_numeric string ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice idea. I have added proper validation for the type of value.

@jorgsowa jorgsowa marked this pull request as ready for review April 11, 2026 09:43
@jorgsowa jorgsowa requested a review from Girgias April 11, 2026 09:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants