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
F173825125: D52580.id162256.diff
Mon, Sep 28, 5:33 PM
Unknown Object (File)
Fri, Sep 25, 9:56 PM
Unknown Object (File)
Tue, Sep 22, 7:45 AM
Unknown Object (File)
Mon, Sep 21, 9:23 AM
Unknown Object (File)
Sun, Sep 20, 4:29 PM
Unknown Object (File)
Aug 28 2026, 6:24 AM
Unknown Object (File)
Aug 26 2026, 3:30 PM
Unknown Object (File)
Aug 26 2026, 9:19 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 Skipped
Unit
Tests Skipped
Build Status
Buildable 67087
Build 63970: arc lint + arc unit

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