Thread View: comp.bugs.sys5
4 messages
4 total messages
Started by T. William Wells
Sat, 16 Sep 1989 02:52
Bug in closedir
Author: T. William Wells
Date: Sat, 16 Sep 1989 02:52
Date: Sat, 16 Sep 1989 02:52
10 lines
718 bytes
718 bytes
Closedir, on my Microport SysV/386 3.0e, frees the DIR structure
and then closes the file using the first field of that structure.
If you are using -lmalloc, which trashes the freed data, you are
going to be unpleasantly surprised.
No doubt this bogosity is present throughout the library.
---
Bill { uunet | novavax | ankh | sunvice } !twwells!bill
bill@twwells.com
Re: Bug in closedir
Author: Doug Gwyn
Date: Sat, 16 Sep 1989 23:20
Date: Sat, 16 Sep 1989 23:20
48 lines
1647 bytes
1647 bytes
In article <1989Sep16.025206.5915@twwells.com> bill@twwells.com (T. William Wells) writes:
>Closedir, on my Microport SysV/386 3.0e, frees the DIR structure
>and then closes the file using the first field of that structure.
>... No doubt this bogosity is present throughout the library.
I don't know about the last statement. I suspect Microport is using AT&T's
closedir() implementation, the SVR3.0 version of which was derived from one
of my earlier public-domain implementations. R. Salz pointed out the bug
to me and I fixed it long ago; here is my current version:
/*
closedir -- close a directory stream
last edit: 11-Nov-1988 D A Gwyn
*/
#include <sys/errno.h>
#include <sys/types.h>
#include <dirent.h>
typedef char *pointer; /* (void *) if you have it */
extern void free();
extern int close();
extern int errno;
#ifndef NULL
#define NULL 0
#endif
int
closedir( dirp )
register DIR *dirp; /* stream from opendir() */
{
register int fd;
if ( dirp == NULL || dirp->dd_buf == NULL )
{
errno = EFAULT;
return -1; /* invalid pointer */
}
fd = dirp->dd_fd; /* bug fix thanks to R. Salz */
free( (pointer)dirp->dd_buf );
free( (pointer)dirp );
return close( fd );
}
Re: Bug in closedir
Author: T. William Wells
Date: Sun, 17 Sep 1989 10:32
Date: Sun, 17 Sep 1989 10:32
17 lines
1281 bytes
1281 bytes
In article <11081@smoke.BRL.MIL> gwyn@brl.arpa (Doug Gwyn) writes:
: In article <1989Sep16.025206.5915@twwells.com> bill@twwells.com (T. William Wells) writes:
: >Closedir, on my Microport SysV/386 3.0e, frees the DIR structure
: >and then closes the file using the first field of that structure.
: >... No doubt this bogosity is present throughout the library.
:
: I don't know about the last statement. I suspect Microport is using AT&T's
: closedir() implementation, the SVR3.0 version of which was derived from one
: of my earlier public-domain implementations. R. Salz pointed out the bug
: to me and I fixed it long ago; here is my current version:
The closedir on my system consists of just the three calls: two frees
and a close. There is no error checking of any kind.
---
Bill { uunet | novavax | ankh | sunvice } !twwells!bill
bill@twwells.com
Re: Bug in closedir
Author: Guy Harris
Date: Mon, 18 Sep 1989 18:05
Date: Mon, 18 Sep 1989 18:05
16 lines
1342 bytes
1342 bytes
>: I don't know about the last statement. I suspect Microport is using AT&T's >: closedir() implementation, the SVR3.0 version of which was derived from one >: of my earlier public-domain implementations. R. Salz pointed out the bug >: to me and I fixed it long ago; here is my current version: > >The closedir on my system consists of just the three calls: two frees >and a close. There is no error checking of any kind. The "closedir" in AT&T's S5R3.[01] implementation consists of just the three calls: two frees and a close. There is no error checking of any kind, unless you count the fact that the return value of the "close" is the return value of "closedir".... In other words, your observation about the contents of your system's "closedir" is not at all inconsistent with Doug's hypothesis that Microport is using AT&T's standard "closedir".
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads