about summary refs log tree commit diff
path: root/sysdeps
diff options
context:
space:
mode:
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>2020-04-14 17:41:56 -0300
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>2020-05-27 11:55:00 -0300
commitef3330fde49502c342cf0541cd3c283a3c4a79cd (patch)
treed65866211082bde5585bdeafa668908c9f21e38f /sysdeps
parent415d0b0b3f1649d688f18c34bcfb16ad72e337ce (diff)
downloadglibc-ef3330fde49502c342cf0541cd3c283a3c4a79cd.tar.gz
glibc-ef3330fde49502c342cf0541cd3c283a3c4a79cd.tar.xz
glibc-ef3330fde49502c342cf0541cd3c283a3c4a79cd.zip
linux: Use internal DIR locks when accessing filepos on telldir
Since it might change during a readdir call.

Checked on x86_64-linux-gnu and i686-linux-gnu.
Diffstat (limited to 'sysdeps')
-rw-r--r--sysdeps/posix/telldir.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/sysdeps/posix/telldir.c b/sysdeps/posix/telldir.c
index 1bb822c807..57d435ed21 100644
--- a/sysdeps/posix/telldir.c
+++ b/sysdeps/posix/telldir.c
@@ -23,5 +23,11 @@
 long int
 telldir (DIR *dirp)
 {
-  return dirp->filepos;
+  long int ret;
+
+  __libc_lock_lock (dirp->lock);
+  ret = dirp->filepos;
+  __libc_lock_unlock (dirp->lock);
+
+  return ret;
 }