From: Andreas Schneider Date: Fri, 25 Oct 2024 05:56:46 +0000 (+0200) Subject: s3:utils: Fix memory leaks in test_ntlm_in_both() X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a9231b22964ddfdc46c0e6c472dc7921267f86d8;p=thirdparty%2Fsamba.git s3:utils: Fix memory leaks in test_ntlm_in_both() Direct leak of 112 byte(s) in 1 object(s) allocated from: #0 0x7ff61d8fc777 in malloc ../../../../libsanitizer/asan/asan_malloc_linux.cpp:69 #1 0x7ff61d450c57 in __talloc_with_prefix ../../lib/talloc/talloc.c:783 #2 0x7ff61d452acf in __talloc ../../lib/talloc/talloc.c:825 #3 0x7ff61d452acf in _talloc_named_const ../../lib/talloc/talloc.c:982 #4 0x7ff61d452acf in _talloc_array ../../lib/talloc/talloc.c:2784 #5 0x7ff61c9f6a99 in data_blob_talloc_named ../../lib/util/data_blob.c:58 #6 0x7ff61c9f6b1b in data_blob_named ../../lib/util/data_blob.c:40 #7 0x561cafffad96 in test_ntlm_in_both ../../source3/utils/ntlm_auth_diagnostics.c:285 #8 0x561cafffc8d4 in diagnose_ntlm_auth ../../source3/utils/ntlm_auth_diagnostics.c:714 #9 0x561cafff8efd in main ../../source3/utils/ntlm_auth.c:2855 #10 0x7ff61a02a2ad in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58 Signed-off-by: Andreas Schneider Reviewed-by: Noel Power --- diff --git a/source3/utils/ntlm_auth_diagnostics.c b/source3/utils/ntlm_auth_diagnostics.c index 1a57f7726f2..fa6b73b7e2c 100644 --- a/source3/utils/ntlm_auth_diagnostics.c +++ b/source3/utils/ntlm_auth_diagnostics.c @@ -314,15 +314,12 @@ static bool test_ntlm_in_both(bool lanman_support_expected) user_session_key, &authoritative, &error_string, NULL); - - data_blob_free(&nt_response); - if (!NT_STATUS_IS_OK(nt_status)) { d_printf("%s (0x%x)\n", error_string, NT_STATUS_V(nt_status)); - SAFE_FREE(error_string); - return False; + pass = false; + goto done; } SAFE_FREE(error_string); @@ -358,6 +355,11 @@ static bool test_ntlm_in_both(bool lanman_support_expected) } +done: + SAFE_FREE(error_string); + data_blob_free(&nt_response); + data_blob_free(&session_key); + return pass; }