e85d727
diff -up openssl-1.1.0g/crypto/conf/conf_api.c.secure-getenv openssl-1.1.0g/crypto/conf/conf_api.c
e85d727
--- openssl-1.1.0g/crypto/conf/conf_api.c.secure-getenv	2017-11-02 15:29:02.000000000 +0100
e85d727
+++ openssl-1.1.0g/crypto/conf/conf_api.c	2017-11-03 16:12:31.826265323 +0100
510bcc2
@@ -9,6 +9,8 @@
510bcc2
 
510bcc2
 /* Part of the code in here was originally in conf.c, which is now removed */
510bcc2
 
510bcc2
+/* for secure_getenv */
510bcc2
+#define _GNU_SOURCE
510bcc2
 #include <stdlib.h>
510bcc2
 #include <string.h>
510bcc2
 #include <openssl/conf.h>
510bcc2
@@ -82,7 +84,7 @@ char *_CONF_get_string(const CONF *conf,
510bcc2
             if (v != NULL)
510bcc2
                 return (v->value);
510bcc2
             if (strcmp(section, "ENV") == 0) {
510bcc2
-                p = getenv(name);
510bcc2
+                p = secure_getenv(name);
510bcc2
                 if (p != NULL)
510bcc2
                     return (p);
510bcc2
             }
510bcc2
@@ -95,7 +97,7 @@ char *_CONF_get_string(const CONF *conf,
510bcc2
         else
510bcc2
             return (NULL);
510bcc2
     } else
510bcc2
-        return (getenv(name));
510bcc2
+        return (secure_getenv(name));
510bcc2
 }
510bcc2
 
510bcc2
 static unsigned long conf_value_hash(const CONF_VALUE *v)
e85d727
diff -up openssl-1.1.0g/crypto/conf/conf_mod.c.secure-getenv openssl-1.1.0g/crypto/conf/conf_mod.c
e85d727
--- openssl-1.1.0g/crypto/conf/conf_mod.c.secure-getenv	2017-11-02 15:29:02.000000000 +0100
e85d727
+++ openssl-1.1.0g/crypto/conf/conf_mod.c	2017-11-03 16:12:31.827265347 +0100
510bcc2
@@ -7,6 +7,8 @@
510bcc2
  * https://www.openssl.org/source/license.html
510bcc2
  */
510bcc2
 
510bcc2
+/* for secure_getenv */
510bcc2
+#define _GNU_SOURCE
510bcc2
 #include <stdio.h>
510bcc2
 #include <ctype.h>
510bcc2
 #include <openssl/crypto.h>
