diff options
author | Martin Willi <martin@revosec.ch> | 2011-04-21 13:21:26 +0200 |
---|---|---|
committer | Martin Willi <martin@revosec.ch> | 2011-04-21 13:35:31 +0200 |
commit | 5b0bcfb1fc4aabb6535db91e70f7f262328e664f (patch) | |
tree | 000c5588b5da0e498f74e251cd0e1aeaa6d597a9 /src/libstrongswan | |
parent | fdead26ffe1da8501a6ff5e0639a6f44c723e763 (diff) | |
download | strongswan-5b0bcfb1fc4aabb6535db91e70f7f262328e664f.tar.bz2 strongswan-5b0bcfb1fc4aabb6535db91e70f7f262328e664f.tar.xz |
Revert alloc_str changes
This reverts commit fdead26ffe1da8501a6ff5e0639a6f44c723e763.
This reverts commit 3e2419ebe32de72d824864eb2e0e677a7c197af1.
This reverts commit 17ce69b47a1efd6234960cf7d1f50712aee61db5.
Diffstat (limited to 'src/libstrongswan')
-rw-r--r-- | src/libstrongswan/plugins/openssl/openssl_rsa_private_key.c | 21 | ||||
-rw-r--r-- | src/libstrongswan/plugins/pkcs11/pkcs11_manager.c | 9 | ||||
-rw-r--r-- | src/libstrongswan/settings.c | 16 | ||||
-rw-r--r-- | src/libstrongswan/settings.h | 20 |
4 files changed, 13 insertions, 53 deletions
diff --git a/src/libstrongswan/plugins/openssl/openssl_rsa_private_key.c b/src/libstrongswan/plugins/openssl/openssl_rsa_private_key.c index 39c28d3cd..0b607c386 100644 --- a/src/libstrongswan/plugins/openssl/openssl_rsa_private_key.c +++ b/src/libstrongswan/plugins/openssl/openssl_rsa_private_key.c @@ -550,34 +550,36 @@ openssl_rsa_private_key_t *openssl_rsa_private_key_connect(key_type_t type, if (!engine_id) { - engine_id = lib->settings->alloc_str(lib->settings, + engine_id = lib->settings->get_str(lib->settings, "libstrongswan.plugins.openssl.engine_id", "pkcs11"); } engine = ENGINE_by_id(engine_id); if (!engine) { DBG2(DBG_LIB, "engine '%s' is not available", engine_id); - goto engine_failed; + return NULL; } if (!ENGINE_init(engine)) { DBG1(DBG_LIB, "failed to initialize engine '%s'", engine_id); - goto engine_failed; + ENGINE_free(engine); + return NULL; } if (!login(engine, keyid)) { DBG1(DBG_LIB, "login to engine '%s' failed", engine_id); - goto engine_failed; + ENGINE_free(engine); + return NULL; } key = ENGINE_load_private_key(engine, keyname, NULL, NULL); if (!key) { DBG1(DBG_LIB, "failed to load private key with ID '%s' from " "engine '%s'", keyname, engine_id); - goto engine_failed; + ENGINE_free(engine); + return NULL; } ENGINE_free(engine); - free(engine_id); this = create_empty(); this->rsa = EVP_PKEY_get1_RSA(key); @@ -592,12 +594,5 @@ openssl_rsa_private_key_t *openssl_rsa_private_key_connect(key_type_t type, #else /* OPENSSL_NO_ENGINE */ return NULL; #endif /* OPENSSL_NO_ENGINE */ -engine_failed: - if (engine) - { - ENGINE_free(engine); - } - free(engine_id); - return NULL; } diff --git a/src/libstrongswan/plugins/pkcs11/pkcs11_manager.c b/src/libstrongswan/plugins/pkcs11/pkcs11_manager.c index 7579e0e2e..431cd6a2c 100644 --- a/src/libstrongswan/plugins/pkcs11/pkcs11_manager.c +++ b/src/libstrongswan/plugins/pkcs11/pkcs11_manager.c @@ -74,8 +74,7 @@ static void lib_entry_destroy(lib_entry_t *entry) { entry->job->cancel(entry->job); } - DESTROY_IF(entry->lib); - free(entry->path); + entry->lib->destroy(entry->lib); free(entry); } @@ -366,12 +365,12 @@ pkcs11_manager_t *pkcs11_manager_create(pkcs11_manager_token_event_t cb, .this = this, ); - entry->path = lib->settings->alloc_str(lib->settings, + entry->path = lib->settings->get_str(lib->settings, "libstrongswan.plugins.pkcs11.modules.%s.path", NULL, module); if (!entry->path) { DBG1(DBG_CFG, "PKCS11 module '%s' lacks library path", module); - lib_entry_destroy(entry); + free(entry); continue; } entry->lib = pkcs11_library_create(module, entry->path, @@ -380,7 +379,7 @@ pkcs11_manager_t *pkcs11_manager_create(pkcs11_manager_token_event_t cb, FALSE, module)); if (!entry->lib) { - lib_entry_destroy(entry); + free(entry); continue; } this->libs->insert_last(this->libs, entry); diff --git a/src/libstrongswan/settings.c b/src/libstrongswan/settings.c index 941eb0514..8a2248b46 100644 --- a/src/libstrongswan/settings.c +++ b/src/libstrongswan/settings.c @@ -444,21 +444,6 @@ METHOD(settings_t, get_str, char*, return def; } -METHOD(settings_t, alloc_str, char*, - private_settings_t *this, char *key, char *def, ...) -{ - char *value; - va_list args; - - va_start(args, def); - /* additional lock to savely strdup */ - this->lock->read_lock(this->lock); - value = strdupnull(find_value(this, this->top, key, args) ?: def); - this->lock->unlock(this->lock); - va_end(args); - return value; -} - /** * Described in header */ @@ -1207,7 +1192,6 @@ settings_t *settings_create(char *file) INIT(this, .public = { .get_str = _get_str, - .alloc_str = _alloc_str, .get_int = _get_int, .get_double = _get_double, .get_time = _get_time, diff --git a/src/libstrongswan/settings.h b/src/libstrongswan/settings.h index bc106e3a7..9ccd02327 100644 --- a/src/libstrongswan/settings.h +++ b/src/libstrongswan/settings.h @@ -146,32 +146,14 @@ struct settings_t { /** * Get a settings value as a string. * - * This functions returns a string held by settings_t. It is not thread - * save, a thread calling load_files might free the returned string at - * any time. Use the thread save alloc_str if a different thread might - * call load_files() or set_str(). - * * @param key key including sections, printf style format * @param def value returned if key not found * @param ... argument list for key - * @return value pointing to internal string, not to be freed + * @return value pointing to internal string */ char* (*get_str)(settings_t *this, char *key, char *def, ...); /** - * Get a settings value as a string, thread save variant. - * - * This function is identical to get_str, but is thread save. It allocates - * a copy for the returned string which must be freed. - * - * @param key key including sections, printf style format - * @param def value returned if key not found - * @param ... argument list for key - * @return allocated string, to be free - */ - char* (*alloc_str)(settings_t *this, char *key, char *def, ...); - - /** * Get a boolean yes|no, true|false value. * * @param key key including sections, printf style format |