This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Try to use issetugid before falling back to insecure getenv


Dne sreda, 25. april 2018 ob 19:53:08 CEST je Andreas Schwab napisal(a):
> On Apr 25 2018, Matija Skala <mskala@gmx.com> wrote:
> > diff --git a/libvtv/configure.ac b/libvtv/configure.ac
> > index ba3009ee3fb..878ba02a2e2 100644
> > --- a/libvtv/configure.ac
> > +++ b/libvtv/configure.ac
> > @@ -115,6 +115,9 @@ AC_CHECK_FUNCS([__secure_getenv])
> > 
> >  AC_GNU_SOURCE
> >  AC_CHECK_FUNCS([secure_getenv])
> > 
> > +AC_GNU_SOURCE
> > +AC_CHECK_FUNCS([issetugid])
> 
> There is no need to repeat AC_GNU_SOURCE.
> 
> Andreas.

Thanks for pointing this out. There was already one repetition which confused me.

---
 libvtv/configure.ac | 3 ++-
 libvtv/vtv_utils.cc | 2 ++
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/libvtv/configure.ac b/libvtv/configure.ac
index ba3009ee3fb..4d8cda9adaf 100644
--- a/libvtv/configure.ac
+++ b/libvtv/configure.ac
@@ -112,9 +112,10 @@ AC_SUBST(toolexeclibdir)
 AC_GNU_SOURCE
 AC_CHECK_FUNCS([__secure_getenv])
 
-AC_GNU_SOURCE
 AC_CHECK_FUNCS([secure_getenv])
 
+AC_CHECK_FUNCS([issetugid])
+
 AC_CHECK_FUNCS([getexecname __fortify_fail])
 
 # Check for programs.
diff --git a/libvtv/vtv_utils.cc b/libvtv/vtv_utils.cc
index 1e41ced4473..10efee987d4 100644
--- a/libvtv/vtv_utils.cc
+++ b/libvtv/vtv_utils.cc
@@ -46,6 +46,8 @@
 #ifndef HAVE_SECURE_GETENV
 #  ifdef HAVE___SECURE_GETENV
 #    define secure_getenv __secure_getenv
+#  elif defined HAVE_ISSETUGID
+#    define secure_getenv(name) (issetugid() ? NULL : getenv(name))
 #  else
 #    define secure_getenv getenv
 #  endif
-- 
2.16.1


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]