Skip to content

Commit

Permalink
s3:passdb: Fix memory leak caused by recursion of get_global_sam_sid()
Browse files Browse the repository at this point in the history
Direct leak of 68 byte(s) in 1 object(s) allocated from:
    #0 0x7f4f39cdc03f in malloc (/lib64/libasan.so.8+0xdc03f) (BuildId: 3e1694ad218c99a8b1b69231666a27df63cf19d0)
    #1 0x7f4f36fbe427 in malloc_ ../../source3/lib/util_malloc.c:38
    #2 0x7f4f394b5e19 in pdb_generate_sam_sid ../../source3/passdb/machine_sid.c:90
    #3 0x7f4f394b5e19 in get_global_sam_sid ../../source3/passdb/machine_sid.c:211
    #4 0x7f4f394af366 in secrets_store_domain_sid ../../source3/passdb/machine_account_secrets.c:143
    #5 0x7f4f394b5eb5 in pdb_generate_sam_sid ../../source3/passdb/machine_sid.c:110
    #6 0x7f4f394b5eb5 in get_global_sam_sid ../../source3/passdb/machine_sid.c:211
    #7 0x7f4f394af366 in secrets_store_domain_sid ../../source3/passdb/machine_account_secrets.c:143
    #8 0x557a1f11d62c in net_setlocalsid ../../source3/utils/net.c:416
    #9 0x557a1f1c9972 in net_run_function ../../source3/utils/net_util.c:464
    #10 0x557a1f121129 in main ../../source3/utils/net.c:1372
    #11 0x7f4f34c281af in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>

Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Tue Jan 23 14:30:58 UTC 2024 on atb-devel-224
  • Loading branch information
cryptomilk committed Jan 23, 2024
1 parent dc18e2a commit 13d98c8
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions source3/passdb/machine_account_secrets.c
Expand Up @@ -138,11 +138,13 @@ bool secrets_store_domain_sid(const char *domain, const struct dom_sid *sid)
&clean_sid,
sizeof(struct dom_sid));

/* Force a re-query, in the case where we modified our domain */
/* Force a re-query */
if (ret) {
if (dom_sid_equal(get_global_sam_sid(), sid) == false) {
reset_global_sam_sid();
}
/*
* Do not call get_global_domain_sid() here, or we will call it
* recursively.
*/
reset_global_sam_sid();
}
return ret;
}
Expand Down

0 comments on commit 13d98c8

Please sign in to comment.