From: Ulrich Drepper Date: Sat, 22 Jun 2002 05:58:14 +0000 (+0000) Subject: Update. X-Git-Tag: cvs/glibc-2-3~703 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=05ae4d6ad95c139aacbc16ed6b50a24678d01bf8;p=platform%2Fupstream%2Fglibc.git Update. 2002-06-21 Ulrich Drepper * sysdeps/unix/sysv/linux/getdents.c [__ASSUME_GETDENTS64_SYSCALL] (__GETDENTS): Check for failed getdents64 syscall. * dirent/Makefile (tests): Add bug-readdir1. * dirent/bug-readdir1.c: New file. --- diff --git a/ChangeLog b/ChangeLog index c0bfdf7..e54e640 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2002-06-21 Ulrich Drepper + + * sysdeps/unix/sysv/linux/getdents.c [__ASSUME_GETDENTS64_SYSCALL] + (__GETDENTS): Check for failed getdents64 syscall. + * dirent/Makefile (tests): Add bug-readdir1. + * dirent/bug-readdir1.c: New file. + 2002-06-17 Jakub Jelinek * elf/dl-lookup.c (_dl_debug_bindings): Use type_class 4 for TLS diff --git a/dirent/Makefile b/dirent/Makefile index a88a85b..4811411 100644 --- a/dirent/Makefile +++ b/dirent/Makefile @@ -1,4 +1,4 @@ -# Copyright (C) 1991,92,93,94,95,96,97,98,99,2000 Free Software Foundation, Inc. +# Copyright (C) 1991-2000, 2002 Free Software Foundation, Inc. # This file is part of the GNU C Library. # The GNU C Library is free software; you can redistribute it and/or @@ -28,7 +28,7 @@ routines := opendir closedir readdir readdir_r rewinddir \ alphasort64 versionsort64 distribute := dirstream.h -tests := list tst-seekdir opendir-tst1 +tests := list tst-seekdir opendir-tst1 bug-readdir1 include ../Rules diff --git a/dirent/bug-readdir1.c b/dirent/bug-readdir1.c new file mode 100644 index 0000000..f9c609c --- /dev/null +++ b/dirent/bug-readdir1.c @@ -0,0 +1,36 @@ +#include +#include +#include +#include +#include +#include + + +int +main (void) +{ + DIR *dirp; + struct dirent* ent; + + /* open a dir stream */ + dirp = opendir ("/tmp"); + if (dirp == NULL) + { + if (errno == ENOENT) + exit (0); + + perror ("opendir"); + exit (1); + } + + /* close the dir stream, making it invalid */ + if (closedir (dirp)) + { + perror ("closedir"); + exit (1); + } + + ent = readdir (dirp); + + return ent != NULL || errno != EBADF; +} diff --git a/sysdeps/unix/sysv/linux/getdents.c b/sysdeps/unix/sysv/linux/getdents.c index 5d79a3a..6dc9d71 100644 --- a/sysdeps/unix/sysv/linux/getdents.c +++ b/sysdeps/unix/sysv/linux/getdents.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1993,95,96,97,98,99,2000,2001 Free Software Foundation, Inc. +/* Copyright (C) 1993, 1995-2002 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -129,6 +129,10 @@ __GETDENTS (int fd, char *buf, size_t nbytes) const size_t size_diff = (offsetof (struct kernel_dirent64, d_name) - offsetof (DIRENT_TYPE, d_name)); + /* Return the error if encountered. */ + if (retval == -1) + return -1; + /* If the structure returned by the kernel is identical to what we need, don't do any conversions. */ if (offsetof (DIRENT_TYPE, d_name)