Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: Re: PATCH: no more fd mixups
- X-seq: zsh-workers 8189
- From: "Bart Schaefer" <schaefer@xxxxxxxxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxxxxxx
- Subject: PATCH: Re: PATCH: no more fd mixups
- Date: Sun, 10 Oct 1999 16:39:02 +0000
- In-reply-to: <E11aK4j-0006RV-00@xxxxxxxxxxxxxxxxxx>
- In-reply-to: <991010155440.ZM2271@xxxxxxxxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxxxxxx; run by ezmlm
- References: <E11aK4j-0006RV-00@xxxxxxxxxxxxxxxxxx> <E11aJ8m-0004lr-00@xxxxxxxxxxxxxxxxxx> <991010155440.ZM2271@xxxxxxxxxxxxxxxxxxxxxxx>
On Oct 10, 3:35pm, Zefram wrote:
} Subject: PATCH: no more fd mixups
}
} This patch prevents the user from duping the shell's private file
} descriptors (deemed to be fds 10 and above).
On Oct 10, 3:54pm, Bart Schaefer wrote:
} Subject: Re: PATCH: 3.0.6/3.1.6: Re: All sorts of file-descriptor strangen
}
} If we continue to limit the FDs on the LHS to 0-9, then we can simply
} report EBADF whenever one of the "private" FDs appears on the RHS.
Here's a tweak to Zefram's patch to really limit the descriptors to those
in use by the shell. The substantive change is only to throw in the test
that the descriptor is in the fdtable[] array, but I took the liberty of
changing some old no-space-between-`if'-and-`(' style to the style now in
wider use in the zsh code.
Index: Src/exec.c
===================================================================
RCS file: /extra/cvsroot/zsh/zsh-3.1/Src/exec.c,v
retrieving revision 1.62
diff -u -r1.62 exec.c
--- exec.c 1999/10/10 16:29:06 1.62
+++ exec.c 1999/10/10 16:29:56
@@ -1906,9 +1906,9 @@
break;
case MERGEIN:
case MERGEOUT:
- if(fn->fd2 < 10)
+ if (fn->fd2 < 10)
closemn(mfds, fn->fd2);
- if(fn->fd2 > 9) {
+ if (fn->fd2 > 9 && fdtable[fn->fd2]) {
fil = -1;
errno = EBADF;
} else {
@@ -1922,7 +1922,7 @@
closemnodes(mfds);
fixfds(save);
- if(fn->fd2 != -2)
+ if (fn->fd2 != -2)
sprintf(fdstr, "%d", fn->fd2);
zerr("%s: %e", fn->fd2 == -2 ? "coprocess" : fdstr, errno);
execerr();
--
Bart Schaefer Brass Lantern Enterprises
http://www.well.com/user/barts http://www.brasslantern.com
Messages sorted by:
Reverse Date,
Date,
Thread,
Author