8186766: UnixNativeDispatcher::readlink() may truncate overlong paths

Reviewed-by: alanb
This commit is contained in:
Brian Burkhalter 2018-08-03 12:45:18 -07:00
parent 32ec91ca9b
commit b924bf7233

View file

@ -875,7 +875,10 @@ Java_sun_nio_fs_UnixNativeDispatcher_readlink0(JNIEnv* env, jclass this,
} 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);