510bcc2
@@ -478,7 +480,7 @@ char *CONF_get1_default_config_file(void
510bcc2
     char *file;
510bcc2
     int len;
510bcc2
 
510bcc2
-    file = getenv("OPENSSL_CONF");
510bcc2
+    file = secure_getenv("OPENSSL_CONF");
510bcc2
     if (file)
510bcc2
         return OPENSSL_strdup(file);
510bcc2
 
e85d727
diff -up openssl-1.1.0g/crypto/engine/eng_list.c.secure-getenv openssl-1.1.0g/crypto/engine/eng_list.c
e85d727
--- openssl-1.1.0g/crypto/engine/eng_list.c.secure-getenv	2017-11-02 15:29:03.000000000 +0100
e85d727
+++ openssl-1.1.0g/crypto/engine/eng_list.c	2017-11-03 16:12:31.827265347 +0100
510bcc2
@@ -13,6 +13,8 @@
510bcc2
  * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project.
510bcc2
  */
510bcc2
 
510bcc2
+/* for secure_getenv */
510bcc2
+#define _GNU_SOURCE
510bcc2
 #include "eng_int.h"
510bcc2
 
510bcc2
 /*
510bcc2
@@ -322,7 +324,7 @@ ENGINE *ENGINE_by_id(const char *id)
510bcc2
      * Prevent infinite recursion if we're looking for the dynamic engine.
510bcc2
      */
510bcc2
     if (strcmp(id, "dynamic")) {
510bcc2
-        if ((load_dir = getenv("OPENSSL_ENGINES")) == 0)
510bcc2
+        if ((load_dir = secure_getenv("OPENSSL_ENGINES")) == 0)
510bcc2
             load_dir = ENGINESDIR;
510bcc2
         iterator = ENGINE_by_id("dynamic");
510bcc2
         if (!iterator || !ENGINE_ctrl_cmd_string(iterator, "ID", id, 0) ||
e85d727
diff -up openssl-1.1.0g/crypto/rand/randfile.c.secure-getenv openssl-1.1.0g/crypto/rand/randfile.c
e85d727
--- openssl-1.1.0g/crypto/rand/randfile.c.secure-getenv	2017-11-02 15:29:03.000000000 +0100
e85d727
+++ openssl-1.1.0g/crypto/rand/randfile.c	2017-11-03 16:12:31.827265347 +0100
510bcc2
@@ -7,6 +7,8 @@
510bcc2
  * https://www.openssl.org/source/license.html
510bcc2
  */
510bcc2
 
510bcc2
+/* for secure_getenv */
510bcc2
+#define _GNU_SOURCE
510bcc2
 #include "internal/cryptlib.h"
510bcc2
 
510bcc2
 #include <errno.h>
e85d727
@@ -317,10 +319,10 @@ const char *RAND_file_name(char *buf, si
510bcc2
     if (OPENSSL_issetugid() != 0) {
510bcc2
         use_randfile = 0;
510bcc2
     } else {
510bcc2
-        s = getenv("RANDFILE");
510bcc2
+        s = secure_getenv("RANDFILE");
510bcc2
         if (s == NULL || *s == '\0') {
510bcc2
             use_randfile = 0;
510bcc2
-            s = getenv("HOME");
510bcc2
+            s = secure_getenv("HOME");
510bcc2
         }
510bcc2
     }
510bcc2
 #endif
e85d727
diff -up openssl-1.1.0g/crypto/x509/by_dir.c.secure-getenv openssl-1.1.0g/crypto/x509/by_dir.c
e85d727
--- openssl-1.1.0g/crypto/x509/by_dir.c.secure-getenv	2017-11-02 15:29:04.000000000 +0100
e85d727
+++ openssl-1.1.0g/crypto/x509/by_dir.c	2017-11-03 16:12:31.827265347 +0100
510bcc2
@@ -7,6 +7,8 @@
510bcc2
  * https://www.openssl.org/source/license.html
510bcc2
  */
510bcc2
 
510bcc2
+/* for secure_getenv */
510bcc2
+#define _GNU_SOURCE
510bcc2
 #include <stdio.h>
510bcc2
 #include <time.h>
510bcc2
 #include <errno.h>
e85d727
@@ -78,7 +80,7 @@ static int dir_ctrl(X509_LOOKUP *ctx, in
510bcc2
     switch (cmd) {
510bcc2
     case X509_L_ADD_DIR:
510bcc2
         if (argl == X509_FILETYPE_DEFAULT) {
510bcc2
-            dir = (char *)getenv(X509_get_default_cert_dir_env());
510bcc2
+            dir = (char *)secure_getenv(X509_get_default_cert_dir_env());
510bcc2
             if (dir)
510bcc2
                 ret = add_cert_dir(ld, dir, X509_FILETYPE_PEM);
510bcc2
             else
e85d727
diff -up openssl-1.1.0g/crypto/x509/by_file.c.secure-getenv openssl-1.1.0g/crypto/x509/by_file.c
e85d727
--- openssl-1.1.0g/crypto/x509/by_file.c.secure-getenv	2017-11-02 15:29:04.000000000 +0100
e85d727
+++ openssl-1.1.0g/crypto/x509/by_file.c	2017-11-03 16:14:13.230649686 +0100
510bcc2
@@ -7,6 +7,8 @@
510bcc2
  * https://www.openssl.org/source/license.html
510bcc2
  */
510bcc2
 
510bcc2
+/* for secure_getenv */
510bcc2
+#define _GNU_SOURCE
510bcc2
 #include <stdio.h>
510bcc2
 #include <time.h>
510bcc2
 #include <errno.h>
510bcc2
@@ -47,7 +49,7 @@ static int by_file_ctrl(X509_LOOKUP *ctx
510bcc2
     switch (cmd) {
510bcc2
     case X509_L_FILE_LOAD:
510bcc2
         if (argl == X509_FILETYPE_DEFAULT) {
e85d727
-            file = getenv(X509_get_default_cert_file_env());
e85d727
+            file = secure_getenv(X509_get_default_cert_file_env());
510bcc2
             if (file)
510bcc2
                 ok = (X509_load_cert_crl_file(ctx, file,
510bcc2
                                               X509_FILETYPE_PEM) != 0);