From 50573f91dbac0c5b2756703814847798563c3249 Mon Sep 17 00:00:00 2001 From: Luke Howard Date: Sat, 18 Sep 2010 14:14:05 +0200 Subject: [PATCH] cleanup --- mech_eap/delete_name_attribute.c | 1 - mech_eap/get_name_attribute.c | 1 - mech_eap/release_any_name_mapping.c | 2 + mech_eap/set_name_attribute.c | 1 - mech_eap/util_attr.cpp | 95 +++++++++++++++++++------------------ mech_eap/util_attr.h | 4 +- 6 files changed, 54 insertions(+), 50 deletions(-) diff --git a/mech_eap/delete_name_attribute.c b/mech_eap/delete_name_attribute.c index a57272c..97d8d16 100644 --- a/mech_eap/delete_name_attribute.c +++ b/mech_eap/delete_name_attribute.c @@ -38,7 +38,6 @@ gss_delete_name_attribute(OM_uint32 *minor, gss_buffer_t attr) { OM_uint32 major; - gss_buffer_desc prefix, suffix; if (name == GSS_C_NO_NAME) { *minor = EINVAL; diff --git a/mech_eap/get_name_attribute.c b/mech_eap/get_name_attribute.c index c5e5d24..7fe328f 100644 --- a/mech_eap/get_name_attribute.c +++ b/mech_eap/get_name_attribute.c @@ -43,7 +43,6 @@ gss_get_name_attribute(OM_uint32 *minor, int *more) { OM_uint32 major; - gss_buffer_desc prefix, suffix; if (name == GSS_C_NO_NAME) { *minor = EINVAL; diff --git a/mech_eap/release_any_name_mapping.c b/mech_eap/release_any_name_mapping.c index 791c85b..c2d8ede 100644 --- a/mech_eap/release_any_name_mapping.c +++ b/mech_eap/release_any_name_mapping.c @@ -49,6 +49,8 @@ gss_release_any_name_mapping(OM_uint32 *minor, major = gssEapReleaseAnyNameMapping(minor, name, type_id, input); + *input = NULL; + GSSEAP_MUTEX_UNLOCK(&name->mutex); return major; diff --git a/mech_eap/set_name_attribute.c b/mech_eap/set_name_attribute.c index fa95836..93d1c25 100644 --- a/mech_eap/set_name_attribute.c +++ b/mech_eap/set_name_attribute.c @@ -40,7 +40,6 @@ gss_set_name_attribute(OM_uint32 *minor, gss_buffer_t value) { OM_uint32 major; - gss_buffer_desc prefix, suffix; if (name == GSS_C_NO_NAME) { *minor = EINVAL; diff --git a/mech_eap/util_attr.cpp b/mech_eap/util_attr.cpp index 6931dc0..0e62d34 100644 --- a/mech_eap/util_attr.cpp +++ b/mech_eap/util_attr.cpp @@ -47,11 +47,11 @@ gss_eap_attr_factories[ATTR_TYPE_MAX] = { gss_eap_attr_ctx::gss_eap_attr_ctx(void) { for (unsigned int i = 0; i < ATTR_TYPE_MAX; i++) { - gss_eap_attr_source *provider; + gss_eap_attr_source *source; - provider = (gss_eap_attr_factories[i])(); - if (provider != NULL) - m_providers[i] = provider; + source = (gss_eap_attr_factories[i])(); + + m_sources[i] = source; } } @@ -63,11 +63,11 @@ gss_eap_attr_ctx::initFromExistingContext(const gss_eap_attr_ctx *manager, return false; for (unsigned int i = 0; i < ATTR_TYPE_MAX; i++) { - gss_eap_attr_source *provider; + gss_eap_attr_source *source; - provider = m_providers[i]; - if (provider != NULL) { - if (!provider->initFromExistingContext(this, source)) + source = m_sources[i]; + if (source != NULL) { + if (!source->initFromExistingContext(this, source)) return false; } } @@ -84,11 +84,11 @@ gss_eap_attr_ctx::initFromGssContext(const gss_eap_attr_ctx *manager, return false; for (unsigned int i = 0; i < ATTR_TYPE_MAX; i++) { - gss_eap_attr_source *provider; + gss_eap_attr_source *source; - provider = m_providers[i]; - if (provider != NULL) { - if (!provider->initFromGssContext(this, cred, ctx)) + source = m_sources[i]; + if (source != NULL) { + if (!source->initFromGssContext(this, cred, ctx)) return false; } } @@ -99,7 +99,7 @@ gss_eap_attr_ctx::initFromGssContext(const gss_eap_attr_ctx *manager, gss_eap_attr_ctx::~gss_eap_attr_ctx(void) { for (unsigned int i = 0; i < ATTR_TYPE_MAX; i++) - delete m_providers[i]; + delete m_sources[i]; } bool @@ -123,7 +123,7 @@ gss_eap_attr_ctx::finalize(void) gss_eap_attr_source * gss_eap_attr_ctx::getProvider(unsigned int type) const { - return m_providers[type]; + return m_sources[type]; } gss_eap_attr_source * @@ -133,7 +133,7 @@ gss_eap_attr_ctx::getProvider(const gss_buffer_t prefix) const type = attributePrefixToType(prefix); - return m_providers[type]; + return m_sources[type]; } void @@ -143,13 +143,13 @@ gss_eap_attr_ctx::setAttribute(int complete, { gss_buffer_desc suffix = GSS_C_EMPTY_BUFFER; unsigned int type; - gss_eap_attr_source *provider; + gss_eap_attr_source *source; decomposeAttributeName(attr, &type, &suffix); - provider = m_providers[type]; - if (provider != NULL) { - provider->setAttribute(complete, + source = m_sources[type]; + if (source != NULL) { + source->setAttribute(complete, (type == ATTR_TYPE_LOCAL) ? attr : &suffix, value); @@ -161,13 +161,13 @@ gss_eap_attr_ctx::deleteAttribute(const gss_buffer_t attr) { gss_buffer_desc suffix = GSS_C_EMPTY_BUFFER; unsigned int type; - gss_eap_attr_source *provider; + gss_eap_attr_source *source; decomposeAttributeName(attr, &type, &suffix); - provider = m_providers[type]; - if (provider != NULL) { - provider->deleteAttribute(type == ATTR_TYPE_LOCAL ? attr : &suffix); + source = m_sources[type]; + if (source != NULL) { + source->deleteAttribute(type == ATTR_TYPE_LOCAL ? attr : &suffix); } } @@ -178,13 +178,13 @@ gss_eap_attr_ctx::getAttributeTypes(gss_eap_attr_enumeration_cb cb, void *data) size_t i; for (i = 0; i < ATTR_TYPE_MAX; i++) { - gss_eap_attr_source *provider; + gss_eap_attr_source *source; - provider = m_providers[i]; - if (provider == NULL) + source = m_sources[i]; + if (source == NULL) continue; - ret = provider->getAttributeTypes(cb, data); + ret = source->getAttributeTypes(cb, data); if (ret == false) break; } @@ -198,7 +198,7 @@ struct eap_gss_get_attr_types_args { }; static bool -addAttribute(const gss_eap_attr_source *provider, +addAttribute(const gss_eap_attr_source *source, const gss_buffer_t attribute, void *data) { @@ -235,15 +235,15 @@ gss_eap_attr_ctx::getAttributeTypes(gss_buffer_set_t *attrs) args.attrs = *attrs; for (i = 0; i < ATTR_TYPE_MAX; i++) { - gss_eap_attr_source *provider; + gss_eap_attr_source *source; args.type = i; - provider = m_providers[i]; - if (provider == NULL) + source = m_sources[i]; + if (source == NULL) continue; - ret = provider->getAttributeTypes(addAttribute, (void *)&args); + ret = source->getAttributeTypes(addAttribute, (void *)&args); if (ret == false) break; } @@ -265,20 +265,20 @@ gss_eap_attr_ctx::getAttribute(const gss_buffer_t attr, { gss_buffer_desc suffix = GSS_C_EMPTY_BUFFER; unsigned int type; - gss_eap_attr_source *provider; + gss_eap_attr_source *source; bool ret; decomposeAttributeName(attr, &type, &suffix); - provider = m_providers[type]; - if (provider == NULL) { + source = m_sources[type]; + if (source == NULL) { *more = 0; return false; } - ret = provider->getAttribute(type == ATTR_TYPE_LOCAL ? attr : &suffix, - authenticated, complete, - value, display_value, more); + ret = source->getAttribute(type == ATTR_TYPE_LOCAL ? attr : &suffix, + authenticated, complete, + value, display_value, more); return ret; } @@ -299,7 +299,7 @@ gss_eap_attr_ctx::releaseAnyNameMapping(gss_buffer_t type_id, void gss_eap_attr_ctx::exportToBuffer(gss_buffer_t buffer) const { - m_providers[ATTR_TYPE_RADIUS]->exportToBuffer(buffer); + m_sources[ATTR_TYPE_RADIUS]->exportToBuffer(buffer); } bool @@ -309,15 +309,16 @@ gss_eap_attr_ctx::initFromBuffer(const gss_eap_attr_ctx *manager, unsigned int i; bool ret; - ret = m_providers[ATTR_TYPE_RADIUS]->initFromBuffer(this, buffer); + ret = m_sources[ATTR_TYPE_RADIUS]->initFromBuffer(this, buffer); if (!ret) return false; for (i = ATTR_TYPE_RADIUS + 1; i < ATTR_TYPE_MAX; i++) { - gss_eap_attr_source *provider = m_providers[i]; + gss_eap_attr_source *source = m_sources[i]; - ret = provider->initFromGssContext( - this, GSS_C_NO_CREDENTIAL, GSS_C_NO_CONTEXT); + ret = source->initFromGssContext(this, + GSS_C_NO_CREDENTIAL, + GSS_C_NO_CONTEXT); if (!ret) break; } @@ -590,10 +591,14 @@ gssEapImportAttrContext(OM_uint32 *minor, gss_buffer_t buffer, gss_name_t name) { - if (buffer->length != 0) { - gss_eap_attr_ctx *ctx = new gss_eap_attr_ctx; + gss_eap_attr_ctx *ctx = NULL; + assert(name->attrCtx == NULL); + + if (buffer->length != 0) { try { + ctx = new gss_eap_attr_ctx; + if (!ctx->initFromBuffer(NULL, buffer)) { delete ctx; return GSS_S_DEFECTIVE_TOKEN; diff --git a/mech_eap/util_attr.h b/mech_eap/util_attr.h index 247bad5..b6dbed5 100644 --- a/mech_eap/util_attr.h +++ b/mech_eap/util_attr.h @@ -71,7 +71,7 @@ public: } typedef bool - gss_eap_attr_enumeration_cb(const gss_eap_attr_source *provider, + gss_eap_attr_enumeration_cb(const gss_eap_attr_source *source, const gss_buffer_t attribute, void *data); @@ -184,7 +184,7 @@ public: gss_eap_attr_source *getProvider(const gss_buffer_t prefix) const; private: - gss_eap_attr_source *m_providers[ATTR_TYPE_MAX]; + gss_eap_attr_source *m_sources[ATTR_TYPE_MAX]; }; #include "util_radius.h" -- 2.1.4