OSDN Git Service

remove erroneous SYMLINK_MAX definition from limits.h, pathconf
authorRich Felker <dalias@aerifal.cx>
Tue, 21 Aug 2018 00:20:31 +0000 (20:20 -0400)
committerRich Felker <dalias@aerifal.cx>
Tue, 21 Aug 2018 00:33:19 +0000 (20:33 -0400)
POSIX requires the symlink function to fail with ENAMETOOLONG if the
link contents to be written exceed SYMLINK_MAX in length, but neither
Linux nor our syscall wrapper code enforce this. the value 255 for
SYMLINK_MAX is not meaningful and does not seem to have been motivated
by anything except perhaps a wrong assumption that a definition was
mandatory. it has been present (though moving through bits to
top-level limits.h) since the beginning of the project history.

[f]pathconf is entitled to return -1 as the limit for conf names for
which there is no hard limit, with the usual POSIX note that an
indefinite limit does not imply an infinite limit. in principle we
might should report a limit for filesystems that impose one, but such
functionality is not currently present for any of the pathconf limits,
and adding it is beyond the scope of fixing the incorrect limit.

include/limits.h
src/conf/fpathconf.c

index 9cb5426..ab163a2 100644 (file)
@@ -42,7 +42,6 @@
 #define PIPE_BUF 4096
 #define FILESIZEBITS 64
 #define NAME_MAX 255
-#define SYMLINK_MAX 255
 #define PATH_MAX 4096
 #define NGROUPS_MAX 32
 #define ARG_MAX 131072
index 8eb037e..e6aca5c 100644 (file)
@@ -24,7 +24,7 @@ long fpathconf(int fd, int name)
                [_PC_REC_MIN_XFER_SIZE] = 4096,
                [_PC_REC_XFER_ALIGN] = 4096,
                [_PC_ALLOC_SIZE_MIN] = 4096,
-               [_PC_SYMLINK_MAX] = SYMLINK_MAX,
+               [_PC_SYMLINK_MAX] = -1,
                [_PC_2_SYMLINKS] = 1
        };
        if (name >= sizeof(values)/sizeof(values[0])) {