From: "Bart Schaefer" <schaefer@candle.brasslantern.com>
To: zsh-workers@sunsite.auc.dk
Subject: PATCH: Re: PATCH: no more fd mixups
Date: Sun, 10 Oct 1999 16:39:02 +0000 [thread overview]
Message-ID: <991010163903.ZM2414@candle.brasslantern.com> (raw)
In-Reply-To: <E11aK4j-0006RV-00@crucigera.fysh.org>
In-Reply-To: <991010155440.ZM2271@candle.brasslantern.com>
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
next prev parent reply other threads:[~1999-10-10 16:39 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-10-05 9:45 All sorts of file-descriptor strangeness Bart Schaefer
1999-10-10 8:27 ` PATCH: 3.0.6/3.1.6: " Bart Schaefer
1999-10-10 13:35 ` Zefram
1999-10-10 15:54 ` Bart Schaefer
1999-10-10 16:39 ` Bart Schaefer [this message]
1999-10-10 17:53 ` PATCH: Re: PATCH: no more fd mixups Zefram
1999-10-10 21:11 ` PATCH: 3.0.6/3.1.6: Re: All sorts of file-descriptor strangeness Bart Schaefer
1999-10-11 8:12 ` Zefram
1999-10-10 17:41 ` Zefram
1999-10-10 14:35 PATCH: no more fd mixups Zefram
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=991010163903.ZM2414@candle.brasslantern.com \
--to=schaefer@candle.brasslantern.com \
--cc=zsh-workers@sunsite.auc.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).