From e486a708c5506f1014f0e1ae98d4d98c41e5274e Mon Sep 17 00:00:00 2001 From: olavmrk Date: Fri, 20 Jun 2014 11:25:16 +0000 Subject: Convert lasso_saml_response to dynamic size storage Using the previously introduced storage facility converts storage of lasso_saml_reponse from being constrained to a fixed sized string to being constrained only by the overall entry cache size. Signed-off-by: Simo Sorce git-svn-id: https://modmellon.googlecode.com/svn/trunk@234 a716ebb1-153a-0410-b759-cfb97c6a1b53 --- auth_mellon.h | 3 +-- auth_mellon_cache.c | 35 ++++++++++++++++------------------- 2 files changed, 17 insertions(+), 21 deletions(-) diff --git a/auth_mellon.h b/auth_mellon.h index 4002147..64b6af1 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_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 { */ am_cache_storage_t lasso_identity; am_cache_storage_t lasso_session; - char lasso_saml_response[AM_CACHE_MAX_LASSO_SAML_RESPONSE_SIZE]; + am_cache_storage_t lasso_saml_response; am_cache_env_t env[AM_CACHE_ENVSIZE]; diff --git a/auth_mellon_cache.c b/auth_mellon_cache.c index 645cb67..e37eab5 100644 --- a/auth_mellon_cache.c +++ b/auth_mellon_cache.c @@ -314,6 +314,7 @@ am_cache_entry_t *am_cache_new(server_rec *s, const char *key) am_cache_storage_null(&t->lasso_identity); am_cache_storage_null(&t->lasso_session); + am_cache_storage_null(&t->lasso_saml_response); t->pool_size = am_cache_entry_pool_size(mod_cfg); t->pool[0] = '\0'; @@ -545,10 +546,12 @@ void am_cache_env_populate(request_rec *r, am_cache_entry_t *t) apr_table_set(r->subprocess_env, "MELLON_SESSION", session); } - if (d->dump_saml_response) - apr_table_set(r->subprocess_env, - "MELLON_SAML_RESPONSE", - t->lasso_saml_response); + if (d->dump_saml_response) { + const char *sr = am_cache_entry_get_string(t, &t->lasso_saml_response); + if (sr) { + apr_table_set(r->subprocess_env, "MELLON_SAML_RESPONSE", sr); + } + } } @@ -614,21 +617,15 @@ int am_cache_set_lasso_state(am_cache_entry_t *session, return HTTP_INTERNAL_SERVER_ERROR; } - if(lasso_saml_response != NULL) { - if(strlen(lasso_saml_response) < AM_CACHE_MAX_LASSO_SAML_RESPONSE_SIZE) { - strcpy(session->lasso_saml_response, lasso_saml_response); - } else { - ap_log_error(APLOG_MARK, APLOG_ERR, 0, NULL, - "Lasso SAML response 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_saml_response), - (apr_size_t)AM_CACHE_MAX_LASSO_SAML_RESPONSE_SIZE - 1); - return HTTP_INTERNAL_SERVER_ERROR; - } - } else { - /* No session dump to save. */ - strcpy(session->lasso_saml_response, ""); + status = am_cache_entry_store_string(session, + &session->lasso_saml_response, + lasso_saml_response); + if (status != 0) { + ap_log_error(APLOG_MARK, APLOG_ERR, 0, NULL, + "Lasso SAML response is to big for storage. Size of " + "lasso SAML Reponse is %" APR_SIZE_T_FMT ".", + (apr_size_t)strlen(lasso_saml_response)); + return HTTP_INTERNAL_SERVER_ERROR; } return OK; -- cgit