about summary refs log tree commit diff
path: root/sysdeps/unix/sysv/linux/i386/glob64.c
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2016-05-04 12:09:35 +0200
committerFlorian Weimer <fweimer@redhat.com>2016-05-04 12:09:35 +0200
commit5171f3079f2cc53e0548fc4967361f4d1ce9d7ea (patch)
tree3d23357f6313d2d00017bf641fd61a3dc9459105 /sysdeps/unix/sysv/linux/i386/glob64.c
parent2faba597eca15666ce46cc721041747e96c8b942 (diff)
downloadglibc-5171f3079f2cc53e0548fc4967361f4d1ce9d7ea.tar.gz
glibc-5171f3079f2cc53e0548fc4967361f4d1ce9d7ea.tar.xz
glibc-5171f3079f2cc53e0548fc4967361f4d1ce9d7ea.zip
CVE-2016-1234: glob: Do not copy d_name field of struct dirent [BZ #19779]
Instead, we store the data we need from the return value of
readdir in an object of the new type struct readdir_result.
This type is independent of the layout of struct dirent.
Diffstat (limited to 'sysdeps/unix/sysv/linux/i386/glob64.c')
-rw-r--r--sysdeps/unix/sysv/linux/i386/glob64.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/sysdeps/unix/sysv/linux/i386/glob64.c b/sysdeps/unix/sysv/linux/i386/glob64.c
index b4fcd1a73c..802c957d6c 100644
--- a/sysdeps/unix/sysv/linux/i386/glob64.c
+++ b/sysdeps/unix/sysv/linux/i386/glob64.c
@@ -1,3 +1,21 @@
+/* Two glob variants with 64-bit support, for dirent64 and __olddirent64.
+   Copyright (C) 1998-2016 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
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
 #include <dirent.h>
 #include <glob.h>
 #include <sys/stat.h>
@@ -38,11 +56,15 @@ int __old_glob64 (const char *__pattern, int __flags,
 
 #undef dirent
 #define dirent __old_dirent64
+#undef GL_READDIR
+# define GL_READDIR(pglob, stream) \
+  ((struct __old_dirent64 *) (pglob)->gl_readdir (stream))
 #undef __readdir
 #define __readdir(dirp) __old_readdir64 (dirp)
 #undef glob
 #define glob(pattern, flags, errfunc, pglob) \
   __old_glob64 (pattern, flags, errfunc, pglob)
+#define convert_dirent __old_convert_dirent
 #define glob_in_dir __old_glob_in_dir
 #define GLOB_ATTRIBUTE attribute_compat_text_section