From: Andreas Schneider Date: Tue, 14 Oct 2025 09:21:42 +0000 (+0200) Subject: s3:util: Pass a memory context to get_challenge for ntlm_auth tests X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b989f6e7091b0adfa394ed860fc731639a42ba99;p=thirdparty%2Fsamba.git s3:util: Pass a memory context to get_challenge for ntlm_auth tests Fixes memory leaks detected by LeakSanitizer. Signed-off-by: Andreas Schneider Reviewed-by: Anoop C S --- diff --git a/source3/utils/ntlm_auth.c b/source3/utils/ntlm_auth.c index a424990baa8..6c2493ec1f1 100644 --- a/source3/utils/ntlm_auth.c +++ b/source3/utils/ntlm_auth.c @@ -367,13 +367,13 @@ const char *get_winbind_netbios_name(void) } -DATA_BLOB get_challenge(void) +DATA_BLOB get_challenge(TALLOC_CTX *mem_ctx) { static DATA_BLOB chal; if (opt_challenge.length) return opt_challenge; - chal = data_blob(NULL, 8); + chal = data_blob_talloc(mem_ctx, NULL, 8); generate_random_buffer(chal.data, chal.length); return chal; diff --git a/source3/utils/ntlm_auth_diagnostics.c b/source3/utils/ntlm_auth_diagnostics.c index 00fb25d32bd..e5a8101deac 100644 --- a/source3/utils/ntlm_auth_diagnostics.c +++ b/source3/utils/ntlm_auth_diagnostics.c @@ -60,7 +60,7 @@ static bool test_lm_ntlm_broken(enum ntlm_break break_which, uchar user_session_key[16]; uchar lm_hash[16]; uchar nt_hash[16]; - DATA_BLOB chall = get_challenge(); + DATA_BLOB chall = get_challenge(talloc_tos()); char *error_string = NULL; ZERO_STRUCT(lm_key); @@ -199,7 +199,7 @@ static bool test_ntlm_in_lm(bool lanman_support_expected) uchar lm_key[8]; uchar lm_hash[16]; uchar user_session_key[16]; - DATA_BLOB chall = get_challenge(); + DATA_BLOB chall = get_challenge(talloc_tos()); char *error_string = NULL; ZERO_STRUCT(user_session_key); @@ -291,7 +291,7 @@ static bool test_ntlm_in_both(bool lanman_support_expected) uint8_t lm_hash[16]; uint8_t user_session_key[16]; uint8_t nt_hash[16]; - DATA_BLOB chall = get_challenge(); + DATA_BLOB chall = get_challenge(talloc_tos()); char *error_string = NULL; ZERO_STRUCT(lm_key); @@ -380,7 +380,7 @@ static bool test_lmv2_ntlmv2_broken(enum ntlm_break break_which) DATA_BLOB names_blob = NTLMv2_generate_names_blob(NULL, get_winbind_netbios_name(), get_winbind_domain()); uint8_t authoritative = 1; uchar user_session_key[16]; - DATA_BLOB chall = get_challenge(); + DATA_BLOB chall = get_challenge(talloc_tos()); char *error_string = NULL; ZERO_STRUCT(user_session_key); diff --git a/source3/utils/ntlm_auth_proto.h b/source3/utils/ntlm_auth_proto.h index ed6d5f44a2f..5fcc49b5064 100644 --- a/source3/utils/ntlm_auth_proto.h +++ b/source3/utils/ntlm_auth_proto.h @@ -28,7 +28,7 @@ const char *get_winbind_domain(void); const char *get_winbind_netbios_name(void); -DATA_BLOB get_challenge(void) ; +DATA_BLOB get_challenge(TALLOC_CTX *mem_ctx) ; NTSTATUS contact_winbind_auth_crap(const char *username, const char *domain, const char *workstation,