b6b438
From bf554cd1d46a4e2955f5dad40f08f8e574760bde Mon Sep 17 00:00:00 2001
b6b438
From: Andreas Schneider <asn@samba.org>
b6b438
Date: Wed, 13 Nov 2019 10:06:20 +0100
b6b438
Subject: [PATCH 151/187] libcli:auth: Check return code of
b6b438
 netlogon_creds_client_authenticator()
b6b438
b6b438
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14195
b6b438
b6b438
Signed-off-by: Andreas Schneider <asn@samba.org>
b6b438
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
b6b438
(cherry picked from commit 0906848936c410f49b26f7688df7ce1a0e1097f5)
b6b438
---
b6b438
 libcli/auth/netlogon_creds_cli.c | 49 +++++++++++++++++++++++---------
b6b438
 1 file changed, 36 insertions(+), 13 deletions(-)
b6b438
b6b438
diff --git a/libcli/auth/netlogon_creds_cli.c b/libcli/auth/netlogon_creds_cli.c
b6b438
index 50a5f50a57d..2123862dbd2 100644
b6b438
--- a/libcli/auth/netlogon_creds_cli.c
b6b438
+++ b/libcli/auth/netlogon_creds_cli.c
b6b438
@@ -1547,7 +1547,11 @@ struct tevent_req *netlogon_creds_cli_check_send(TALLOC_CTX *mem_ctx,
b6b438
 	 */
b6b438
 	tevent_req_defer_callback(req, state->ev);
b6b438
 
b6b438
-	netlogon_creds_client_authenticator(state->creds, &state->req_auth);
b6b438
+	status = netlogon_creds_client_authenticator(state->creds,
b6b438
+						     &state->req_auth);
b6b438
+	if (tevent_req_nterror(req, status)) {
b6b438
+		return tevent_req_post(req, ev);
b6b438
+	}
b6b438
 	ZERO_STRUCT(state->rep_auth);
b6b438
 
b6b438
 	subreq = dcerpc_netr_LogonGetCapabilities_send(state, state->ev,
b6b438
@@ -1981,8 +1985,11 @@ static void netlogon_creds_cli_ServerPasswordSet_locked(struct tevent_req *subre
b6b438
 	tevent_req_defer_callback(req, state->ev);
b6b438
 
b6b438
 	state->tmp_creds = *state->creds;
b6b438
-	netlogon_creds_client_authenticator(&state->tmp_creds,
b6b438
-					    &state->req_auth);
b6b438
+	status = netlogon_creds_client_authenticator(&state->tmp_creds,
b6b438
+						     &state->req_auth);
b6b438
+	if (tevent_req_nterror(req, status)) {
b6b438
+		return;
b6b438
+	}
b6b438
 	ZERO_STRUCT(state->rep_auth);
b6b438
 
b6b438
 	if (state->tmp_creds.negotiate_flags & NETLOGON_NEG_PASSWORD_SET2) {
b6b438
@@ -2416,8 +2423,12 @@ static void netlogon_creds_cli_LogonSamLogon_start(struct tevent_req *req)
b6b438
 	}
b6b438
 
b6b438
 	state->tmp_creds = *state->lk_creds;
b6b438
-	netlogon_creds_client_authenticator(&state->tmp_creds,
b6b438
-					    &state->req_auth);
b6b438
+	status = netlogon_creds_client_authenticator(&state->tmp_creds,
b6b438
+						     &state->req_auth);
b6b438
+	if (tevent_req_nterror(req, status)) {
b6b438
+		netlogon_creds_cli_LogonSamLogon_cleanup(req, status);
b6b438
+		return;
b6b438
+	}
b6b438
 	ZERO_STRUCT(state->rep_auth);
b6b438
 
b6b438
 	state->logon = netlogon_creds_shallow_copy_logon(state,
b6b438
@@ -2848,8 +2859,11 @@ static void netlogon_creds_cli_DsrUpdateReadOnlyServerDnsRecords_locked(struct t
b6b438
 	tevent_req_defer_callback(req, state->ev);
b6b438
 
b6b438
 	state->tmp_creds = *state->creds;
b6b438
-	netlogon_creds_client_authenticator(&state->tmp_creds,
b6b438
-					    &state->req_auth);
b6b438
+	status = netlogon_creds_client_authenticator(&state->tmp_creds,
b6b438
+						     &state->req_auth);
b6b438
+	if (tevent_req_nterror(req, status)) {
b6b438
+		return;
b6b438
+	}
b6b438
 	ZERO_STRUCT(state->rep_auth);
b6b438
 
b6b438
 	subreq = dcerpc_netr_DsrUpdateReadOnlyServerDnsRecords_send(state, state->ev,
b6b438
@@ -3100,8 +3114,11 @@ static void netlogon_creds_cli_ServerGetTrustInfo_locked(struct tevent_req *subr
b6b438
 	tevent_req_defer_callback(req, state->ev);
b6b438
 
b6b438
 	state->tmp_creds = *state->creds;
b6b438
-	netlogon_creds_client_authenticator(&state->tmp_creds,
b6b438
-					    &state->req_auth);
b6b438
+	status = netlogon_creds_client_authenticator(&state->tmp_creds,
b6b438
+						     &state->req_auth);
b6b438
+	if (tevent_req_nterror(req, status)) {
b6b438
+		return;
b6b438
+	}
b6b438
 	ZERO_STRUCT(state->rep_auth);
b6b438
 
b6b438
 	subreq = dcerpc_netr_ServerGetTrustInfo_send(state, state->ev,
b6b438
@@ -3402,8 +3419,11 @@ static void netlogon_creds_cli_GetForestTrustInformation_locked(struct tevent_re
b6b438
 	tevent_req_defer_callback(req, state->ev);
b6b438
 
b6b438
 	state->tmp_creds = *state->creds;
b6b438
-	netlogon_creds_client_authenticator(&state->tmp_creds,
b6b438
-					    &state->req_auth);
b6b438
+	status = netlogon_creds_client_authenticator(&state->tmp_creds,
b6b438
+						     &state->req_auth);
b6b438
+	if (tevent_req_nterror(req, status)) {
b6b438
+		return;
b6b438
+	}
b6b438
 	ZERO_STRUCT(state->rep_auth);
b6b438
 
b6b438
 	subreq = dcerpc_netr_GetForestTrustInformation_send(state, state->ev,
b6b438
@@ -3680,8 +3700,11 @@ static void netlogon_creds_cli_SendToSam_locked(struct tevent_req *subreq)
b6b438
 	tevent_req_defer_callback(req, state->ev);
b6b438
 
b6b438
 	state->tmp_creds = *state->creds;
b6b438
-	netlogon_creds_client_authenticator(&state->tmp_creds,
b6b438
-					    &state->req_auth);
b6b438
+	status = netlogon_creds_client_authenticator(&state->tmp_creds,
b6b438
+						     &state->req_auth);
b6b438
+	if (tevent_req_nterror(req, status)) {
b6b438
+		return;
b6b438
+	}
b6b438
 	ZERO_STRUCT(state->rep_auth);
b6b438
 
b6b438
 	if (state->tmp_creds.negotiate_flags & NETLOGON_NEG_SUPPORTS_AES) {
b6b438
-- 
b6b438
2.23.0
b6b438