]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3:util: Pass a memory context to get_challenge for ntlm_auth tests
authorAndreas Schneider <asn@samba.org>
Tue, 14 Oct 2025 09:21:42 +0000 (11:21 +0200)
committerAnoop C S <anoopcs@samba.org>
Thu, 16 Oct 2025 08:32:32 +0000 (08:32 +0000)
Fixes memory leaks detected by LeakSanitizer.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
source3/utils/ntlm_auth.c
source3/utils/ntlm_auth_diagnostics.c
source3/utils/ntlm_auth_proto.h

index a424990baa83dd59d9d2a09d13df926de7893c46..6c2493ec1f19483d1c1976d2646fc44915ed63af 100644 (file)
@@ -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;
index 00fb25d32bdb2078e6b052553dd5f9cc82dcac70..e5a8101deac033207b3f8ce7c21597f19acfb754 100644 (file)
@@ -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);
index ed6d5f44a2fb299eee6a5eec2dd29198cc19bb53..5fcc49b5064948d32dfb73ccaa40f1d9295b5923 100644 (file)
@@ -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,