fixed the cleanup code when the credential factory fails to create a builder
authorTobias Brunner <tobias@strongswan.org>
Mon, 19 May 2008 12:43:01 +0000 (12:43 -0000)
committerTobias Brunner <tobias@strongswan.org>
Mon, 19 May 2008 12:43:01 +0000 (12:43 -0000)
src/libstrongswan/credentials/credential_factory.c
src/libstrongswan/credentials/credential_factory.h

index 5a421ee..de4c2fb 100644 (file)
 #include <utils/mutex.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;
 
 /**
@@ -183,6 +189,11 @@ static void* create(private_credential_factory_t *this, credential_type_t type,
        
                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 */
        va_start(args, subtype);
@@ -200,6 +211,27 @@ static void* create(private_credential_factory_t *this, credential_type_t type,
                                free(chunk.ptr);
                                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:
                        {
                                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);
                                continue;
                        }
-                       case BUILD_KEY_SIZE:
-                       case BUILD_X509_FLAG:
+                       case BUILD_FROM_FILE:
+                       case BUILD_IETF_GROUP_ATTR:
+                       {
+                               va_arg(args, void*);
                                continue;
+                       }
                        default:
                                DBG1("builder part %N not supported by factory",
                                         builder_part_names, part);
index 394d0b0..873cf8a 100644 (file)
@@ -42,6 +42,11 @@ enum credential_type_t {
 };
 
 /**
+ * enum names for credential_type_t
+ */
+extern enum_name_t *credential_type_names;
+
+/**
  * Manages credential construction functions and creates instances.
  */
 struct credential_factory_t {