diff options
author | Cristian RodrÃguez <crrodriguez@opensuse.org> | 2013-02-26 22:40:15 -0300 |
---|---|---|
committer | Kay Sievers <kay@vrfy.org> | 2013-02-27 12:10:56 +0100 |
commit | 0fd32922ba6044b63adcc1d8ae462bf895390bf8 (patch) | |
tree | c87aa4b5ec1c73d1d69876e72014c58e0389a49e | |
parent | a6636ac9f7d2e29c2d744b9c8551631dd0976c61 (diff) | |
download | libabc-0fd32922ba6044b63adcc1d8ae462bf895390bf8.tar.gz |
libraries should use secure_getenv if possible
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | src/libabc-private.h | 8 | ||||
-rw-r--r-- | src/libabc.c | 2 |
3 files changed, 11 insertions, 1 deletions
diff --git a/configure.ac b/configure.ac index 24abeef..1926d18 100644 --- a/configure.ac +++ b/configure.ac @@ -32,6 +32,8 @@ AS_IF([test "x$enable_debug" = "xyes"], [ 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 @@ abc_log_null(struct abc_ctx *ctx, const char *format, ...) {} # 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 @@ ABC_EXPORT int abc_new(struct abc_ctx **ctx) 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)); |