This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "GNU M4 source repository".
http://git.sv.gnu.org/gitweb/?p=m4.git;a=commitdiff;h=3747d9b3026ff3372789f0c8f451791af966acfd The branch, branch-1.6 has been updated via 3747d9b3026ff3372789f0c8f451791af966acfd (commit) via 06331182fde485887e38d7c033d3d43e12641838 (commit) from 75f444724834fafe495fe10bb73a261150623726 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 3747d9b3026ff3372789f0c8f451791af966acfd Author: Eric Blake <[EMAIL PROTECTED]> Date: Wed Sep 24 22:02:45 2008 -0600 Unify error handling for reading directories. * src/path.c (m4_path_search): Factor open attempts... (m4_fopen): ...into new function, to reject directories. * doc/m4.texinfo (Include): Document that directories cannot be input files. Signed-off-by: Eric Blake <[EMAIL PROTECTED]> (cherry picked from commit eed62f0d2729c243d7c081c48d789f9d86fa340f) commit 06331182fde485887e38d7c033d3d43e12641838 Author: Eric Blake <[EMAIL PROTECTED]> Date: Wed Sep 24 20:43:12 2008 -0600 Avoid bugs on platforms that mishandle trailing /. * m4/gnulib-cache.m4: Import fopen module. * doc/m4.texinfo (Command line files, Include): Add tests. (Using frozen files): This test now works on mingw. * checks/check-them (examples): Expand xerr to allow ignoring error output because of differences in platform errno values. Signed-off-by: Eric Blake <[EMAIL PROTECTED]> (cherry picked from commit ce1f8f6861b928b7b587d69eee2000a0101e3381) ----------------------------------------------------------------------- Summary of changes: ChangeLog | 15 ++++++++++++++ checks/check-them | 19 ++++++++++------- doc/m4.texinfo | 55 ++++++++++++++++++++++++++++++++++++++++++++++++--- m4/gnulib-cache.m4 | 3 +- src/path.c | 31 ++++++++++++++++++++++------ 5 files changed, 103 insertions(+), 20 deletions(-) diff --git a/ChangeLog b/ChangeLog index da4838e..0786c2a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2008-09-24 Eric Blake <[EMAIL PROTECTED]> + + Unify error handling for reading directories. + * src/path.c (m4_path_search): Factor open attempts... + (m4_fopen): ...into new function, to reject directories. + * doc/m4.texinfo (Include): Document that directories cannot be + input files. + + Avoid bugs on platforms that mishandle trailing /. + * m4/gnulib-cache.m4: Import fopen module. + * doc/m4.texinfo (Command line files, Include): Add tests. + (Using frozen files): This test now works on mingw. + * checks/check-them (examples): Expand xerr to allow ignoring + error output because of differences in platform errno values. + 2008-09-22 Eric Blake <[EMAIL PROTECTED]> Support alternate path separator. diff --git a/checks/check-them b/checks/check-them index 8ddef58..89f8b41 100755 --- a/checks/check-them +++ b/checks/check-them @@ -117,14 +117,17 @@ do fi xerrfile=`sed -n 's/^dnl @ expected error: //p' "$file"` - if test -z "$xerrfile" ; then - sed '/^dnl @error{}/!d - s///; '"s|^m4:|$m4name:|; s|examples/|$examples/|" \ - "$file" > $xerr - else - sed "s|^m4:|$m4name:|; s|examples/|$examples/|" \ - "$examples/$xerrfile" > $xerr - fi + case $xerrfile in + ignore) + cp $err $xerr ;; + '') + sed '/^dnl @error{}/!d + s///; '"s|^m4:|$m4name:|; s|examples/|$examples/|" \ + "$file" > $xerr ;; + *) + sed "s|^m4:|$m4name:|; s|examples/|$examples/|" \ + "$examples/$xerrfile" > $xerr ;; + esac # For the benefit of mingw, normalize \r\n line endings if $strip_needed ; then diff --git a/doc/m4.texinfo b/doc/m4.texinfo index dd4a928..db80b60 100644 --- a/doc/m4.texinfo +++ b/doc/m4.texinfo @@ -1011,6 +1011,19 @@ If you need to read a file whose name starts with a @file{-}, you can specify it as @samp{./-file}, or use @option{--} to mark the end of options. [EMAIL PROTECTED] [EMAIL PROTECTED] Test that 'm4 file/' detects that file is not a directory; we [EMAIL PROTECTED] can assume that the current directory contains a Makefile. [EMAIL PROTECTED] mingw fails with EINVAL rather than ENOTDIR. + [EMAIL PROTECTED] status: 1 [EMAIL PROTECTED] xerr: ignore [EMAIL PROTECTED] options: Makefile/ [EMAIL PROTECTED] [EMAIL PROTECTED]: Makefile/: Not a directory [EMAIL PROTECTED] example [EMAIL PROTECTED] ignore + @node Syntax @chapter Lexical and syntactic conventions @@ -5122,7 +5135,8 @@ the previous input file. The expansion of @code{include} and @code{sinclude} is therefore the contents of @var{file}. -If @var{file} does not exist (or cannot be read), the expansion is void, +If @var{file} does not exist, is a directory, or cannot otherwise be +read, the expansion is void, and @code{include} will fail with an error while @code{sinclude} is silent. The empty string counts as a file that does not exist. @@ -5203,6 +5217,42 @@ files on the command line. In @acronym{GNU} @code{m4}, an alternative method of reading files is using @code{undivert} (@pxref{Undivert}) on a named file. [EMAIL PROTECTED] [EMAIL PROTECTED] Test that include(`file/') detects that file is not a [EMAIL PROTECTED] directory; we can assume that the current directory contains a [EMAIL PROTECTED] Makefile. mingw fails with EINVAL rather than ENOTDIR. + [EMAIL PROTECTED] status: 1 [EMAIL PROTECTED] xerr: ignore [EMAIL PROTECTED] +include(`Makefile/') [EMAIL PROTECTED]:stdin:1: include: cannot open `Makefile/': Not a directory [EMAIL PROTECTED] [EMAIL PROTECTED] example + [EMAIL PROTECTED] POSIX allows, but doesn't require, failure on reading [EMAIL PROTECTED] directories. But since they aren't text files, it never makes [EMAIL PROTECTED] sense, so we globally forbid it even if fopen doesn't. mingw [EMAIL PROTECTED] fails with EACCES rather than EISDIR. + [EMAIL PROTECTED] status: 1 [EMAIL PROTECTED] xerr: ignore [EMAIL PROTECTED] +include(`.') [EMAIL PROTECTED]:stdin:1: include: cannot open `.': Is a directory [EMAIL PROTECTED] [EMAIL PROTECTED] example + [EMAIL PROTECTED] Meanwhile, ignore errors with sinclude. + [EMAIL PROTECTED] +sinclude(`Makefile/') [EMAIL PROTECTED] +sinclude(`.') [EMAIL PROTECTED] [EMAIL PROTECTED] example [EMAIL PROTECTED] ignore + @node Search Path @section Searching for include files @@ -7222,9 +7272,6 @@ changed strings for quotes or comments. And future releases of @comment options: -F /dev/null @example -ifdef(`__unix__', , - `errprint(` skipping: /dev/null not known to exist -')m4exit(`77')')dnl traceon(`undefined')dnl @end example diff --git a/m4/gnulib-cache.m4 b/m4/gnulib-cache.m4 index 1f78e71..a738429 100644 --- a/m4/gnulib-cache.m4 +++ b/m4/gnulib-cache.m4 @@ -15,7 +15,7 @@ # Specification in the form of a command-line invocation: -# gnulib-tool --import --dir=. --local-dir=local --lib=libm4 --source-base=lib --m4-base=m4 --doc-base=doc --aux-dir=build-aux --with-tests --no-libtool --macro-prefix=M4 announce-gen assert autobuild avltree-oset binary-io clean-temp cloexec close-stream closein config-h dirname error fdl fflush filenamecat flexmember fopen-safer fseeko gendocs getopt git-version-gen gnumakefile gnupload gpl-3.0 hash intprops memmem mkstemp obstack obstack-printf-posix progname quote regex stdbool stdint stdlib-safer strtod strtol unlocked-io vasnprintf-posix verror version-etc version-etc-fsf xalloc xmemdup0 xprintf xvasprintf-posix +# gnulib-tool --import --dir=. --local-dir=local --lib=libm4 --source-base=lib --m4-base=m4 --doc-base=doc --aux-dir=build-aux --with-tests --no-libtool --macro-prefix=M4 announce-gen assert autobuild avltree-oset binary-io clean-temp cloexec close-stream closein config-h dirname error fdl fflush filenamecat flexmember fopen fopen-safer fseeko gendocs getopt git-version-gen gnumakefile gnupload gpl-3.0 hash intprops memmem mkstemp obstack obstack-printf-posix progname quote regex stdbool stdint stdlib-safer strtod strtol unlocked-io vasnprintf-posix verror version-etc version-etc-fsf xalloc xmemdup0 xprintf xvasprintf-posix # Specification in the form of a few gnulib-tool.m4 macro invocations: gl_LOCAL_DIR([local]) @@ -36,6 +36,7 @@ gl_MODULES([ fflush filenamecat flexmember + fopen fopen-safer fseeko gendocs diff --git a/src/path.c b/src/path.c index c0d7df7..d630bad 100644 --- a/src/path.c +++ b/src/path.c @@ -105,6 +105,28 @@ add_include_directory (const char *dir) #endif } +/* Attempt to open FILE; if it opens, verify that it is not a + directory, and ensure it does not leak across execs. */ +static FILE * +m4_fopen (const char *file, const char *mode) +{ + FILE *fp = fopen (file, "r"); + if (fp) + { + struct stat st; + int fd = fileno (fp); + if (fstat (fd, &st) == 0 && S_ISDIR (st.st_mode)) + { + fclose (fp); + errno = EISDIR; + return NULL; + } + if (set_cloexec_flag (fd, true) != 0) + m4_warn (errno, NULL, _("cannot protect input file across forks")); + } + return fp; +} + /* Search for FILE, first in `.', then according to -I options. If successful, return the open file, and if RESULT is not NULL, set *RESULT to a malloc'd string that represents the file found with @@ -129,11 +151,9 @@ m4_path_search (const char *file, char **result) } /* Look in current working directory first. */ - fp = fopen (file, "r"); + fp = m4_fopen (file, "r"); if (fp != NULL) { - if (set_cloexec_flag (fileno (fp), true) != 0) - m4_warn (errno, NULL, _("cannot protect input file across forks")); if (result) *result = xstrdup (file); return fp; @@ -152,18 +172,15 @@ m4_path_search (const char *file, char **result) xfprintf (stderr, "m4_path_search (%s) -- trying %s\n", file, name); #endif - fp = fopen (name, "r"); + fp = m4_fopen (name, "r"); if (fp != NULL) { if (debug_level & DEBUG_TRACE_PATH) debug_message ("path search for `%s' found `%s'", file, name); - if (set_cloexec_flag (fileno (fp), true) != 0) - m4_warn (errno, NULL, _("cannot protect input file across forks")); if (result) *result = name; else free (name); - errno = e; return fp; } free (name); hooks/post-receive -- GNU M4 source repository
