Skip to content

Commit b989f6e

Browse files
cryptomilkanoopcs9
authored andcommitted
s3:util: Pass a memory context to get_challenge for ntlm_auth tests
Fixes memory leaks detected by LeakSanitizer. Signed-off-by: Andreas Schneider <[email protected]> Reviewed-by: Anoop C S <[email protected]>
1 parent a7d5853 commit b989f6e

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

source3/utils/ntlm_auth.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -367,13 +367,13 @@ const char *get_winbind_netbios_name(void)
367367

368368
}
369369

370-
DATA_BLOB get_challenge(void)
370+
DATA_BLOB get_challenge(TALLOC_CTX *mem_ctx)
371371
{
372372
static DATA_BLOB chal;
373373
if (opt_challenge.length)
374374
return opt_challenge;
375375

376-
chal = data_blob(NULL, 8);
376+
chal = data_blob_talloc(mem_ctx, NULL, 8);
377377

378378
generate_random_buffer(chal.data, chal.length);
379379
return chal;

source3/utils/ntlm_auth_diagnostics.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ static bool test_lm_ntlm_broken(enum ntlm_break break_which,
6060
uchar user_session_key[16];
6161
uchar lm_hash[16];
6262
uchar nt_hash[16];
63-
DATA_BLOB chall = get_challenge();
63+
DATA_BLOB chall = get_challenge(talloc_tos());
6464
char *error_string = NULL;
6565

6666
ZERO_STRUCT(lm_key);
@@ -199,7 +199,7 @@ static bool test_ntlm_in_lm(bool lanman_support_expected)
199199
uchar lm_key[8];
200200
uchar lm_hash[16];
201201
uchar user_session_key[16];
202-
DATA_BLOB chall = get_challenge();
202+
DATA_BLOB chall = get_challenge(talloc_tos());
203203
char *error_string = NULL;
204204

205205
ZERO_STRUCT(user_session_key);
@@ -291,7 +291,7 @@ static bool test_ntlm_in_both(bool lanman_support_expected)
291291
uint8_t lm_hash[16];
292292
uint8_t user_session_key[16];
293293
uint8_t nt_hash[16];
294-
DATA_BLOB chall = get_challenge();
294+
DATA_BLOB chall = get_challenge(talloc_tos());
295295
char *error_string = NULL;
296296

297297
ZERO_STRUCT(lm_key);
@@ -380,7 +380,7 @@ static bool test_lmv2_ntlmv2_broken(enum ntlm_break break_which)
380380
DATA_BLOB names_blob = NTLMv2_generate_names_blob(NULL, get_winbind_netbios_name(), get_winbind_domain());
381381
uint8_t authoritative = 1;
382382
uchar user_session_key[16];
383-
DATA_BLOB chall = get_challenge();
383+
DATA_BLOB chall = get_challenge(talloc_tos());
384384
char *error_string = NULL;
385385

386386
ZERO_STRUCT(user_session_key);

source3/utils/ntlm_auth_proto.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
const char *get_winbind_domain(void);
3030
const char *get_winbind_netbios_name(void);
31-
DATA_BLOB get_challenge(void) ;
31+
DATA_BLOB get_challenge(TALLOC_CTX *mem_ctx) ;
3232
NTSTATUS contact_winbind_auth_crap(const char *username,
3333
const char *domain,
3434
const char *workstation,

0 commit comments

Comments
 (0)