diff options
author | Roland McGrath <roland@gnu.org> | 1999-10-14 01:29:18 +0000 |
---|---|---|
committer | Roland McGrath <roland@gnu.org> | 1999-10-14 01:29:18 +0000 |
commit | 0fea802472bed2dcb1c2fa443dbf9061c4efa555 (patch) | |
tree | b02639644c77a05e6a1c85ce641552d2325511bb | |
parent | bb5ab6161caedaadc7744d73e69da4a7808a498e (diff) |
1999-10-13 Roland McGrath <roland@baalperazim.frob.com>
* io-pathconf.c (diskfs_S_io_pathconf): Cap diskfs_name_max to size
representable in struct dirent.d_namlen.
(diskfs_S_io_pathconf): Always return 1 for _PC_NO_TRUNC, since we
always constrain diskfs_name_max.
-rw-r--r-- | libdiskfs/io-pathconf.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/libdiskfs/io-pathconf.c b/libdiskfs/io-pathconf.c index 8c86cabf..b851f9b1 100644 --- a/libdiskfs/io-pathconf.c +++ b/libdiskfs/io-pathconf.c @@ -18,6 +18,8 @@ #include <unistd.h> #include "priv.h" #include "io_S.h" +#include <dirent.h> +#include <limits.h> /* Implement io_pathconf as described in <hurd/io.defs>. */ kern_return_t @@ -43,12 +45,16 @@ diskfs_S_io_pathconf (struct protid *cred, break; case _PC_NAME_MAX: - /* <hurd/hurd_types.defs> string_t constrains the upper bound. */ - *value = diskfs_name_max > 1023 ? 1023 : diskfs_name_max; + /* <hurd/hurd_types.defs> string_t constrains the upper bound. + The `struct dirent' format defined by libc further contrains it. */ +#define D_NAMLEN_MAX (UCHAR_MAX * sizeof (((struct dirent *) 0)->d_namlen)) + if (diskfs_name_max > D_NAMLEN_MAX || diskfs_name_max < 0) + diskfs_name_max = D_NAMLEN_MAX; + *value = diskfs_name_max; break; case _PC_NO_TRUNC: /* enforced in diskfs_lookup */ - *value = diskfs_name_max >= 0; + *value = 1; /* diskfs_name_max >= 0; */ /* see above */ break; case _PC_CHOWN_RESTRICTED: |