Cleanup cert config files for tests
[openssl.git] / test / confdump.c
index b83119ef3432ffe07b3ef53e137386f5517c10c8..3750d2cc8c80add0f9895ee558cb6f20eb5c9175 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 1999-2019 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 1999-2020 The OpenSSL Project Authors. All Rights Reserved.
  *
  * Licensed under the Apache License 2.0 (the "License").  You may not use
  * this file except in compliance with the License.  You can obtain a copy
@@ -14,6 +14,9 @@
 #include <openssl/safestack.h>
 #include <openssl/err.h>
 
+DEFINE_STACK_OF(CONF_VALUE)
+DEFINE_STACK_OF_CSTRING()
+
 static STACK_OF(OPENSSL_CSTRING) *section_names = NULL;
 
 static void collect_section_name(CONF_VALUE *v)
@@ -51,10 +54,10 @@ static void dump_section(const char *name, const CONF *cnf)
 int main(int argc, char **argv)
 {
     long eline;
-    CONF *conf;
+    CONF *conf = NCONF_new(NCONF_default());
+    int ret = 1;
 
-    if ((conf = NCONF_new(NCONF_default())) != NULL
-        && NCONF_load(conf, argv[1], &eline)) {
+    if (conf != NULL && NCONF_load(conf, argv[1], &eline)) {
         int i;
 
         collect_all_sections(conf);
@@ -62,9 +65,10 @@ int main(int argc, char **argv)
             dump_section(sk_OPENSSL_CSTRING_value(section_names, i), conf);
         }
         sk_OPENSSL_CSTRING_free(section_names);
+        ret = 0;
     } else {
         ERR_print_errors_fp(stderr);
-        return 1;
     }
-    return 0;
+    NCONF_free(conf);
+    return ret;
 }