Bug 15771 - memmory leak wbcCtxLookupSid. samba-4.21.2
Summary: memmory leak wbcCtxLookupSid. samba-4.21.2
Status: RESOLVED FIXED
Alias: None
Product: TALLOC
Classification: Unclassified
Component: libtalloc (show other bugs)
Version: unspecified
Hardware: All All
: P5 normal
Target Milestone: ---
Assignee: Jule Anger
QA Contact: Samba QA Contact
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-12-16 16:45 UTC by prohorp
Modified: 2025-01-06 15:34 UTC (History)
1 user (show)

See Also:


Attachments
Does that help? (745 bytes, text/plain)
2024-12-16 16:51 UTC, Volker Lendecke
no flags Details
Patch works against 4.21 and 4.20 (913 bytes, patch)
2024-12-18 15:24 UTC, Volker Lendecke
gd: review+
Details

Note You need to log in before you can comment on or make changes to this bug.
Description prohorp 2024-12-16 16:45:30 UTC
Memory leak var «name»:
line 2536 in function «winbind_upn_to_username»
https://gitlab.com/samba-team/samba/-/blob/master/nsswitch/pam_winbind.c?ref_type=heads#L2536
```
/* Convert the SID back to the sAMAccountName */
wbc_status = wbcCtxLookupSid(ctx->wbc_ctx, &sid, &domain, &name, &type);
```
in function «wbcCtxLookupSid» on line 297 the pointer is being erased
Comment 1 Volker Lendecke 2024-12-16 16:51:12 UTC
Created attachment 18509 [details]
Does that help?
Comment 2 prohorp 2024-12-16 16:57:33 UTC
Comment on attachment 18509 [details]
Does that help?

No.
After call func "wbcCtxLookupName" var "name" has a new pointer value.
Help save value "name" in "name_save" before call func "wbcCtxLookupName".
After
```
wbcFreeMemory(name);
+++
if (name != name_save)
   wbcFreeMemory(name_save);
```
Comment 3 prohorp 2024-12-16 17:01:38 UTC
(In reply to Volker Lendecke from comment #1)
Oh sorry.
This really help.
Comment 4 prohorp 2024-12-16 17:04:59 UTC
(In reply to prohorp from comment #2)
this is an option to release resources at the end of the function
Comment 5 Samba QA Contact 2024-12-18 09:31:04 UTC
This bug was referenced in samba master:

7e8bfe738a3d91b0724d57ed54acf40ebe026c14
Comment 6 Volker Lendecke 2024-12-18 15:24:26 UTC
Created attachment 18514 [details]
Patch works against 4.21 and 4.20
Comment 7 Guenther Deschner 2024-12-18 17:22:25 UTC
Comment on attachment 18514 [details]
Patch works against 4.21 and 4.20

LGTM, RB+, thanks!
Comment 8 Guenther Deschner 2024-12-18 17:23:38 UTC
Jule, please add to 4.20 and 4.21
Comment 9 Jule Anger 2024-12-19 08:44:10 UTC
Pushed to autobuild-v4-{21,20}-test.
Comment 10 Samba QA Contact 2024-12-19 10:14:04 UTC
This bug was referenced in samba v4-21-test:

7202467477de13e9c960677de6792ec42f92ac0c
Comment 11 Samba QA Contact 2024-12-19 10:41:12 UTC
This bug was referenced in samba v4-20-test:

4d043ea5e51904ab701d87d93f235dd989a08d6a
Comment 12 Jule Anger 2024-12-19 11:50:06 UTC
Closing out bug report.

Thanks!
Comment 13 Samba QA Contact 2025-01-06 15:34:52 UTC
This bug was referenced in samba v4-21-stable (Release samba-4.21.3):

7202467477de13e9c960677de6792ec42f92ac0c