Update copyright year
[openssl.git] / crypto / conf / conf_ssl.c
index 015c46c6da52e5b427b14dd94738698ecb7f65c1..84c5b2afe5818fd96b875659f37194fee528130e 100644 (file)
@@ -1,7 +1,7 @@
 /*
- * Copyright 2015-2018 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2015-2021 The OpenSSL Project Authors. All Rights Reserved.
  *
- * Licensed under the OpenSSL license (the "License").  You may not use
+ * 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
  * in the file LICENSE in the source distribution or at
  * https://www.openssl.org/source/license.html
@@ -12,7 +12,7 @@
 #include <openssl/conf.h>
 #include <openssl/err.h>
 #include "internal/sslconf.h"
-#include "conf_lcl.h"
+#include "conf_local.h"
 
 /*
  * SSL library configuration module placeholder. We load it here but defer
@@ -68,15 +68,19 @@ static int ssl_module_init(CONF_IMODULE *md, const CONF *cnf)
     ssl_conf_section = CONF_imodule_get_value(md);
     cmd_lists = NCONF_get_section(cnf, ssl_conf_section);
     if (sk_CONF_VALUE_num(cmd_lists) <= 0) {
-        if (cmd_lists == NULL)
-            CONFerr(CONF_F_SSL_MODULE_INIT, CONF_R_SSL_SECTION_NOT_FOUND);
-        else
-            CONFerr(CONF_F_SSL_MODULE_INIT, CONF_R_SSL_SECTION_EMPTY);
-        ERR_add_error_data(2, "section=", ssl_conf_section);
+        int rcode =
+            cmd_lists == NULL
+            ? CONF_R_SSL_SECTION_NOT_FOUND
+            : CONF_R_SSL_SECTION_EMPTY;
+
+        ERR_raise_data(ERR_LIB_CONF, rcode, "section=%s", ssl_conf_section);
         goto err;
     }
     cnt = sk_CONF_VALUE_num(cmd_lists);
+    ssl_module_free(md);
     ssl_names = OPENSSL_zalloc(sizeof(*ssl_names) * cnt);
+    if (ssl_names == NULL)
+        goto err;
     ssl_names_count = cnt;
     for (i = 0; i < ssl_names_count; i++) {
         struct ssl_conf_name_st *ssl_name = ssl_names + i;
@@ -84,13 +88,13 @@ static int ssl_module_init(CONF_IMODULE *md, const CONF *cnf)
         STACK_OF(CONF_VALUE) *cmds = NCONF_get_section(cnf, sect->value);
 
         if (sk_CONF_VALUE_num(cmds) <= 0) {
-            if (cmds == NULL)
-                CONFerr(CONF_F_SSL_MODULE_INIT,
-                        CONF_R_SSL_COMMAND_SECTION_NOT_FOUND);
-            else
-                CONFerr(CONF_F_SSL_MODULE_INIT,
-                        CONF_R_SSL_COMMAND_SECTION_EMPTY);
-            ERR_add_error_data(4, "name=", sect->name, ", value=", sect->value);
+            int rcode =
+                cmds == NULL
+                ? CONF_R_SSL_COMMAND_SECTION_NOT_FOUND
+                : CONF_R_SSL_COMMAND_SECTION_EMPTY;
+
+            ERR_raise_data(ERR_LIB_CONF, rcode,
+                           "name=%s, value=%s", sect->name, sect->value);
             goto err;
         }
         ssl_name->name = OPENSSL_strdup(sect->name);
@@ -172,7 +176,7 @@ void conf_ssl_get_cmd(const SSL_CONF_CMD *cmd, size_t idx, char **cmdstr,
     *arg = cmd[idx].arg;
 }
 
-void conf_add_ssl_module(void)
+void ossl_config_add_ssl_module(void)
 {
     CONF_module_add("ssl_conf", ssl_module_init, ssl_module_free);
 }