Skip to content

Commit c640f3d

Browse files
author
Sascha Schumann
committed
Implement additional heuristic for session id search. Now looks into
REQUEST_URI as well.
1 parent 7ae27b5 commit c640f3d

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

ext/session/session.c

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,17 +327,21 @@ static void _php_session_start(PSLS_D)
327327
{
328328
pval **ppid;
329329
pval **data;
330+
char *p;
330331
int send_cookie = 1;
331332
int define_sid = 1;
332333
int module_number = PS(module_number);
333334
int nrand;
335+
int lensess;
334336
ELS_FETCH();
335337

336338
if (PS(nr_open_sessions) > 0) return;
337339

340+
lensess = strlen(PS(session_name));
341+
338342
if(!PS(id) &&
339343
zend_hash_find(&EG(symbol_table), PS(session_name),
340-
strlen(PS(session_name)) + 1, (void **) &ppid) == SUCCESS) {
344+
lensess + 1, (void **) &ppid) == SUCCESS) {
341345
convert_to_string((*ppid));
342346
PS(id) = estrndup((*ppid)->value.str.val, (*ppid)->value.str.len);
343347
send_cookie = 0;
@@ -348,9 +352,22 @@ static void _php_session_start(PSLS_D)
348352
sizeof("HTTP_COOKIE_VARS"), (void **) &data) == SUCCESS &&
349353
(*data)->type == IS_ARRAY &&
350354
zend_hash_find((*data)->value.ht, PS(session_name),
351-
strlen(PS(session_name)) + 1, (void **) &ppid) == SUCCESS) {
355+
lensess + 1, (void **) &ppid) == SUCCESS) {
352356
define_sid = 0;
353357
}
358+
359+
if(!PS(id) &&
360+
zend_hash_find(&EG(symbol_table), "REQUEST_URI",
361+
sizeof("REQUEST_URI"), (void **) &data) == SUCCESS &&
362+
(*data)->type == IS_STRING &&
363+
(p = strstr((*data)->value.str.val, PS(session_name))) &&
364+
p[lensess] == '=') {
365+
char *q;
366+
367+
p += lensess + 1;
368+
if((q = strpbrk(p, "/?\\")))
369+
PS(id) = estrndup(p, q - p);
370+
}
354371

355372
if(!PS(id)) {
356373
PS(id) = _php_create_id(NULL);

0 commit comments

Comments
 (0)