RFR: 8229872: (fs) Increase buffer size used with getmntent

Vladimir Kempik vkempik at azul.com
Wed Sep 4 14:52:17 UTC 2019


Hello
See comments:

> 4 сент. 2019 г., в 17:24, Alan Bateman <Alan.Bateman at oracle.com> написал(а):
> 
> 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).
I have looked at getmntent_r in libmusl, you are right.  I will fix that.
> 
> 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?
> 
Its no issue since newline character counted, and getmntent_r is looking for newline character. Every line in /proc/mounts ends with newline character.
from man getline:
       getline()  reads an entire line from stream, storing the address of the
       buffer containing the text into *lineptr.  The  buffer  is  null-termi‐
       nated and includes the newline character, if one was found.

> Have you considered using fseek instead of rewind to avoid the uncertainty as to whether errno is set?
it seems fseek vs rewind&ferror is : with fseek we will know errno while with rewind&ferror we will know the error happened but no errno.

do you thinks its better to introduce fseek (but how do I specify SEEK_SET in java then, some enum?) or just rewrite native part of rewind to actually use fseek?

Thanks, Vladimir
> 
> -Alan
> 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: Message signed with OpenPGP
URL: <https://mail.openjdk.java.net/pipermail/nio-dev/attachments/20190904/e039f7a3/signature.asc>


More information about the nio-dev mailing list