Skip to content

ext/session: fix cookie_lifetime overflow#21704

Draft
jorgsowa wants to merge 1 commit intophp:masterfrom
jorgsowa:fix/session-cookie-lifetime-overflow
Draft

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

Conversation

@jorgsowa
Copy link
Copy Markdown
Contributor

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.

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.

#else
const zend_long maxcookie = ZEND_LONG_MAX / 2 - 1;
#endif
zend_long v = (zend_long)atol(ZSTR_VAL(new_value));
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 ?

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