[glib/wip/oholy/fix-trash-symlink: 110/110] glocalfile: Use MAXSYMLINKS when following symlinks
- From: Ondrej Holy <oholy src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/wip/oholy/fix-trash-symlink: 110/110] glocalfile: Use MAXSYMLINKS when following symlinks
- Date: Wed, 17 Oct 2018 11:26:26 +0000 (UTC)
commit 1ff17152ce69a61ec4b937fdda96ba6b880bcc01
Author: Ondrej Holy <oholy redhat com>
Date: Fri Sep 21 16:12:51 2018 +0200
glocalfile: Use MAXSYMLINKS when following symlinks
Currently, readlink() is used only 12 times when expanding symlinks.
However, kernel uses 40 for this purpose and it is defined as MAXSYMLINKS.
Use that constant if available, or 40. See:
https://github.com/torvalds/linux/include/linux/namei.h.
gio/glocalfile.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
---
diff --git a/gio/glocalfile.c b/gio/glocalfile.c
index a547bcda0..064755981 100644
--- a/gio/glocalfile.c
+++ b/gio/glocalfile.c
@@ -1610,7 +1610,15 @@ expand_symlinks (const char *path,
}
num_recursions++;
- if (num_recursions > 12)
+
+#ifdef MAXSYMLINKS
+ if (num_recursions > MAXSYMLINKS)
+#else
+ /* 40 is used in kernel sources currently:
+ * https://github.com/torvalds/linux/include/linux/namei.h
+ */
+ if (num_recursions > 40)
+#endif
{
g_free (target);
return NULL;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]