]> git.saurik.com Git - bison.git/commitdiff
* bootstrap: Add stdio-safer, unistd-safer modules.
authorPaul Eggert <eggert@cs.ucla.edu>
Sun, 22 May 2005 08:04:06 +0000 (08:04 +0000)
committerPaul Eggert <eggert@cs.ucla.edu>
Sun, 22 May 2005 08:04:06 +0000 (08:04 +0000)
Remove m4/glibc2.m4 (introduced by latest gnulib, but
we don't need it).
* lib/.cvsignore: Add dup-safer.c, fd-safer.c,
fopen-safer.c, stdio-safer.h, unistd-safer.h.
* lib/subpipe.c: Include "unistd-safer.h".
(create_subpipe): Make sure all the newly-created
file descriptors are > 2, so that diagnostics don't
get sent down them (which might cause Bison to hang, in theory).
* m4/.cvsignore: Add stdio-safer.m4, unistd-safer.m4.
* src/files.c (xfopen): Use fopen_safer, not fopen.

ChangeLog
bootstrap
lib/.cvsignore
lib/subpipe.c
m4/.cvsignore
src/files.c

index 0ec3c5b0b89ab0853564d6f418af9b71426850ba..f8882170e9e3b8de27ee29c7c3dc535778d6b32d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,10 +1,24 @@
 2005-05-22  Paul Eggert  <eggert@cs.ucla.edu>
 
 2005-05-22  Paul Eggert  <eggert@cs.ucla.edu>
 
+       * bootstrap: Add stdio-safer, unistd-safer modules.
+       Remove m4/glibc2.m4 (introduced by latest gnulib, but
+       we don't need it).
+       * lib/.cvsignore: Add dup-safer.c, fd-safer.c,
+       fopen-safer.c, stdio-safer.h, unistd-safer.h.
+       * lib/subpipe.c: Include "unistd-safer.h".
+       (create_subpipe): Make sure all the newly-created
+       file descriptors are > 2, so that diagnostics don't
+       get sent down them (which might cause Bison to hang, in theory).
+       * m4/.cvsignore: Add stdio-safer.m4, unistd-safer.m4.
+       * src/files.c (xfopen): Use fopen_safer, not fopen.
+
        * data/lalr1.cc (yy::]b4_parser_class_name[::parse): Port
        yesterday's yacc.c fix.
 
 2005-05-21  Paul Eggert  <eggert@cs.ucla.edu>
 
        * data/lalr1.cc (yy::]b4_parser_class_name[::parse): Port
        yesterday's yacc.c fix.
 
 2005-05-21  Paul Eggert  <eggert@cs.ucla.edu>
 
+       * data/glr.c, data/lalr1.cc: Update copyright date.
+
        Fix a destructor bug reported by Wolfgang Spraul in
        <http://lists.gnu.org/archive/html/bug-bison/2005-05/msg00042.html>.
        * data/yacc.c (yyabortlab): Don't call destructor, and
        Fix a destructor bug reported by Wolfgang Spraul in
        <http://lists.gnu.org/archive/html/bug-bison/2005-05/msg00042.html>.
        * data/yacc.c (yyabortlab): Don't call destructor, and
index f14d269bab861942f0ef103131ce30a4bcb6c698..d843e43cb0ed320f579336a3213e0ceb9bbfb466 100755 (executable)
--- a/bootstrap
+++ b/bootstrap
@@ -105,7 +105,9 @@ obstack
 quote
 quotearg
 stdbool
 quote
 quotearg
 stdbool
+stdio-safer
 stpcpy
 stpcpy
+unistd-safer
 xalloc
 xalloc-die
 xstrndup
 xalloc
 xalloc-die
 xstrndup
@@ -197,6 +199,7 @@ intl_files_to_remove='
   intl
   m4/codeset.m4
   m4/gettext.m4
   intl
   m4/codeset.m4
   m4/gettext.m4
+  m4/glibc2.m4
   m4/glibc21.m4
   m4/intdiv0.m4
   m4/intmax.m4
   m4/glibc21.m4
   m4/intdiv0.m4
   m4/intmax.m4
index 61c71b0648233791e923673e9a8602411909a5cd..0a6915f0e9397449fedbc8daccd04f586a4564a3 100644 (file)
@@ -9,11 +9,14 @@ argmatch.h
 basename.c
 dirname.c
 dirname.h
 basename.c
 dirname.c
 dirname.h
+dup-safer.c
 error.c
 error.h
 exit.h
 exitfail.c
 exitfail.h
 error.c
 error.h
 exit.h
 exitfail.c
 exitfail.h
+fd-safer.c
+fopen-safer.c
 getopt.c
 getopt.h
 getopt1.c
 getopt.c
 getopt.h
 getopt1.c
@@ -37,6 +40,7 @@ quotearg.h
 realloc.c
 stdbool.h
 stdbool_.h
 realloc.c
 stdbool.h
 stdbool_.h
+stdio-safer.h
 stpcpy.c
 stpcpy.h
 strdup.c
 stpcpy.c
 stpcpy.h
 strdup.c
@@ -46,6 +50,7 @@ strncasecmp.c
 strndup.c
 strndup.h
 strnlen.c
 strndup.c
 strndup.h
 strnlen.c
+unistd-safer.h
 unlocked-io.h
 xalloc-die.c
 xalloc.h
 unlocked-io.h
 xalloc-die.c
 xalloc.h
index 786de26b8ca49d3117a7f2ed7136dc591335cf41..f20907174c2c3b58f64e8a091e0b67c9369aee9b 100644 (file)
@@ -1,6 +1,6 @@
 /* Subprocesses with pipes.
 
 /* Subprocesses with pipes.
 
-   Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -68,6 +68,7 @@
 #endif
 
 #include "error.h"
 #endif
 
 #include "error.h"
+#include "unistd-safer.h"
 
 #include "gettext.h"
 #define _(Msgid)  gettext (Msgid)
 
 #include "gettext.h"
 #define _(Msgid)  gettext (Msgid)
@@ -105,15 +106,13 @@ create_subpipe (char const * const *argv, int fd[2])
   int to_out_fd;
   pid_t pid;
 
   int to_out_fd;
   pid_t pid;
 
-  if (pipe (pipe_fd) != 0)
+  if (pipe (pipe_fd) != 0
+      || (to_in_fd = fd_safer (pipe_fd[0])) < 0
+      || (to_out_fd = fd_safer (pipe_fd[1])) < 0
+      || pipe (pipe_fd) != 0
+      || (from_in_fd = fd_safer (pipe_fd[0])) < 0
+      || (from_out_fd = fd_safer (pipe_fd[1])) < 0)
     error (EXIT_FAILURE, errno, "pipe");
     error (EXIT_FAILURE, errno, "pipe");
-  to_in_fd = pipe_fd[0];
-  to_out_fd = pipe_fd[1];
-
-  if (pipe (pipe_fd) != 0)
-    error (EXIT_FAILURE, errno, "pipe");
-  from_in_fd = pipe_fd[0];
-  from_out_fd = pipe_fd[1];
 
   pid = vfork ();
   if (pid < 0)
 
   pid = vfork ();
   if (pid < 0)
@@ -124,23 +123,16 @@ create_subpipe (char const * const *argv, int fd[2])
       /* Child.  */
       close (to_out_fd);
       close (from_in_fd);
       /* Child.  */
       close (to_out_fd);
       close (from_in_fd);
-
-      if (to_in_fd != STDIN_FILENO)
-       {
-         dup2 (to_in_fd, STDIN_FILENO);
-         close (to_in_fd);
-       }
-      if (from_out_fd != STDOUT_FILENO)
-       {
-         dup2 (from_out_fd, STDOUT_FILENO);
-         close (from_out_fd);
-       }
+      dup2 (to_in_fd, STDIN_FILENO);
+      close (to_in_fd);
+      dup2 (from_out_fd, STDOUT_FILENO);
+      close (from_out_fd);
 
       /* The cast to (char **) rather than (char * const *) is needed
         for portability to older hosts with a nonstandard prototype
         for execvp.  */
       execvp (argv[0], (char **) argv);
 
       /* The cast to (char **) rather than (char * const *) is needed
         for portability to older hosts with a nonstandard prototype
         for execvp.  */
       execvp (argv[0], (char **) argv);
-    
+
       _exit (errno == ENOENT ? 127 : 126);
     }
 
       _exit (errno == ENOENT ? 127 : 126);
     }
 
