[Bug 275232] libc memory leak - acl_to_text() / acl_to_text_np()
Date: Tue, 21 Nov 2023 14:00:49 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=275232 Bug ID: 275232 Summary: libc memory leak - acl_to_text() / acl_to_text_np() Product: Base System Version: 13.2-RELEASE Hardware: Any OS: Any Status: New Severity: Affects Some People Priority: --- Component: bin Assignee: bugs@FreeBSD.org Reporter: pen@lysator.liu.se Created attachment 246464 --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=246464&action=edit Patch to fix three small memory leaks in libc / acl_to_text() There is a couple of small memory leaks in the libc functions acl_to_text() ad acl_to_text_np() - if the ACL contains user: and/or group: entries then it will leak about sizeof(uid_t) allocated blocks for each ACL entry... Compile with "cc -g" and then run with "valgrind --leak-check=full ./a.out": #include <stdio.h> #include <sys/acl.h> int main(int argc, char *argv[]) { acl_t a; acl_entry_t e; uid_t uid; a = acl_init(1); acl_create_entry(&a, &e); acl_set_tag_type(e, ACL_USER); uid = 1001; acl_set_qualifier(e, &uid); acl_set_entry_type_np(e, ACL_ENTRY_TYPE_ALLOW); char *s = acl_to_text(a, NULL); puts(s); acl_free(s); acl_free(a); return 0; } ==94097== 4 bytes in 1 blocks are definitely lost in loss record 1 of 10 ==94097== at 0x484CBE4: malloc (vg_replace_malloc.c:435) ==94097== by 0x4953AB3: acl_get_qualifier (in /lib/libc.so.7) ==94097== by 0x49556B8: ??? (in /lib/libc.so.7) ==94097== by 0x201B0D: main (acl_to_text_leak.c:20) There are at least three missed acl_free() calls for returned identifiers from acl_get_qualifier() in lib/libc/posix1e/acl_to_text_nfs4.c -- You are receiving this mail because: You are the assignee for the bug.