This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] posix: Add compat glob symbol to not follow dangling symbols



On 15/09/2017 17:01, Joseph Myers wrote:
> On Fri, 15 Sep 2017, Adhemerval Zanella wrote:
> 
>> This works as expected with the patch applied.  Since it is for generic
>> ABI, default compat symbols are added with override for Linux due LFS.
>> Now we have two compat symbols for glob on Linux:
>>
>>   1. sysdeps/unix/sysv/linux/oldglob.c which implements glob64 with
>>      the old dirent layout.  For this implementation I also set it to
>>      follow the no dangling symlinks which is the safest path.
>>
>>   2. sysdeps/unix/sysv/linux/glob{64}-lstat-compat.c which implements
>>      the compat symbol for dangling symlinks.  As for generic glob,
>>      the implementation uses XSTAT_IS_XSTAT64 to define whether
>>      both __glob_lstat_compat and __glob64_lstat_compat should be
>>      different implementations.  For archictures that define
>>      XSTAT_IS_XSTAT64, __glob_lstat_compat is aliased to
>>      __glob64_lstat_compat.
> 
> 3. sysdeps/unix/sysv/linux/alpha/oldglob.c has another compat version for 
> a different glob_t layout.  Presumably that one also should ignore 
> gl_lstat.

For alpha old compat symbol I think setting gl_lstat to gl_stat would
be suffice to follow old semantic:

diff --git a/sysdeps/unix/sysv/linux/alpha/oldglob.c b/sysdeps/unix/sysv/linux/alpha/oldglob.c
index 988c92b..b54624c 100644
--- a/sysdeps/unix/sysv/linux/alpha/oldglob.c
+++ b/sysdeps/unix/sysv/linux/alpha/oldglob.c
@@ -59,7 +59,9 @@ __old_glob (const char *pattern, int flags,
   correct.gl_closedir = pglob->gl_closedir;
   correct.gl_readdir = pglob->gl_readdir;
   correct.gl_opendir = pglob->gl_opendir;
-  correct.gl_lstat = pglob->gl_lstat;
+  /* Set gl_lstat and gl_stat for both gl_stat for compatibility with old
+     implementation that did not follow dangling symlinks.  */
+  correct.gl_lstat = pglob->gl_stat;
   correct.gl_stat = pglob->gl_stat;
 
   result = glob (pattern, flags, errfunc, &correct);
@@ -72,7 +74,7 @@ __old_glob (const char *pattern, int flags,
   pglob->gl_closedir = correct.gl_closedir;
   pglob->gl_readdir = correct.gl_readdir;
   pglob->gl_opendir = correct.gl_opendir;
-  pglob->gl_lstat = correct.gl_lstat;
+  /* Only need to restore gl_stat.  */
   pglob->gl_stat = correct.gl_stat;
 
   return result;


I will incorporate it to my initial patch.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]