Skip to content

Commit

Permalink
MFH
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan Esser committed Jun 16, 2007
1 parent 83828a3 commit 3e37881
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions ext/session/session.c
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,7 @@ static void php_session_initialize(TSRMLS_D)
int vallen;

/* check session name for invalid characters */
if (PS(id) && strpbrk(PS(id), "\r\n\t <>'\"\\()@,;:[]?={}&%")) {
if (PS(id) && strpbrk(PS(id), "\r\n\t <>'\"\\")) {
efree(PS(id));
PS(id) = NULL;
}
Expand Down Expand Up @@ -918,6 +918,7 @@ static void php_session_send_cookie(TSRMLS_D)
{
smart_str ncookie = {0};
char *date_fmt = NULL;
char *e_session_name, *e_id;

if (SG(headers_sent)) {
char *output_start_filename = php_get_output_start_filename(TSRMLS_C);
Expand All @@ -931,11 +932,18 @@ static void php_session_send_cookie(TSRMLS_D)
}
return;
}

/* URL encode session_name and id because they might be user supplied */
e_session_name = php_url_encode(PS(session_name), strlen(PS(session_name)), NULL);
e_id = php_url_encode(PS(id), strlen(PS(id)), NULL);

smart_str_appends(&ncookie, COOKIE_SET_COOKIE);
smart_str_appends(&ncookie, PS(session_name));
smart_str_appends(&ncookie, e_session_name);
smart_str_appendc(&ncookie, '=');
smart_str_appends(&ncookie, PS(id));
smart_str_appends(&ncookie, e_id);

efree(e_session_name);
efree(e_id);

if (PS(cookie_lifetime) > 0) {
struct timeval tv;
Expand Down

0 comments on commit 3e37881

Please sign in to comment.