From bb7cb04962300ad0fd6c0b928fc47317699de491 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Thu, 6 Jan 2011 14:49:21 +0000 Subject: [PATCH 2/3] dirent_buf_size: always assume that readdir_r needs at least NAME_MAX bytes fpathconf() can apparently return 0 for the max length of a filename, at least on zfs-on-fuse. Sigh. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=15922 --- dbus/dbus-sysdeps-util-unix.c | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-) diff --git a/dbus/dbus-sysdeps-util-unix.c b/dbus/dbus-sysdeps-util-unix.c index c01b2a7..60a38d5 100644 --- a/dbus/dbus-sysdeps-util-unix.c +++ b/dbus/dbus-sysdeps-util-unix.c @@ -647,6 +647,14 @@ dirent_buf_size(DIR * dirp, size_t *size) # endif # endif +#if defined(NAME_MAX) + /* Don't trust returns from fpathconf less than NAME_MAX. According to + * https://bugs.freedesktop.org/show_bug.cgi?id=15922, zfs-on-fuse + * incorrectly returns 0. */ + if (name_max < NAME_MAX) + name_max = NAME_MAX; +#endif + /* Don't trust values of NAME_MAX less than 255. According to * "readdir_r considered harmful", HP-UX incorrectly defines it smaller. */ if (name_max < 255) -- 1.7.2.3