JDK-8165936 fixed a potential buffer overflow in TimeZone_md.c, but broke Solaris, which was fixed with JDK-8166148. The code now imposes a minimum buffer size of 1024 bytes for the readdir_r buffer.
A better way would be to just rely on pathconf():
- if pathconf() returns an error, return an error as well
- Otherwise use the length pathconf() returned, but use a canary at the end of the buffer to check for buffer overflows.
The latter point is important because readdir_r in combination with pathconf is unsafe, see e.g. https://womble.decadent.org.uk/readdir_r-advisory.html