[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
pipe-safer.c fixes
From: |
Paul Eggert |
Subject: |
pipe-safer.c fixes |
Date: |
Fri, 11 Aug 2006 13:33:03 -0700 |
User-agent: |
Gnus/5.1008 (Gnus v5.10.8) Emacs/21.4 (gnu/linux) |
The latest change to pipe-safer.c doesn't work on GNU or Unix
platforms, since it misspelled an identifier. (Yet another waste of
my time due to mingw -- mingw changes really should get checked on a
GNU/Linux box before review/checkin....)
Also I noticed a file descriptor leak.
I installed this.
2006-08-11 Paul Eggert <address@hidden>
* pipe-safer.c (pipe_safer): Fix misspelling: HAVE_FUNC_PIPE ->
HAVE_PIPE. Fix a file descriptor leak when fd_safer fails.
--- lib/pipe-safer.c 27 Jul 2006 04:34:16 -0000 1.3
+++ lib/pipe-safer.c 11 Aug 2006 20:23:35 -0000
@@ -33,25 +33,27 @@
int
pipe_safer (int fd[2])
{
-#if HAVE_FUNC_PIPE
- int fail = pipe (fd);
- if (fail)
- return fail;
+#if HAVE_PIPE
+ if (pipe (fd) == 0)
+ {
+ int i;
+ for (i = 0; i < 2; i++)
+ {
+ fd[i] = fd_safer (fd[i]);
+ if (fd[i] < 0)
+ {
+ int e = errno;
+ close (fd[1 - i]);
+ errno = e;
+ return -1;
+ }
+ }
- {
- int i;
- for (i = 0; i < 2; i++)
- {
- int f = fd_safer (fd[i]);
- if (f < 0)
- return -1;
- fd[i] = f;
- }
- }
-
- return 0;
-#else /* ! HAVE_FUNC_PIPE */
+ return 0;
+ }
+#else
errno = ENOSYS;
- return -1;
#endif
+
+ return -1;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- pipe-safer.c fixes,
Paul Eggert <=