libraries should use secure_getenv if possible
diff --git a/configure.ac b/configure.ac
index 24abeef..1926d18 100644
--- a/configure.ac
+++ b/configure.ac
@@ -32,6 +32,8 @@
         AC_DEFINE(ENABLE_DEBUG, [1], [Debug messages.])
 ])
 
+AC_CHECK_FUNCS([__secure_getenv secure_getenv])
+
 my_CFLAGS="-Wall \
 -Wmissing-declarations -Wmissing-prototypes \
 -Wnested-externs -Wpointer-arith \
diff --git a/src/libabc-private.h b/src/libabc-private.h
index 819c830..a186421 100644
--- a/src/libabc-private.h
+++ b/src/libabc-private.h
@@ -49,6 +49,14 @@
 #  define err(ctx, arg...) abc_log_null(ctx, ## arg)
 #endif
 
+#ifndef HAVE_SECURE_GETENV
+#  ifdef HAVE__SECURE_GETENV
+#    define secure_getenv __secure_getenv
+#  else
+#    error neither secure_getenv nor __secure_getenv is available
+#  endif
+#endif
+
 #define ABC_EXPORT __attribute__ ((visibility("default")))
 
 void abc_log(struct abc_ctx *ctx,
diff --git a/src/libabc.c b/src/libabc.c
index 1581c2c..cbbc16a 100644
--- a/src/libabc.c
+++ b/src/libabc.c
@@ -143,7 +143,7 @@
         c->log_priority = LOG_ERR;
 
         /* environment overwrites config */
-        env = getenv("ABC_LOG");
+        env = secure_getenv("ABC_LOG");
         if (env != NULL)
                 abc_set_log_priority(c, log_priority(env));