index 220416763f15b9ed1960ee89d5831399bfbe3ef7..30e5230f3219a750a0e6b1037cf9a3849e5605d9 100644 (file)
@@ -26,11 +26,13 @@ progtest.m4
 quote.m4
 quotearg.m4
 stdbool.m4
 quote.m4
 quotearg.m4
 stdbool.m4
+stdio-safer.m4
 stpcpy.m4
 strdup.m4
 strerror_r.m4
 strndup.m4
 strnlen.m4
 stpcpy.m4
 strdup.m4
 strerror_r.m4
 strndup.m4
 strnlen.m4
+unistd-safer.m4
 unlocked-io.m4
 xalloc.m4
 xstrndup.m4
 unlocked-io.m4
 xalloc.m4
 xstrndup.m4
index aa65f41f5f9dfdfad1d4866c558087e2b7ff03c2..abe86463d6a3818b288515a8d3844f5d0df3b574 100644 (file)
@@ -1,6 +1,6 @@
 /* Open and close files for Bison.
 
 /* Open and close files for Bison.
 
-   Copyright (C) 1984, 1986, 1989, 1992, 2000, 2001, 2002, 2003, 2004
+   Copyright (C) 1984, 1986, 1989, 1992, 2000, 2001, 2002, 2003, 2004, 2005
    Free Software Foundation, Inc.
 
    This file is part of Bison, the GNU Compiler Compiler.
    Free Software Foundation, Inc.
 
    This file is part of Bison, the GNU Compiler Compiler.
@@ -95,7 +95,7 @@ xfopen (const char *name, const char *mode)
 {
   FILE *ptr;
 
 {
   FILE *ptr;
 
-  ptr = fopen (name, mode);
+  ptr = fopen_safer (name, mode);
   if (!ptr)
     error (EXIT_FAILURE, get_errno (), _("cannot open file `%s'"), name);
 
   if (!ptr)
     error (EXIT_FAILURE, get_errno (), _("cannot open file `%s'"), name);