summaryrefslogtreecommitdiff
path: root/dirent
diff options
context:
space:
mode:
Diffstat (limited to 'dirent')
-rw-r--r--dirent/Makefile4
-rw-r--r--dirent/bug-readdir1.c36
2 files changed, 38 insertions, 2 deletions
diff --git a/dirent/Makefile b/dirent/Makefile
index a88a85b63e..481141136b 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 0000000000..f9c609cc98
--- /dev/null
+++ b/dirent/bug-readdir1.c
@@ -0,0 +1,36 @@
+#include <dirent.h>
+#include <errno.h>
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+
+
+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;
+}