summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorolavmrk <olavmrk@a716ebb1-153a-0410-b759-cfb97c6a1b53>2014-06-20 11:25:02 +0000
committerolavmrk <olavmrk@a716ebb1-153a-0410-b759-cfb97c6a1b53>2014-06-20 11:25:02 +0000
commitf60d394094439102ef140132c187a1f6f3cb0d50 (patch)
tree890cc6f8ccb320258e8e7df9843abc01dbee5bb2
parentf91a46b9b45e5502b2c863995ed6ad2c89d3eddb (diff)
downloadmod_auth_mellon-f60d394094439102ef140132c187a1f6f3cb0d50.zip
mod_auth_mellon-f60d394094439102ef140132c187a1f6f3cb0d50.tar.gz
mod_auth_mellon-f60d394094439102ef140132c187a1f6f3cb0d50.tar.xz
Convert lasso_session to dynamic size storage
Using the previously introduced storage facility converts storage of lasso_session from being constrained to a fixed sized string to being constrained only by the overall entry cache size. Signed-off-by: Simo Sorce <simo@redhat.com> git-svn-id: https://modmellon.googlecode.com/svn/trunk@233 a716ebb1-153a-0410-b759-cfb97c6a1b53
-rw-r--r--auth_mellon.h3
-rw-r--r--auth_mellon_cache.c39
2 files changed, 16 insertions, 26 deletions
diff --git a/auth_mellon.h b/auth_mellon.h
index 984c35e..4002147 100644
--- a/auth_mellon.h
+++ b/auth_mellon.h
@@ -75,7 +75,6 @@
#define AM_CACHE_VALSIZE 512-AM_CACHE_VARSIZE
#define AM_CACHE_ENVSIZE 128
#define AM_CACHE_USERSIZE 512
-#define AM_CACHE_MAX_LASSO_SESSION_SIZE 32768
#define AM_CACHE_MAX_LASSO_SAML_RESPONSE_SIZE 65536
#define AM_CACHE_DEFAULT_ENTRY_SIZE 196608
#define AM_CACHE_MIN_ENTRY_SIZE 65536
@@ -265,7 +264,7 @@ typedef struct am_cache_entry_t {
*and logout requests.
*/
am_cache_storage_t lasso_identity;
- char lasso_session[AM_CACHE_MAX_LASSO_SESSION_SIZE];
+ am_cache_storage_t lasso_session;
char lasso_saml_response[AM_CACHE_MAX_LASSO_SAML_RESPONSE_SIZE];
am_cache_env_t env[AM_CACHE_ENVSIZE];
diff --git a/auth_mellon_cache.c b/auth_mellon_cache.c
index fb21cd8..645cb67 100644
--- a/auth_mellon_cache.c
+++ b/auth_mellon_cache.c
@@ -313,7 +313,7 @@ am_cache_entry_t *am_cache_new(server_rec *s, const char *key)
t->user[0] = '\0';
am_cache_storage_null(&t->lasso_identity);
- t->lasso_session[0] = '\0';
+ am_cache_storage_null(&t->lasso_session);
t->pool_size = am_cache_entry_pool_size(mod_cfg);
t->pool[0] = '\0';
@@ -533,13 +533,15 @@ void am_cache_env_populate(request_rec *r, am_cache_entry_t *t)
/* Populate with the session? */
if (d->dump_session) {
char *session;
+ const char *srcstr;
int srclen, dstlen;
- srclen = strlen(t->lasso_session);
+ srcstr = am_cache_entry_get_string(t, &t->lasso_session);
+ srclen = strlen(srcstr);
dstlen = apr_base64_encode_len(srclen);
session = apr_palloc(r->pool, dstlen);
- (void)apr_base64_encode(session, t->lasso_session, srclen);
+ (void)apr_base64_encode(session, srcstr, srclen);
apr_table_set(r->subprocess_env, "MELLON_SESSION", session);
}
@@ -601,22 +603,15 @@ int am_cache_set_lasso_state(am_cache_entry_t *session,
return HTTP_INTERNAL_SERVER_ERROR;
}
-
- if(lasso_session != NULL) {
- if(strlen(lasso_session) < AM_CACHE_MAX_LASSO_SESSION_SIZE) {
- strcpy(session->lasso_session, lasso_session);
- } else {
- ap_log_error(APLOG_MARK, APLOG_ERR, 0, NULL,
- "Lasso session is to big for storage. Size of lasso"
- " session is %" APR_SIZE_T_FMT ", max size is %"
- APR_SIZE_T_FMT ".",
- (apr_size_t)strlen(lasso_session),
- (apr_size_t)AM_CACHE_MAX_LASSO_SESSION_SIZE - 1);
- return HTTP_INTERNAL_SERVER_ERROR;
- }
- } else {
- /* No session dump to save. */
- strcpy(session->lasso_session, "");
+ status = am_cache_entry_store_string(session,
+ &session->lasso_session,
+ lasso_session);
+ if (status != 0) {
+ ap_log_error(APLOG_MARK, APLOG_ERR, 0, NULL,
+ "Lasso session is to big for storage. Size of lasso"
+ " session is %" APR_SIZE_T_FMT ".",
+ (apr_size_t)strlen(lasso_session));
+ return HTTP_INTERNAL_SERVER_ERROR;
}
if(lasso_saml_response != NULL) {
@@ -664,9 +659,5 @@ const char *am_cache_get_lasso_identity(am_cache_entry_t *session)
*/
const char *am_cache_get_lasso_session(am_cache_entry_t *session)
{
- if(strlen(session->lasso_session) == 0) {
- return NULL;
- }
-
- return session->lasso_session;
+ return am_cache_entry_get_string(session, &session->lasso_session);
}