On Mon, 22 Dec 2025 14:24:20 GMT, Weijun Wang <[email protected]> wrote:

>> src/jdk.security.auth/share/classes/com/sun/security/auth/module/UnixSystem.java
>>  line 78:
>> 
>>> 76:             }
>>> 77: 
>>> 78:             var resbuf = passwd.allocate(scope);
>> 
>> Wouldn't this be 1024 as well?
>
> This is the `MemorySegment allocate(SegmentAllocator allocator)` method in 
> the generated `passwd.java`. If I understand correctly, the 2nd argument to 
> `getpwuid_r` should be the pointer to a single `passwd` struct and the 3rd is 
> to a big enough memory to hold contents of extra pointers inside `passwd`.

Yes, ideally the 3rd argument would be the size of platform's maximum pwd 
struct buffer size, which at least can found found on linux and macos with  
_SC_GETPW_R_SIZE_MAX using sysconf.  The sysconf FFM would not be a must-have, 
but would be a nice addition (along with errno) as part of the core libraries 
in the future.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/28931#discussion_r2642271796

Reply via email to