*BSD News Article 30943


Return to BSD News archive

Xref: sserve comp.bugs.4bsd:2032 comp.os.386bsd.development:2194 comp.unix.bsd:14048
Newsgroups: comp.bugs.4bsd,comp.os.386bsd.development,comp.unix.bsd
Path: sserve!newshost.anu.edu.au!munnari.oz.au!bunyip.cc.uq.oz.au!harbinger.cc.monash.edu.au!msuinfo!agate!library.ucla.edu!europa.eng.gtefsd.com!MathWorks.Com!news.duke.edu!news-feed-1.peachnet.edu!paperboy.wellfleet.com!noc.near.net!atria.com!jtk
From: jtk@atria.com (John T. Kohl)
Subject: bug in libc/rcmd.c (selects only on 32 descriptors!)
Message-ID: <CqGvwM.CEG@atria.com>
Followup-To: comp.bugs.4bsd
Sender: news@atria.com
Nntp-Posting-Host: banana.atria.com
Organization: Atria Software, Inc.
Date: Fri, 27 May 1994 15:19:33 GMT
Lines: 30

If you use the rcmd() library routine, you better not have the first 32
file descriptors in use.

It calls select() with a hardcoded "number of file descriptors" argument
of 32, rather than computing it based on the sockets about which it
cares.

This bug [as evidenced by source code examination or the attached
program] is in the BSD Networking Release 2 sources, as well as binaries
shipped in DEC OSF/1 V2.0 and SunOS 4.1.3.

substitute your own hostname below, of course:

#include <fcntl.h>
#include <unistd.h>

main()
{
    register int i;

    for (i = 0; ; i++) {
	printf("round %d: opening fd %d\n", i, open("/dev/null", O_RDONLY));
	system("rsh localhost -n ls -C /tmp");
    }
}
--
John Kohl <jtk@atria.com> or <jtkohl@mit.edu>
working for but not representing:	Atria Software
---------
What are you pretending not to know?