From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from munnari.oz.au ([128.250.1.21]) by archone.tamu.edu with SMTP id <22543>; Sun, 30 Jun 1991 09:24:47 -0500 Received: from basser.cs.su.oz by munnari.oz.au with SunIII (5.64+1.3.1+0.50) id AA05592; Mon, 1 Jul 1991 00:24:21 +1000 (from dhog@basser.cs.su.OZ.AU) Date: Sun, 30 Jun 1991 07:21:06 -0500 From: David Hogan To: The Rc Mailing List Subject: Rc globbing bug, with fix Message-Id: <9106302221.21747.rc.babab@cs.su.oz.au> X-Face: 'B4A5xr.&(*ne}8,IvVj2^PS"?tx:^[d%W3qSI-pYcRS4#L]H1avGI62"ufA.",n + #include #include "rc.h" #include "glob.h" #include "glom.h" *************** *** 78,88 **** --- 79,94 ---- List *top, *r; DIR *dirp; struct dirent *dp; + struct stat stbuf; /* prototypes for XXXdir functions. comment out if necessary */ extern DIR *opendir(const char *); extern struct dirent *readdir(DIR *); extern int closedir(DIR *); + /* First check that d is a directory -- on many systems, opendir + will succeed even if it isn't -- to our great peril! */ + if (stat(d, &stbuf) < 0 || (stbuf.st_mode & S_IFMT) != S_IFDIR) + return NULL; if ((dirp = opendir(d)) == NULL) return NULL;