Page MenuHomeFreeBSD

libutil: fix memory leak in login_cap
Needs RevisionPublic

Authored by khng on Jan 5 2026, 2:48 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Mar 1, 3:05 AM
Unknown Object (File)
Sat, Feb 21, 3:31 AM
Unknown Object (File)
Wed, Feb 18, 8:17 PM
Unknown Object (File)
Jan 29 2026, 1:06 AM
Unknown Object (File)
Jan 24 2026, 4:43 AM
Unknown Object (File)
Jan 19 2026, 7:33 PM
Unknown Object (File)
Jan 18 2026, 9:33 AM
Unknown Object (File)
Jan 15 2026, 11:08 AM
Subscribers

Details

Reviewers
des
olce
Summary

cgetstr() allocates memory to the string and sends it back to
the caller. Caller of cgetstr() is supposed to free that memory.

Sponsored by: Hewlett Packard Enterprise
MFC after: 3 days

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 69625
Build 66508: arc lint + arc unit

Event Timeline

khng requested review of this revision.Jan 5 2026, 2:48 PM

Your use of “Obtained from” is incorrect, unless “Hewlett Packard Enterprise” is the name of a piece of open-source software I've never heard of that has a copy of our libutil and already had this patch. You probably want to use “Sponsored by” instead.

In D54526#1246414, @des wrote:

Your use of “Obtained from” is incorrect, unless “Hewlett Packard Enterprise” is the name of a piece of open-source software I've never heard of that has a copy of our libutil and already had this patch. You probably want to use “Sponsored by” instead.

I just changed it to "Sponsored by:".

des requested changes to this revision.Sat, Feb 28, 10:30 AM
des added inline comments.
lib/libutil/login_cap.c
490

I refer you to login_cap(3):

Note that with all functions in this group, you should not call free(3)
on any pointers returned.  Memory allocated during retrieval or
processing of capability tags is automatically reused by subsequent calls
to functions in this group, or deallocated on calling login_close().
This revision now requires changes to proceed.Sat, Feb 28, 10:30 AM