# HG changeset patch # User bpb # Date 1533325518 25200 # Node ID 13e2e64337be4721ecf6dc16a0dac7a195b5d1c4 # Parent acf02a6f369ea670d6cc09ddabf69317a7c454a9 8186766: UnixNativeDispatcher::readlink() may truncate overlong paths Reviewed-by: alanb diff -r acf02a6f369e -r 13e2e64337be src/java.base/unix/native/libnio/fs/UnixNativeDispatcher.c --- a/src/java.base/unix/native/libnio/fs/UnixNativeDispatcher.c Fri Aug 03 09:42:57 2018 -0700 +++ b/src/java.base/unix/native/libnio/fs/UnixNativeDispatcher.c Fri Aug 03 12:45:18 2018 -0700 @@ -875,7 +875,10 @@ } else { jsize len; if (n == sizeof(target)) { - n--; + /* Traditionally readlink(2) should not return more than */ + /* PATH_MAX bytes (no terminating null byte is appended). */ + throwUnixException(env, ENAMETOOLONG); + return NULL; } target[n] = '\0'; len = (jsize)strlen(target);