RFR: 8229872: (fs) Increase buffer size used with getmntent
Alan Bateman
Alan.Bateman at oracle.com
Wed Sep 4 14:24:47 UTC 2019
On 04/09/2019 13:07, Vladimir Kempik wrote:
> Hello
> Please review v5 of fix:
> http://cr.openjdk.java.net/~vkempik/8229872/webrev.05
>
> diff vs v4:
> moved getlinelen and rewind in UnixNativeDispatcher.c right after fclose.
> changed getlinelen return type to jlong
> slightly improved the comment about getlinelen and updated comments
> formatting in native part.
>
LinuxNativeDispatcher.getmntent shouldn't free buf before it has copied
the strings from the mntent structure as it could potentially access
memory that is allocated for something else. It also needs to check the
return from malloc and throw an exception if possible (you'll see other
examples of this).
The size returned by getline doesn't include the NUL terminator. Are you
sure that this size is large enough for the buffer that you specify to
getmntent_r to store the strings? I expect it is because the strings
that are stuffed into the buffer are a subset of the items that on the
entry. Do I have that right?
Have you considered using fseek instead of rewind to avoid the
uncertainty as to whether errno is set?
-Alan
More information about the nio-dev
mailing list