Commit b0a3048e authored by Nikos Mavrogiannopoulos's avatar Nikos Mavrogiannopoulos
Browse files

env: use secure_getenv when reading environment variables

parent a0735b1f
......@@ -53,7 +53,7 @@ const char *p;
if (_fips_mode != -1)
return _fips_mode;
p = getenv("GNUTLS_FORCE_FIPS_MODE");
p = secure_getenv("GNUTLS_FORCE_FIPS_MODE");
if (p) {
if (p[0] == '1')
_fips_mode = 1;
......
......@@ -229,7 +229,7 @@ int gnutls_global_init(void)
_gnutls_switch_lib_state(LIB_STATE_INIT);
e = getenv("GNUTLS_DEBUG_LEVEL");
e = secure_getenv("GNUTLS_DEBUG_LEVEL");
if (e != NULL) {
level = atoi(e);
gnutls_global_set_log_level(level);
......@@ -441,7 +441,7 @@ const char *e;
if (_gnutls_global_init_skip() != 0)
return;
e = getenv("GNUTLS_NO_EXPLICIT_INIT");
e = secure_getenv("GNUTLS_NO_EXPLICIT_INIT");
if (e != NULL) {
ret = atoi(e);
if (ret == 1)
......@@ -462,7 +462,7 @@ static void _DESTRUCTOR lib_deinit(void)
if (_gnutls_global_init_skip() != 0)
return;
e = getenv("GNUTLS_NO_EXPLICIT_INIT");
e = secure_getenv("GNUTLS_NO_EXPLICIT_INIT");
if (e != NULL) {
int ret = atoi(e);
if (ret == 1)
......
......@@ -23,6 +23,8 @@
#ifndef GNUTLS_MEM_H
#define GNUTLS_MEM_H
#include <config.h>
/* this realloc function will return ptr if size==0, and
* will free the ptr if the new allocation failed.
*/
......@@ -41,6 +43,10 @@ int safe_memcmp(const void *s1, const void *s2, size_t n)
return memcmp(s1, s2, n);
}
#ifndef HAVE_SECURE_GETENV
# define secure_getenv getenv
#endif
#define zrelease_mpi_key(mpi) if (*mpi!=NULL) { \
_gnutls_mpi_clear(*mpi); \
_gnutls_mpi_release(mpi); \
......
......@@ -323,7 +323,7 @@ void gnutls_system_global_deinit()
*/
int _gnutls_find_config_path(char *path, size_t max_size)
{
const char *home_dir = getenv("HOME");
const char *home_dir = secure_getenv("HOME");
if (home_dir != NULL && home_dir[0] != 0) {
snprintf(path, max_size, "%s/" CONFIG_PATH, home_dir);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment