Index: configure.ac =================================================================== --- a/configure.ac +++ b/configure.ac @@ -9,7 +9,6 @@ AM_INIT_AUTOMAKE([1.10 foreign -Wall]) AC_PROG_CC_STDC -AC_PROG_CC AC_USE_SYSTEM_EXTENSIONS AM_PROG_AR Index: src/system.h =================================================================== --- a/src/system.h +++ b/src/system.h @@ -2,9 +2,7 @@ * \file popt/system.h */ -#ifdef HAVE_CONFIG_H #include "config.h" -#endif #include @@ -57,6 +55,8 @@ #define getenv(_s) secure_getenv(_s) #elif defined(HAVE___SECURE_GETENV) #define getenv(_s) __secure_getenv(_s) +#else +#error neither secure_getenv nor __secure_getenv is available #endif #if !defined(__GNUC__) && !defined(__attribute__) Index: src/popt.c =================================================================== --- a/src/popt.c +++ b/src/popt.c @@ -197,7 +197,7 @@ poptContext poptGetContext(const char * con->execAbsolute = 1; con->arg_strip = NULL; - if (getenv("POSIXLY_CORRECT") || getenv("POSIX_ME_HARDER")) + if (secure_getenv("POSIXLY_CORRECT") || secure_getenv("POSIX_ME_HARDER")) con->flags |= POPT_CONTEXT_POSIXMEHARDER; if (name) @@ -442,7 +442,7 @@ const char * findProgramPath(/*@null@*/ if (strchr(argv0, '/')) return xstrdup(argv0); - if ((path = getenv("PATH")) == NULL || (path = xstrdup(path)) == NULL) + if ((path = secure_getenv("PATH")) == NULL || (path = xstrdup(path)) == NULL) return NULL; /* The return buffer in t is big enough for any path. */ @@ -1706,6 +1706,7 @@ const char * poptBadOption(poptContext c const char * poptStrerror(const int error) { + char errbuf[1024]; switch (error) { case POPT_ERROR_NOARG: return POPT_("missing argument"); @@ -1728,7 +1729,7 @@ const char * poptStrerror(const int erro case POPT_ERROR_BADCONFIG: return POPT_("config file failed sanity test"); case POPT_ERROR_ERRNO: - return strerror(errno); + return strerror_r(errno, errbuf, sizeof errbuf); default: return POPT_("unknown error"); } Index: src/poptconfig.c =================================================================== --- a/src/poptconfig.c +++ b/src/poptconfig.c @@ -540,7 +540,7 @@ int poptReadDefaultConfig(poptContext co if (rc) goto exit; #endif - if ((home = getenv("HOME"))) { + if ((home = secure_getenv("HOME"))) { char * fn = malloc(strlen(home) + 20); if (fn != NULL) { (void) stpcpy(stpcpy(fn, home), "/.popt");