diff options
author | Ulrich Drepper <drepper@redhat.com> | 1998-10-16 16:33:36 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 1998-10-16 16:33:36 +0000 |
commit | 9ffbb61221fd5d0ee2b7989d2e5c785efee8cc02 (patch) | |
tree | 5c9b303b79c188e0f33571a09c2975ae8eb0e3ce /sysdeps/unix/opendir.c | |
parent | 39e4f7f84ec269a2d86a060d417ceaeb21f53305 (diff) | |
download | glibc-9ffbb61221fd5d0ee2b7989d2e5c785efee8cc02.tar.gz glibc-9ffbb61221fd5d0ee2b7989d2e5c785efee8cc02.tar.xz glibc-9ffbb61221fd5d0ee2b7989d2e5c785efee8cc02.zip |
Update.
* sysdeps/unix/opendir.c: Use O_DIRECTORY if available. If not available double check to verify it's a directory. * sysdeps/unix/sysv/linux/alpha/bits/fcntl.h: Add O_DIRECTORY. * sysdeps/unix/sysv/linux/mips/bits/fcntl: Likewise. * sysdeps/unix/sysv/linux/bits/fcntl.h: Remove O_* constants which are not generally available. * sysdeps/unix/sysv/linux/i386/bits/fcntl.h: New file. * sysdeps/unix/sysv/linux/i386/setgroups.c: Add range check for values. * sysdeps/unix/sysv/linux/arm/Makefile: New file. * sysdeps/unix/sysv/linux/arm/setegid.c: New file. * sysdeps/unix/sysv/linux/arm/seteuid.c: New file. * sysdeps/unix/sysv/linux/arm/setfsgid.c: New file. * sysdeps/unix/sysv/linux/arm/setfsuid.c: New file. * sysdeps/unix/sysv/linux/arm/setgid.c: New file. * sysdeps/unix/sysv/linux/arm/setgroups.c: New file. * sysdeps/unix/sysv/linux/arm/setresgid.c: New file. * sysdeps/unix/sysv/linux/arm/setresuid.c: New file. * sysdeps/unix/sysv/linux/arm/setuid.c: New file. * sysdeps/unix/sysv/linux/i386/setegid.c: New file. * sysdeps/unix/sysv/linux/i386/seteuid.c: New file. * sysdeps/unix/sysv/linux/i386/setfsgid.c: New file. * sysdeps/unix/sysv/linux/i386/setfsuid.c: New file. * sysdeps/unix/sysv/linux/i386/setgid.c: New file. * sysdeps/unix/sysv/linux/i386/setgroups.c: New file. * sysdeps/unix/sysv/linux/i386/setresgid.c: New file. * sysdeps/unix/sysv/linux/i386/setresuid.c: New file. * sysdeps/unix/sysv/linux/i386/setuid.c: New file. * sysdeps/unix/sysv/linux/m68k/setegid.c: New file. * sysdeps/unix/sysv/linux/m68k/seteuid.c: New file. * sysdeps/unix/sysv/linux/m68k/setfsgid.c: New file. * sysdeps/unix/sysv/linux/m68k/setfsuid.c: New file. * sysdeps/unix/sysv/linux/m68k/setgid.c: New file. * sysdeps/unix/sysv/linux/m68k/setgroups.c: New file. * sysdeps/unix/sysv/linux/m68k/setresgid.c: New file. * sysdeps/unix/sysv/linux/m68k/setresuid.c: New file. * sysdeps/unix/sysv/linux/m68k/setuid.c: New file. * sysdeps/unix/sysv/linux/sparc/sparc32/setegid.c: New file. * sysdeps/unix/sysv/linux/sparc/sparc32/seteuid.c: New file. * sysdeps/unix/sysv/linux/sparc/sparc32/setfsgid.c: New file. * sysdeps/unix/sysv/linux/sparc/sparc32/setfsuid.c: New file. * sysdeps/unix/sysv/linux/sparc/sparc32/setgid.c: New file. * sysdeps/unix/sysv/linux/sparc/sparc32/setgroups.c: New file. * sysdeps/unix/sysv/linux/sparc/sparc32/setresgid.c: New file. * sysdeps/unix/sysv/linux/sparc/sparc32/setresuid.c: New file. * sysdeps/unix/sysv/linux/sparc/sparc32/setuid.c: New file. * sysdeps/unix/sysv/linux/arm/syscalls.list: Add s_setgid, s_setresuid, s_setresgid, and s_setuid. * sysdeps/unix/sysv/linux/i386/syscalls.list: Likewise. * sysdeps/unix/sysv/linux/m68k/syscalls.list: Likewise. * sysdeps/unix/sysv/linux/sparc/sparc32/syscalls.list: Likewise. * sysdeps/unix/sysv/linux/i386/Makefile [subdir=misc] (sysdep_routines): Add setfsgid, setfsuid, setresgid, and setresuid. * sysdeps/unix/sysv/linux/m68k/Makefile: Likewise. * sysdeps/unix/sysv/linux/sparc/sparc32/Makefile: Likewise. 1998-10-16 Ulrich Drepper <drepper@cygnus.com> * iconv/skeleton.c: Include ELF header only of STATIC_GCONV is not
Diffstat (limited to 'sysdeps/unix/opendir.c')
-rw-r--r-- | sysdeps/unix/opendir.c | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/sysdeps/unix/opendir.c b/sysdeps/unix/opendir.c index 77f2a0a490..657ad176a8 100644 --- a/sysdeps/unix/opendir.c +++ b/sysdeps/unix/opendir.c @@ -29,6 +29,30 @@ #include <dirstream.h> + +/* We want to be really safe the file we opened is a directory. Some systems + have support for this, others don't. */ +#ifdef O_DIRECTORY +# define OPENDIR(NAME) \ + do { \ + fd = __open (NAME, O_RDONLY|O_NDELAY|O_DIRECTORY); \ + if (fd < 0) \ + return NULL; \ + } while (0) +#else +# define OPENDIR(NAME) \ + do { \ + fd = __open (NAME, O_RDONLY|O_NDELAY); \ + if (fd < 0 || __fstat (fd, &statbuf) < 0 || ! S_ISDIR (statbuf.st_mode)) \ + { \ + if (fd >= 0) \ + __close (fd); \ + return NULL; \ + } \ + } while (0) +#endif + + /* Open a directory stream on NAME. */ DIR * __opendir (const char *name) @@ -58,9 +82,7 @@ __opendir (const char *name) return NULL; } - fd = __open (name, O_RDONLY|O_NDELAY); - if (fd < 0) - return NULL; + OPENDIR (name); if (__fcntl (fd, F_SETFD, FD_CLOEXEC) < 0) goto lose; |