* libc/posix/closedir.c: Fix use after free.
Remove useless test dd_fd != -1 * libc/posix/readdir.c: Remove useless test dd_fd == -1 * libc/posix/readdir_r.c: Ditto.
This commit is contained in:
parent
700a3783ee
commit
ff125797e3
|
@ -1,3 +1,10 @@
|
|||
2013-11-19 Terraneo Federico <fede.tft@hotmail.it>
|
||||
|
||||
* libc/posix/closedir.c: Fix use after free.
|
||||
Remove useless test dd_fd != -1
|
||||
* libc/posix/readdir.c: Remove useless test dd_fd == -1
|
||||
* libc/posix/readdir_r.c: Ditto.
|
||||
|
||||
2013-11-18 Sahil Patnayakuni <sahilp@oarcorp.com>
|
||||
|
||||
* libc/include/stdio.h, libc/machine/powerpc/vfscanf.c,
|
||||
|
|
|
@ -52,25 +52,19 @@ int
|
|||
_DEFUN(closedir, (dirp),
|
||||
register DIR *dirp)
|
||||
{
|
||||
int fd, rc;
|
||||
int rc;
|
||||
|
||||
#ifdef HAVE_DD_LOCK
|
||||
__lock_acquire_recursive(dirp->dd_lock);
|
||||
#endif
|
||||
rc = 0;
|
||||
fd = dirp->dd_fd;
|
||||
if (fd != -1) {
|
||||
dirp->dd_fd = -1;
|
||||
dirp->dd_loc = 0;
|
||||
(void)free((void *)dirp->dd_buf);
|
||||
(void)free((void *)dirp);
|
||||
rc = close(fd);
|
||||
_cleanupdir(dirp);
|
||||
}
|
||||
rc = close(dirp->dd_fd);
|
||||
_cleanupdir(dirp);
|
||||
free((void *)dirp->dd_buf);
|
||||
#ifdef HAVE_DD_LOCK
|
||||
__lock_release_recursive(dirp->dd_lock);
|
||||
__lock_close_recursive(dirp->dd_lock);
|
||||
#endif
|
||||
free((void *)dirp);
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
|
|
@ -53,9 +53,6 @@ _DEFUN(readdir, (dirp),
|
|||
#ifdef HAVE_DD_LOCK
|
||||
__lock_acquire_recursive(dirp->dd_lock);
|
||||
#endif
|
||||
|
||||
if (dirp->dd_fd == -1)
|
||||
return NULL;
|
||||
|
||||
for (;;) {
|
||||
if (dirp->dd_loc == 0) {
|
||||
|
|
|
@ -60,11 +60,6 @@ struct dirent *tmpdp;
|
|||
#ifdef HAVE_DD_LOCK
|
||||
__lock_acquire_recursive(dirp->dd_lock);
|
||||
#endif
|
||||
|
||||
if (dirp->dd_fd == -1) {
|
||||
*dpp = NULL;
|
||||
return errno = EBADF;
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
if (dirp->dd_loc == 0) {
|
||||
|
|
Loading…
Reference in New Issue