summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorolavmrk <olavmrk@a716ebb1-153a-0410-b759-cfb97c6a1b53>2014-06-20 11:24:56 +0000
committerolavmrk <olavmrk@a716ebb1-153a-0410-b759-cfb97c6a1b53>2014-06-20 11:24:56 +0000
commitf91a46b9b45e5502b2c863995ed6ad2c89d3eddb (patch)
tree5fa5f16d190d2af1f6b41e658123a3d1e6bac0f5
parent8dacb0388763ec4da5198b2d6063b45067e16c21 (diff)
downloadmod_auth_mellon-f91a46b9b45e5502b2c863995ed6ad2c89d3eddb.tar.gz
mod_auth_mellon-f91a46b9b45e5502b2c863995ed6ad2c89d3eddb.tar.xz
mod_auth_mellon-f91a46b9b45e5502b2c863995ed6ad2c89d3eddb.zip
Convert lasso_identity to dynamic size storage
Using the previously introduced storage facility converts storage of lasso_identity 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@232 a716ebb1-153a-0410-b759-cfb97c6a1b53
-rw-r--r--auth_mellon.h3
-rw-r--r--auth_mellon_cache.c36
2 files changed, 14 insertions, 25 deletions
diff --git a/auth_mellon.h b/auth_mellon.h
index 5156851..984c35e 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_IDENTITY_SIZE 1024
#define AM_CACHE_MAX_LASSO_SESSION_SIZE 32768
#define AM_CACHE_MAX_LASSO_SAML_RESPONSE_SIZE 65536
#define AM_CACHE_DEFAULT_ENTRY_SIZE 196608
@@ -265,7 +264,7 @@ typedef struct am_cache_entry_t {
/* Variables used to store lasso state between login requests
*and logout requests.
*/
- char lasso_identity[AM_CACHE_MAX_LASSO_IDENTITY_SIZE];
+ am_cache_storage_t lasso_identity;
char lasso_session[AM_CACHE_MAX_LASSO_SESSION_SIZE];
char lasso_saml_response[AM_CACHE_MAX_LASSO_SAML_RESPONSE_SIZE];
diff --git a/auth_mellon_cache.c b/auth_mellon_cache.c
index 0d64a82..fb21cd8 100644
--- a/auth_mellon_cache.c
+++ b/auth_mellon_cache.c
@@ -55,8 +55,6 @@ am_cache_entry_t *am_cache_lock(server_rec *s,
return NULL;
break;
case AM_CACHE_NAMEID:
- if (strlen(key) > AM_CACHE_MAX_LASSO_IDENTITY_SIZE)
- return NULL;
break;
default:
return NULL;
@@ -314,7 +312,7 @@ am_cache_entry_t *am_cache_new(server_rec *s, const char *key)
t->size = 0;
t->user[0] = '\0';
- t->lasso_identity[0] = '\0';
+ am_cache_storage_null(&t->lasso_identity);
t->lasso_session[0] = '\0';
t->pool_size = am_cache_entry_pool_size(mod_cfg);
@@ -590,21 +588,17 @@ int am_cache_set_lasso_state(am_cache_entry_t *session,
const char *lasso_session,
const char *lasso_saml_response)
{
- if(lasso_identity != NULL) {
- if(strlen(lasso_identity) < AM_CACHE_MAX_LASSO_IDENTITY_SIZE) {
- strcpy(session->lasso_identity, lasso_identity);
- } else {
- ap_log_error(APLOG_MARK, APLOG_ERR, 0, NULL,
- "Lasso identity is to big for storage. Size of lasso"
- " identity is %" APR_SIZE_T_FMT ", max size is %"
- APR_SIZE_T_FMT ".",
- (apr_size_t)strlen(lasso_identity),
- (apr_size_t)AM_CACHE_MAX_LASSO_IDENTITY_SIZE - 1);
- return HTTP_INTERNAL_SERVER_ERROR;
- }
- } else {
- /* No identity dump to save. */
- strcpy(session->lasso_identity, "");
+ int status;
+
+ status = am_cache_entry_store_string(session,
+ &session->lasso_identity,
+ lasso_identity);
+ if (status != 0) {
+ ap_log_error(APLOG_MARK, APLOG_ERR, 0, NULL,
+ "Lasso identity is to big for storage. Size of lasso"
+ " identity is %" APR_SIZE_T_FMT ".",
+ (apr_size_t)strlen(lasso_identity));
+ return HTTP_INTERNAL_SERVER_ERROR;
}
@@ -656,11 +650,7 @@ int am_cache_set_lasso_state(am_cache_entry_t *session,
*/
const char *am_cache_get_lasso_identity(am_cache_entry_t *session)
{
- if(strlen(session->lasso_identity) == 0) {
- return NULL;
- }
-
- return session->lasso_identity;
+ return am_cache_entry_get_string(session, &session->lasso_identity);
}