summaryrefslogtreecommitdiffstats
path: root/src/sessions.c
diff options
context:
space:
mode:
authorSimo Sorce <simo@redhat.com>2015-06-16 09:36:34 -0400
committerSimo Sorce <simo@redhat.com>2015-06-16 13:26:35 -0400
commit10d352bac12353efb5fe6e6efd2655e0562a1f8e (patch)
tree04aa53477b198be6948592cfed7cc089eb0d04d3 /src/sessions.c
parentdb750842dd9e7bf2dd76bc9be91bbd4d045d3179 (diff)
downloadmod_auth_gssapi-10d352bac12353efb5fe6e6efd2655e0562a1f8e.tar.gz
mod_auth_gssapi-10d352bac12353efb5fe6e6efd2655e0562a1f8e.tar.xz
mod_auth_gssapi-10d352bac12353efb5fe6e6efd2655e0562a1f8e.zip
Improve mag_conn memory handling
Create a pool just for the mag_conn structure, so that we can clear up all the memory used when a reset is necessary. This also fixes a segfault introduced by a previous patch where we mistakenly zeroed the whole structure including the memory pool pointer, which needs to be preserved. Closes #40 Signed-off-by: Simo Sorce <simo@redhat.com>
Diffstat (limited to 'src/sessions.c')
-rw-r--r--src/sessions.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/src/sessions.c b/src/sessions.c
index 20679f9..73d600c 100644
--- a/src/sessions.c
+++ b/src/sessions.c
@@ -108,11 +108,7 @@ void mag_check_session(request_rec *req,
mc = *conn;
if (!mc) {
- mc = apr_pcalloc(req->pool, sizeof(struct mag_conn));
- if (!mc) return;
-
- mc->parent = req->pool;
- *conn = mc;
+ *conn = mc = mag_new_conn_ctx(req->pool);
}
rc = mag_session_get(req, sess, MAG_BEARER_KEY, &sessval);
@@ -165,19 +161,19 @@ void mag_check_session(request_rec *req,
}
/* user name */
- mc->user_name = apr_pstrndup(mc->parent,
+ mc->user_name = apr_pstrndup(mc->pool,
(char *)gsessdata->username.buf,
gsessdata->username.size);
if (!mc->user_name) goto done;
/* gssapi name */
- mc->gss_name = apr_pstrndup(mc->parent,
+ mc->gss_name = apr_pstrndup(mc->pool,
(char *)gsessdata->gssname.buf,
gsessdata->gssname.size);
if (!mc->gss_name) goto done;
mc->basic_hash.length = gsessdata->basichash.size;
- mc->basic_hash.value = apr_palloc(mc->parent, mc->basic_hash.length);
+ mc->basic_hash.value = apr_palloc(mc->pool, mc->basic_hash.length);
memcpy(mc->basic_hash.value,
gsessdata->basichash.buf, gsessdata->basichash.size);
@@ -335,6 +331,6 @@ void mag_basic_cache(struct mag_config *cfg, struct mag_conn *mc,
if (ret != 0) return;
mc->basic_hash.length = mac_size;
- mc->basic_hash.value = apr_palloc(mc->parent, mac_size);
+ mc->basic_hash.value = apr_palloc(mc->pool, mac_size);
memcpy(mc->basic_hash.value, mac, mac_size);
}