From 0fea802472bed2dcb1c2fa443dbf9061c4efa555 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Thu, 14 Oct 1999 01:29:18 +0000 Subject: 1999-10-13 Roland McGrath * 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. --- libdiskfs/io-pathconf.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'libdiskfs/io-pathconf.c') 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 #include "priv.h" #include "io_S.h" +#include +#include /* Implement io_pathconf as described in . */ kern_return_t @@ -43,12 +45,16 @@ diskfs_S_io_pathconf (struct protid *cred, break; case _PC_NAME_MAX: - /* string_t constrains the upper bound. */ - *value = diskfs_name_max > 1023 ? 1023 : diskfs_name_max; + /* 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: -- cgit v1.2.3