fixed the cleanup code when the credential factory fails to create a builder
This commit is contained in:
@@ -22,6 +22,12 @@
|
|||||||
#include <utils/mutex.h>
|
#include <utils/mutex.h>
|
||||||
#include <credentials/certificates/x509.h>
|
#include <credentials/certificates/x509.h>
|
||||||
|
|
||||||
|
ENUM(credential_type_names, CRED_PRIVATE_KEY, CRED_CERTIFICATE,
|
||||||
|
"CRED_PRIVATE_KEY",
|
||||||
|
"CRED_PUBLIC_KEY",
|
||||||
|
"CRED_CERTIFICATE",
|
||||||
|
);
|
||||||
|
|
||||||
typedef struct private_credential_factory_t private_credential_factory_t;
|
typedef struct private_credential_factory_t private_credential_factory_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -183,6 +189,11 @@ static void* create(private_credential_factory_t *this, credential_type_t type,
|
|||||||
|
|
||||||
return builder->build(builder);
|
return builder->build(builder);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DBG1("failed to create a builder for credential type %N,"
|
||||||
|
" subtype (%d)", credential_type_names, type, subtype);
|
||||||
|
}
|
||||||
|
|
||||||
/** shredder all data on failure */
|
/** shredder all data on failure */
|
||||||
va_start(args, subtype);
|
va_start(args, subtype);
|
||||||
@@ -200,6 +211,27 @@ static void* create(private_credential_factory_t *this, credential_type_t type,
|
|||||||
free(chunk.ptr);
|
free(chunk.ptr);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
case BUILD_SERIAL:
|
||||||
|
{
|
||||||
|
va_arg(args, chunk_t);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
case BUILD_X509_FLAG:
|
||||||
|
{
|
||||||
|
va_arg(args, x509_flag_t);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
case BUILD_KEY_SIZE:
|
||||||
|
{
|
||||||
|
va_arg(args, u_int);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
case BUILD_NOT_BEFORE_TIME:
|
||||||
|
case BUILD_NOT_AFTER_TIME:
|
||||||
|
{
|
||||||
|
va_arg(args, time_t);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
case BUILD_SIGNING_KEY:
|
case BUILD_SIGNING_KEY:
|
||||||
{
|
{
|
||||||
private_key_t *private = va_arg(args, private_key_t*);
|
private_key_t *private = va_arg(args, private_key_t*);
|
||||||
@@ -229,9 +261,12 @@ static void* create(private_credential_factory_t *this, credential_type_t type,
|
|||||||
cert->destroy(cert);
|
cert->destroy(cert);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
case BUILD_KEY_SIZE:
|
case BUILD_FROM_FILE:
|
||||||
case BUILD_X509_FLAG:
|
case BUILD_IETF_GROUP_ATTR:
|
||||||
|
{
|
||||||
|
va_arg(args, void*);
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
DBG1("builder part %N not supported by factory",
|
DBG1("builder part %N not supported by factory",
|
||||||
builder_part_names, part);
|
builder_part_names, part);
|
||||||
|
|||||||
@@ -41,6 +41,11 @@ enum credential_type_t {
|
|||||||
CRED_CERTIFICATE,
|
CRED_CERTIFICATE,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* enum names for credential_type_t
|
||||||
|
*/
|
||||||
|
extern enum_name_t *credential_type_names;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manages credential construction functions and creates instances.
|
* Manages credential construction functions and creates instances.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user