open, fopen: close fd leak in last patch
authorEric Blake <ebb9@byu.net>
Wed, 24 Sep 2008 16:55:19 +0000 (10:55 -0600)
committerEric Blake <ebb9@byu.net>
Wed, 24 Sep 2008 16:55:19 +0000 (10:55 -0600)
* lib/open.c (rpl_open): Close fd before returning error.
* lib/fopen.c (rpl_fopen): Close fd before returning error.
* doc/posix-functions/open.texi (open): Document that Irix also
has the bug.
* doc/posix-functions/fopen.texi (fopen): Likewise.
Reported by Paolo Bonzini.

Signed-off-by: Eric Blake <ebb9@byu.net>
ChangeLog
doc/posix-functions/fopen.texi
doc/posix-functions/open.texi
lib/fopen.c
lib/open.c

index 22bf905ac96ad3905922c3a4ea5e28699f55a7c4..49c1b2f9fb254ed6e729f7b1545f77d6990c9798 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2008-09-24  Eric Blake  <ebb9@byu.net>
+
+       open, fopen: close fd leak in last patch
+       * lib/open.c (rpl_open): Close fd before returning error.
+       * lib/fopen.c (rpl_fopen): Close fd before returning error.
+       * doc/posix-functions/open.texi (open): Document that Irix also
+       has the bug.
+       * doc/posix-functions/fopen.texi (fopen): Likewise.
+       Reported by Paolo Bonzini.
+
 2008-09-24  Bruno Haible  <bruno@clisp.org>
 
        Ensure that a filename ending in a slash cannot be used to access a
index 5fdb8dac4d794cc85e360955160f48dab254fd28..57794fb00265437ea49ed58fe36da56e77a6e8c5 100644 (file)
@@ -12,7 +12,7 @@ Portability problems fixed by Gnulib:
 This function does not fail when the file name argument ends in a slash
 and (without the slash) names a nonexistent file or a file that is not a
 directory, on some platforms:
-HP-UX 11.00, Solaris 9.
+HP-UX 11.00, Solaris 9, Irix 5.3.
 @item
 On Windows platforms (excluding Cygwin), this function does usually not
 recognize the @file{/dev/null} filename.
index ed3155da877ab2198b0dbf69060b5b72e67be938..1986f0c3f698f4b79bec761a978f87d57ae870ac 100644 (file)
@@ -12,7 +12,7 @@ Portability problems fixed by Gnulib:
 This function does not fail when the file name argument ends in a slash
 and (without the slash) names a nonexistent file or a file that is not a
 directory, on some platforms:
-HP-UX 11.00, Solaris 9.
+HP-UX 11.00, Solaris 9, Irix 5.3.
 @item
 On Windows platforms (excluding Cygwin), this function does usually not
 recognize the @file{/dev/null} filename.
index f64122b9f167c50f9ef61f8c40b796938d0a6b60..d6e048b79b6b43fa90ded109811a95926be9a740 100644 (file)
@@ -72,6 +72,7 @@ rpl_fopen (const char *filename, const char *mode)
 
        if (fstat (fd, &statbuf) >= 0 && !S_ISDIR (statbuf.st_mode))
          {
+           close (fd);
            errno = ENOTDIR;
            return NULL;
          }
index 317fb8afac217dd229d62bb67a7973bcdb6f13f8..97c30cee8c60ed5aa20bea42b64587caedb80d4f 100644 (file)
@@ -115,6 +115,7 @@ open (const char *filename, int flags, ...)
 
          if (fstat (fd, &statbuf) >= 0 && !S_ISDIR (statbuf.st_mode))
            {
+             close (fd);
              errno = ENOTDIR;
              return -1;
            }