ASF Bugzilla – Attachment 21300 Details for
Bug 44116
Multiple JSESSIONID handling with overlapping domains does not work
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Handle multiple JSESSIONID cookies with tomcat overlaping domains
tomcat-connectors-1.2.25-src_jk_lb_worker.c.patch (text/plain), 3.88 KB, created by
david ramblewski
on 2007-12-21 03:04:24 UTC
(
hide
)
Description:
Handle multiple JSESSIONID cookies with tomcat overlaping domains
Filename:
MIME Type:
Creator:
david ramblewski
Created:
2007-12-21 03:04:24 UTC
Size:
3.88 KB
patch
obsolete
>--- tomcat-connectors-1.2.25-src/native/common/jk_lb_worker.c Thu Aug 2 19:42:23 2007 >+++ tomcat-connectors-1.2.25-src_patched/native/common/jk_lb_worker.c Thu Dec 13 14:11:35 2007 >@@ -22,7 +22,7 @@ > * Author: Mladen Turk <mturk@apache.org> * > * Author: Rainer Jung <rjung@apache.org> * > * Based on: * >- * Version: $Revision: 562194 $ * >+ * Version: $Revision: 1.6 $ * > ***************************************************************************/ > > #include "jk_pool.h" >@@ -336,46 +336,57 @@ > } > > /* Retrieve the cookie with the given name */ >-static char *get_cookie(jk_ws_service_t *s, const char *name) >+static char *get_cookie(jk_ws_service_t *s, const char *name, jk_logger_t *l) > { >- unsigned i; >- char *result = NULL; >+ char *result = NULL; >+ char *id_start; >+ char *id_end; >+ unsigned i; >+ size_t sz, osz; > > for (i = 0; i < s->num_headers; i++) { > if (strcasecmp(s->headers_names[i], "cookie") == 0) { > >- char *id_start; > for (id_start = strstr(s->headers_values[i], name); > id_start; id_start = strstr(id_start + 1, name)) { >+ > if (id_start == s->headers_values[i] || > id_start[-1] == ';' || > id_start[-1] == ',' || isspace((int)id_start[-1])) { > id_start += strlen(name); >+ > while (*id_start && isspace((int)(*id_start))) > ++id_start; >+ > if (*id_start == '=' && id_start[1]) { > /* > * Session cookie was found, get it's value > */ >- char *id_end; > ++id_start; >- id_start = jk_pool_strdup(s->pool, id_start); >- if ((id_end = strchr(id_start, ';')) != NULL) { >- *id_end = '\0'; >- } >- if ((id_end = strchr(id_start, ',')) != NULL) { >- *id_end = '\0'; >- } >+ >+ if ((id_end = strchr(id_start, ';')) != NULL || (id_end = strchr(id_start, ',')) != NULL) >+ sz = id_end - id_start; >+ else >+ sz = strlen(id_start); >+ > if (result == NULL) { >- result = id_start; >+ result = jk_pool_alloc(s->pool, sz + 1); >+ if (!result) { >+ jk_log(l, JK_LOG_ERROR, "Cannot allocate memory for %s", name); >+ return result; >+ } >+ memcpy(result, id_start, sz); >+ result[sz] = '\0'; > } >- else { >- size_t osz = strlen(result) + 1; >- size_t sz = osz + strlen(id_start) + 1; >- result = >- jk_pool_realloc(s->pool, sz, result, osz); >- strcat(result, ";"); >- strcat(result, id_start); >+ else { >+ osz = strlen(result) + 1; >+ result = jk_pool_realloc(s->pool, osz + sz + 1, result, osz); >+ if (!result) { >+ jk_log(l, JK_LOG_ERROR, "Cannot reallocate memory for %s", name); >+ return result; >+ } >+ strcat(result, ";"); >+ strncat(result, id_start, sz); > } > } > } >@@ -395,7 +406,7 @@ > char *val; > val = get_path_param(s, JK_PATH_SESSION_IDENTIFIER); > if (!val) { >- val = get_cookie(s, JK_SESSION_IDENTIFIER); >+ val = get_cookie(s, JK_SESSION_IDENTIFIER, l); > } > if (val && !*val) { > /* TODO: For now only log the empty sessions.
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 44116
:
21300
|
21338