autoconf-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 1/5] m4sh: fix some namespace safety issues


From: Eric Blake
Subject: [PATCH 1/5] m4sh: fix some namespace safety issues
Date: Wed, 25 Aug 2010 17:18:17 -0600

* lib/m4sugar/m4sh.m4 (_AS_SHELL_SANITIZE): Avoid problems if
as_myself is inherited from environment.
(AS_TMPDIR): Be namespace clean.

Signed-off-by: Eric Blake <address@hidden>
---

We shouldn't clobber $tmp without good reason.  test -d '' reliably
fails, so it makes test -n "$as_tmp" wasted effort.  And although the
user shouldn't be exporting anything in the as_ namespace, it
can't hurt to be a bit more careful.

 ChangeLog           |    7 +++++++
 lib/m4sugar/m4sh.m4 |   10 ++++++----
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index c7ef728..569d7ad 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2010-08-25  Eric Blake  <address@hidden>
+
+       m4sh: fix some namespace safety issues
+       * lib/m4sugar/m4sh.m4 (_AS_SHELL_SANITIZE): Avoid problems if
+       as_myself is inherited from environment.
+       (AS_TMPDIR): Be namespace clean.
+
 2010-08-24  Ralf Wildenhues  <address@hidden>

        tests: fix AC_CACHE_CHECK to skip with bad shells.
diff --git a/lib/m4sugar/m4sh.m4 b/lib/m4sugar/m4sh.m4
index 3cc868c..15dd80d 100644
--- a/lib/m4sugar/m4sh.m4
+++ b/lib/m4sugar/m4sh.m4
@@ -425,6 +425,7 @@ _AS_PATH_SEPARATOR_PREPARE
 IFS=" ""       $as_nl"

 # Find who we are.  Look in the path if we contain no directory separator.
+as_myself=
 case $[0] in @%:@((
   *[[\\/]]* ) as_myself=$[0] ;;
   *) _AS_PATH_WALK([],
@@ -1618,12 +1619,13 @@ m4_define([AS_TMPDIR],
 [# Create a (secure) tmp directory for tmp files.
 m4_if([$2], [], [: ${TMPDIR=/tmp}])
 {
-  tmp=`(umask 077 && mktemp -d "m4_default([$2], [$TMPDIR])/$1XXXXXX") 
2>/dev/null` &&
-  test -n "$tmp" && test -d "$tmp"
+  as_tmp=`(umask 077 && mktemp -d "m4_default([$2],
+    [$TMPDIR])/$1XXXXXX") 2>/dev/null` &&
+  test -d "$as_tmp"
 }  ||
 {
-  tmp=m4_default([$2], [$TMPDIR])/$1$$-$RANDOM
-  (umask 077 && mkdir "$tmp")
+  as_tmp=m4_default([$2], [$TMPDIR])/$1$$-$RANDOM
+  (umask 077 && mkdir "$as_tmp")
 } || AS_ERROR([cannot create a temporary directory in m4_default([$2],
              [$TMPDIR])])])# AS_TMPDIR

-- 
1.7.2.2




reply via email to

[Prev in Thread] Current Thread [Next in Thread]