Page MenuHomeFreeBSD

initgroups(3): Fix return value on allocation failure
ClosedPublic

Authored by olce on Sep 16 2025, 5:11 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Nov 7, 1:55 AM
Unknown Object (File)
Sun, Nov 2, 11:17 AM
Unknown Object (File)
Wed, Oct 29, 5:35 AM
Unknown Object (File)
Wed, Oct 29, 2:16 AM
Unknown Object (File)
Wed, Oct 29, 2:15 AM
Unknown Object (File)
Wed, Oct 29, 2:13 AM
Unknown Object (File)
Mon, Oct 20, 10:37 AM
Unknown Object (File)
Sat, Oct 18, 7:48 AM
Subscribers

Details

Summary

We must not return ENOMEM, but rather -1 with 'errno' set to ENOMEM, as
described in the manual page and as other implementations are doing.
A malloc() failure actually already sets ENOMEM for us. Add comments
indicating which function set 'errno' each time we return.

While here, improve style and remove useless headers.

Fixes: 54404cfb13d4 ("In preparation for raising NGROUPS and NGROUPS_MAX, ...")
MFC after: 1 week
Sponsored by: The FreeBSD Foundation

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

olce requested review of this revision.Sep 16 2025, 5:11 PM
This revision is now accepted and ready to land.Sep 16 2025, 5:49 PM