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