From 15297eea0e6b1e95ddb9e2ccd25ff454a405c351 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 21 Jun 2010 22:20:10 +0200 Subject: s3: Fix some valgrind errors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit With -d 10, there were a ton of uninitialized variables: The "NegotiateFlags" in the automatically parsed ntlmssp structures were not initialized. This also cleans up the talloc use a bit: do early TALLOC_FREE() Günther, please check! Thanks, Volker --- source3/libsmb/ntlmssp.c | 51 +++++++++++++++++++++++++++++++----------------- 1 file changed, 33 insertions(+), 18 deletions(-) (limited to 'source3') diff --git a/source3/libsmb/ntlmssp.c b/source3/libsmb/ntlmssp.c index 1d475172fe..870f6c5149 100644 --- a/source3/libsmb/ntlmssp.c +++ b/source3/libsmb/ntlmssp.c @@ -395,8 +395,6 @@ static NTSTATUS ntlmssp_server_negotiate(struct ntlmssp_state *ntlmssp_state, uint32_t ntlmssp_command, chal_flags; uint8_t cryptkey[8]; const char *target_name; - struct NEGOTIATE_MESSAGE negotiate; - struct CHALLENGE_MESSAGE challenge; NTSTATUS status; /* parse the NTLMSSP packet */ @@ -417,11 +415,16 @@ static NTSTATUS ntlmssp_server_negotiate(struct ntlmssp_state *ntlmssp_state, debug_ntlmssp_flags(neg_flags); if (DEBUGLEVEL >= 10) { - if (NT_STATUS_IS_OK(ntlmssp_pull_NEGOTIATE_MESSAGE(&request, - ntlmssp_state, - &negotiate))) - { - NDR_PRINT_DEBUG(NEGOTIATE_MESSAGE, &negotiate); + struct NEGOTIATE_MESSAGE *negotiate = talloc( + talloc_tos(), struct NEGOTIATE_MESSAGE); + if (negotiate != NULL) { + status = ntlmssp_pull_NEGOTIATE_MESSAGE( + &request, negotiate, negotiate); + if (NT_STATUS_IS_OK(status)) { + NDR_PRINT_DEBUG(NEGOTIATE_MESSAGE, + negotiate); + } + TALLOC_FREE(negotiate); } } } @@ -514,11 +517,17 @@ static NTSTATUS ntlmssp_server_negotiate(struct ntlmssp_state *ntlmssp_state, data_blob_free(&version_blob); if (DEBUGLEVEL >= 10) { - if (NT_STATUS_IS_OK(ntlmssp_pull_CHALLENGE_MESSAGE(reply, - ntlmssp_state, - &challenge))) - { - NDR_PRINT_DEBUG(CHALLENGE_MESSAGE, &challenge); + struct CHALLENGE_MESSAGE *challenge = talloc( + talloc_tos(), struct CHALLENGE_MESSAGE); + if (challenge != NULL) { + challenge->NegotiateFlags = chal_flags; + status = ntlmssp_pull_CHALLENGE_MESSAGE( + reply, challenge, challenge); + if (NT_STATUS_IS_OK(status)) { + NDR_PRINT_DEBUG(CHALLENGE_MESSAGE, + challenge); + } + TALLOC_FREE(challenge); } } } @@ -548,7 +557,6 @@ static NTSTATUS ntlmssp_server_auth(struct ntlmssp_state *ntlmssp_state, DATA_BLOB session_key = data_blob_null; uint32_t ntlmssp_command, auth_flags; NTSTATUS nt_status = NT_STATUS_OK; - struct AUTHENTICATE_MESSAGE authenticate; /* used by NTLM2 */ bool doing_ntlm2 = False; @@ -617,11 +625,18 @@ static NTSTATUS ntlmssp_server_auth(struct ntlmssp_state *ntlmssp_state, ntlmssp_handle_neg_flags(ntlmssp_state, auth_flags, lp_lanman_auth()); if (DEBUGLEVEL >= 10) { - if (NT_STATUS_IS_OK(ntlmssp_pull_AUTHENTICATE_MESSAGE(&request, - ntlmssp_state, - &authenticate))) - { - NDR_PRINT_DEBUG(AUTHENTICATE_MESSAGE, &authenticate); + struct AUTHENTICATE_MESSAGE *authenticate = talloc( + talloc_tos(), struct AUTHENTICATE_MESSAGE); + if (authenticate != NULL) { + NTSTATUS status; + authenticate->NegotiateFlags = auth_flags; + status = ntlmssp_pull_AUTHENTICATE_MESSAGE( + &request, authenticate, authenticate); + if (NT_STATUS_IS_OK(status)) { + NDR_PRINT_DEBUG(AUTHENTICATE_MESSAGE, + authenticate); + } + TALLOC_FREE(authenticate); } } -- cgit