Use secure_getenv(3) when available.
[openssl.git] / crypto / ct / ct_log.c
index ec6fa384d52590787bd884ecc9def8de4e12804f..c1bca3e1415e507b057085b9c39900f66e4b7d76 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2016-2018 The OpenSSL Project Authors. All Rights Reserved.
  *
  * Licensed under the OpenSSL license (the "License").  You may not use
  * this file except in compliance with the License.  You can obtain a copy
@@ -46,7 +46,7 @@ typedef struct ctlog_store_load_ctx_st {
  * Creates an empty context for loading a CT log store.
  * It should be populated before use.
  */
-static CTLOG_STORE_LOAD_CTX *ctlog_store_load_ctx_new();
+static CTLOG_STORE_LOAD_CTX *ctlog_store_load_ctx_new(void);
 
 /*
  * Deletes a CT log store load context.
@@ -54,7 +54,7 @@ static CTLOG_STORE_LOAD_CTX *ctlog_store_load_ctx_new();
  */
 static void ctlog_store_load_ctx_free(CTLOG_STORE_LOAD_CTX* ctx);
 
-static CTLOG_STORE_LOAD_CTX *ctlog_store_load_ctx_new()
+static CTLOG_STORE_LOAD_CTX *ctlog_store_load_ctx_new(void)
 {
     CTLOG_STORE_LOAD_CTX *ctx = OPENSSL_zalloc(sizeof(*ctx));
 
@@ -137,7 +137,7 @@ static int ctlog_new_from_conf(CTLOG **ct_log, const CONF *conf, const char *sec
 
 int CTLOG_STORE_load_default_file(CTLOG_STORE *store)
 {
-    const char *fpath = getenv(CTLOG_FILE_EVP);
+    const char *fpath = ossl_safe_getenv(CTLOG_FILE_EVP);
 
     if (fpath == NULL)
       fpath = CTLOG_FILE;
@@ -199,7 +199,7 @@ int CTLOG_STORE_load_file(CTLOG_STORE *store, const char *file)
     CTLOG_STORE_LOAD_CTX* load_ctx = ctlog_store_load_ctx_new();
 
     if (load_ctx == NULL)
-        goto end;
+        return 0;
     load_ctx->log_store = store;
     load_ctx->conf = NCONF_new(NULL);
     if (load_ctx->conf == NULL)