popt/popt-libc-updates.patch

179 lines
4.8 KiB
Diff
Raw Normal View History

--- configure.ac.orig
+++ configure.ac
@@ -21,7 +21,7 @@ AC_SUBST(LT_AGE, 8)
ALL_LINGUAS="cs da de eo es fi fr ga gl hu id is it ja ko lv nb nl pl pt ro ru sk sl sv th tr uk vi wa zh_TW zh_CN"
AC_PROG_CC_STDC
-AC_PROG_CC
+AC_USE_SYSTEM_EXTENSIONS
AC_PROG_INSTALL
AC_PROG_LIBTOOL
@@ -40,13 +40,12 @@ else
fi
AC_SUBST(TARGET)
-CFLAGS="$CFLAGS -D_GNU_SOURCE -D_REENTRANT"
+CFLAGS="$CFLAGS -D_REENTRANT"
AC_GCC_TRADITIONAL
AC_SYS_LARGEFILE
AC_ISC_POSIX
-AM_C_PROTOTYPES
AC_CHECK_HEADERS(float.h fnmatch.h glob.h langinfo.h libintl.h mcheck.h unistd.h)
@@ -82,7 +81,7 @@ AC_ARG_ENABLE(build-gcov,
AC_CHECK_FUNC(setreuid, [], [
AC_CHECK_LIB(ucb, setreuid, [if echo $LIBS | grep -- -lucb >/dev/null ;then :; else LIBS="$LIBS -lc -lucb" USEUCB=y;fi])
])
-AC_CHECK_FUNCS(getuid geteuid iconv mtrace __secure_getenv setregid stpcpy strerror vasprintf srandom)
+AC_CHECK_FUNCS(getuid geteuid iconv mtrace __secure_getenv secure_getenv setregid stpcpy strerror vasprintf srandom)
AM_GNU_GETTEXT([external])
AM_ICONV_LINK
--- system.h.orig
+++ system.h
@@ -1,10 +1,9 @@
/**
* \file popt/system.h
*/
+#pragma once
-#ifdef HAVE_CONFIG_H
#include "config.h"
-#endif
#if defined (__GLIBC__) && defined(__LCLINT__)
/*@-declundef@*/
@@ -42,6 +41,7 @@ extern __const __int32_t *__ctype_touppe
#include <libc.h>
#endif
+#pragma GCC visibility push(hidden)
/*@-incondefs@*/
/*@mayexit@*/ /*@only@*/ /*@out@*/ /*@unused@*/
void * xmalloc (size_t size)
@@ -77,6 +77,8 @@ static inline char * stpcpy (char *dest,
}
#endif
+#pragma GCC visibility pop
+
/* Memory allocation via macro defs to get meaningful locations from mtrace() */
#if defined(HAVE_MCHECK_H) && defined(__GNUC__)
#define vmefail() (fprintf(stderr, "virtual memory exhausted.\n"), exit(EXIT_FAILURE), NULL)
@@ -91,8 +93,12 @@ static inline char * stpcpy (char *dest,
#define xstrdup(_str) strdup(_str)
#endif /* defined(HAVE_MCHECK_H) && defined(__GNUC__) */
-#if defined(HAVE___SECURE_GETENV) && !defined(__LCLINT__)
-#define getenv(_s) __secure_getenv(_s)
+#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
#if !defined(__GNUC__) && !defined(__attribute__)
--- Makefile.am.orig
+++ Makefile.am
@@ -14,7 +14,7 @@ EXTRA_DIST = config.rpath lookup3.c auto
SUBDIRS = po . auto
-AM_CPPFLAGS = -I. -I$(top_srcdir)
+AM_CPPFLAGS = -include $(top_srcdir)/system.h -I. -I$(top_srcdir)
noinst_HEADERS = poptint.h system.h
--- popt.c.orig
+++ 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");
}
--- poptconfig.c.orig
+++ 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");
--- poptint.h.orig
+++ poptint.h
@@ -11,6 +11,8 @@
#include <stdint.h>
+#pragma GCC visibility push(hidden)
+
/**
* Wrapper to free(3), hides const compilation noise, permit NULL, return NULL.
* @param p memory to free
@@ -149,6 +151,8 @@ struct poptContext_s {
pbm_set * arg_strip;
};
+#pragma GCC visibility pop
+
#if defined(POPT_fprintf)
#define POPT_dgettext dgettext
#else
@@ -182,6 +186,8 @@ extern char *nl_langinfo (nl_item __item
#endif
#endif
+#pragma GCC visibility push(hidden)
+
#if defined(HAVE_DCGETTEXT) && !defined(__LCLINT__)
char *POPT_dgettext(const char * dom, const char * str)
/*@*/;
@@ -200,6 +206,8 @@ const char *POPT_next_char (/*@returned@
#endif
+#pragma GCC visibility pop
+
#if defined(ENABLE_NLS) && defined(HAVE_LIBINTL_H)
#include <libintl.h>
#endif