Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix saving sessions in PHP 5.4 with user session handlers (fix #12) #26

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 18 additions & 3 deletions session.c
Expand Up @@ -728,7 +728,12 @@ static int suhosin_hook_s_read(void **mod_data, const char *key, char **val, int
}*/

/* protect dumb session handlers */
if (key == NULL || !key[0] || *mod_data == NULL) {
if (key == NULL || !key[0] ||
(*mod_data == NULL
#if PHP_VERSION_ID >= 50400
&& !SESSION_G(mod_user_implemented)
#endif
)) {
regenerate:
SDEBUG("regenerating key is %s", key);
KEY = SESSION_G(id) = SESSION_G(mod)->s_create_sid(&SESSION_G(mod_data), NULL TSRMLS_CC);
Expand Down Expand Up @@ -777,7 +782,12 @@ static int suhosin_hook_s_write(void **mod_data, const char *key, const char *va
char *v = (char *)val;

/* protect dumb session handlers */
if (key == NULL || !key[0] || val == NULL || strlen(key) > SUHOSIN_G(session_max_id_length) || *mod_data == NULL) {
if (key == NULL || !key[0] || val == NULL || strlen(key) > SUHOSIN_G(session_max_id_length) ||
(*mod_data == NULL
#if PHP_VERSION_ID >= 50400
&& !SESSION_G(mod_user_implemented)
#endif
)) {
r = FAILURE;
goto return_write;
}
Expand Down Expand Up @@ -820,7 +830,12 @@ static int suhosin_hook_s_destroy(void **mod_data, const char *key TSRMLS_DC)
int r;

/* protect dumb session handlers */
if (key == NULL || !key[0] || strlen(key) > SUHOSIN_G(session_max_id_length) || *mod_data == NULL) {
if (key == NULL || !key[0] || strlen(key) > SUHOSIN_G(session_max_id_length) ||
(*mod_data == NULL
#if PHP_VERSION_ID >= 50400
&& !SESSION_G(mod_user_implemented)
#endif
)) {
return FAILURE;
}

Expand Down