~ubuntu-branches/ubuntu/natty/eglibc/natty-security

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
disable usage of unimplemented *at functions
revert to previous behaviour, inspired by
	http://sourceware.org/ml/glibc-cvs/2006-q1/msg00636.html
	http://sources.redhat.com/cgi-bin/cvsweb.cgi/libc/io/ftw.c.diff?cvsroot=glibc&r1=1.50&r2=1.51

	http://sourceware.org/cgi-bin/cvsweb.cgi/libc/posix/glob.c.diff?cvsroot=glibc&r1=1.77&r2=1.78

---
 io/ftw.c     |    6 ++++++
 posix/glob.c |   31 +++----------------------------
 2 files changed, 9 insertions(+), 28 deletions(-)

--- a/io/ftw.c
+++ b/io/ftw.c
@@ -338,6 +338,7 @@
     {
       assert (data->dirstreams[data->actdir] == NULL);
 
+#if 0
       if (dfdp != NULL && *dfdp != -1)
 	{
 	  int fd = openat64_not_cancel_3 (*dfdp, data->dirbuf + data->ftw.base,
@@ -347,6 +348,7 @@
 	    close_not_cancel_no_status (fd);
 	}
       else
+#endif      
 	{
 	  const char *name;
 
@@ -410,10 +412,12 @@
   *((char *) __mempcpy (data->dirbuf + data->ftw.base, name, namlen)) = '\0';
 
   int statres;
+#if 0  
   if (dir->streamfd != -1)
     statres = FXSTATAT (_STAT_VER, dir->streamfd, name, &st,
 			(data->flags & FTW_PHYS) ? AT_SYMLINK_NOFOLLOW : 0);
   else
+#endif  
     {
       if ((data->flags & FTW_CHDIR) == 0)
 	name = data->dirbuf;
@@ -433,10 +437,12 @@
 	flag = FTW_SLN;
       else
 	{
+#if 0	
 	  if (dir->streamfd != -1)
 	    statres = FXSTATAT (_STAT_VER, dir->streamfd, name, &st,
 				AT_SYMLINK_NOFOLLOW);
 	  else
+#endif	  
 	    statres = LXSTAT (_STAT_VER, name, &st);
 	  if (statres == 0 && S_ISLNK (st.st_mode))
 	    flag = FTW_SLN;
--- a/posix/glob.c
+++ b/posix/glob.c
@@ -1222,42 +1222,21 @@
    allocated with alloca to be recycled.  */
 #if !defined _LIBC || !defined GLOB_ONLY_P
 static int
-__attribute_noinline__
-link_exists2_p (const char *dir, size_t dirlen, const char *fname,
-	       glob_t *pglob
-# ifndef _LIBC
-		, int flags
-# endif
-		)
+link_exists_p (const char *dir, size_t dirlen, const char *fname,
+	       glob_t *pglob, int flags)
 {
   size_t fnamelen = strlen (fname);
   char *fullname = (char *) __alloca (dirlen + 1 + fnamelen + 1);
   struct stat st;
-# ifndef _LIBC
   struct_stat64 st64;
-# endif
 
   mempcpy (mempcpy (mempcpy (fullname, dir, dirlen), "/", 1),
 	   fname, fnamelen + 1);
 
-# ifdef _LIBC
-  return (*pglob->gl_stat) (fullname, &st) == 0;
-# else
   return ((__builtin_expect (flags & GLOB_ALTDIRFUNC, 0)
 	   ? (*pglob->gl_stat) (fullname, &st)
 	   : __stat64 (fullname, &st64)) == 0);
-# endif
 }
-# ifdef _LIBC
-#  define link_exists_p(dfd, dirname, dirnamelen, fname, pglob, flags) \
-  (__builtin_expect (flags & GLOB_ALTDIRFUNC, 0)			      \
-   ? link_exists2_p (dirname, dirnamelen, fname, pglob)			      \
-   : ({ struct stat64 st64;						      \
-       __fxstatat64 (_STAT_VER, dfd, fname, &st64, 0) == 0; }))
-# else
-#  define link_exists_p(dfd, dirname, dirnamelen, fname, pglob, flags) \
-  link_exists2_p (dirname, dirnamelen, fname, pglob, flags)
-# endif
 #endif
 
 
@@ -1332,10 +1311,6 @@
 	}
       else
 	{
-#ifdef _LIBC
-	  int dfd = (__builtin_expect (flags & GLOB_ALTDIRFUNC, 0)
-		     ? -1 : dirfd ((DIR *) stream));
-#endif
 	  int fnm_flags = ((!(flags & GLOB_PERIOD) ? FNM_PERIOD : 0)
 			   | ((flags & GLOB_NOESCAPE) ? FNM_NOESCAPE : 0)
 #if defined _AMIGA || defined VMS
@@ -1394,7 +1369,7 @@
 		  /* If the file we found is a symlink we have to
 		     make sure the target file exists.  */
 		  if (!DIRENT_MIGHT_BE_SYMLINK (d)
-		      || link_exists_p (dfd, directory, dirlen, name, pglob,
+		      || link_exists_p (directory, dirlen, name, pglob,
 					flags))
 		    {
 		      if (cur == names->count)