This message is in MIME format. The first part should be readable text,
while the remaining parts are likely unreadable without MIME-aware tools.

--0-1238618088-1136435035=:5873
Content-Type: TEXT/PLAIN; charset=X-UNKNOWN
Content-Transfer-Encoding: QUOTED-PRINTABLE

On Thu, 5 Jan 2006, Fr=E9d=E9ric Olivi=E9 wrote:

> Damien Miller a =E9crit :
> > Please don't send HTML mail.
> > =20

> Sorry. Hope this is better (I asked Thunderbird to send text-only on this
> list).
> >=20
> > Please try this diff:
> > =20

> It can't work. The "continue" statement causes "dupfd++" never to be eval=

uated
> thus resulting in an infinite loop.


This is better:

Index: misc.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3 D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3 D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3 D
RCS file: /cvs/src/usr.bin/ssh/misc.c,v
retrieving revision 1.40
diff -u -p -r1.40 misc.c
--- misc.c=092 Jan 2006 07:53:44 -0000=091.40
+++ misc.c=095 Jan 2006 04:23:44 -0000
@@ -601,18 +601,20 @@ tun_open(int tun, int mode)
void
sanitise_stdfd(void)
{
-=09int nullfd;
+=09int nullfd, dupfd;
=20
-=09if ((nullfd =3D open(_PATH_DEVNULL, O_RDWR)) =3D=3D -1) {
+=09if ((nullfd =3D dupfd =3D open(_PATH_DEVNULL, O_RDWR)) =3D=3D -1) {
=09=09fprintf(stderr, "Couldn't open /dev/null: %s", strerror(errno));
=09=09exit(1);
=09}
-=09while (nullfd < 2) {
-=09=09if (dup2(nullfd, nullfd + 1) =3D=3D -1) {
+=09while (++dupfd <=3D 2) {
+=09=09/* Only clobber closed fds */
+=09=09if (fcntl(dupfd, F_GETFL, 0) >=3D 0)
+=09=09=09continue;
+=09=09if (dup2(nullfd, dupfd) =3D=3D -1) {
=09=09=09fprintf(stderr, "dup2: %s", strerror(errno));
=09=09=09exit(1);
=09=09}
-=09=09nullfd++;
=09}
=09if (nullfd > 2)
=09=09close(nullfd);
--0-1238618088-1136435035=:5873
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
openssh-unix-dev mailing list
openssh-unix-dev@mindrot.org
http://www.mindrot.org/mailman/listi...enssh-unix-dev

--0-1238618088-1136435035=:5873--