Blob Blame History Raw
From 86c2e733c461f0311eac38eb5cef1eb245aa584c Mon Sep 17 00:00:00 2001
From: Andreas Schneider <asn@samba.org>
Date: Wed, 13 Nov 2019 09:44:32 +0100
Subject: [PATCH 148/187] libcli:auth: Check return status of
 netlogon_creds_first_step()

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14195

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
(cherry picked from commit 0ed92e3e60684bfb02b01479d985535d525a5be5)
---
 libcli/auth/credentials.c | 24 +++++++++++++++++++-----
 1 file changed, 19 insertions(+), 5 deletions(-)

diff --git a/libcli/auth/credentials.c b/libcli/auth/credentials.c
index 36d0368d198..359ba8c4b90 100644
--- a/libcli/auth/credentials.c
+++ b/libcli/auth/credentials.c
@@ -174,15 +174,17 @@ static NTSTATUS netlogon_creds_init_hmac_sha256(struct netlogon_creds_Credential
 	return NT_STATUS_OK;
 }
 
-static void netlogon_creds_first_step(struct netlogon_creds_CredentialState *creds,
-				      const struct netr_Credential *client_challenge,
-				      const struct netr_Credential *server_challenge)
+static NTSTATUS netlogon_creds_first_step(struct netlogon_creds_CredentialState *creds,
+					  const struct netr_Credential *client_challenge,
+					  const struct netr_Credential *server_challenge)
 {
 	netlogon_creds_step_crypt(creds, client_challenge, &creds->client);
 
 	netlogon_creds_step_crypt(creds, server_challenge, &creds->server);
 
 	creds->seed = creds->client;
+
+	return NT_STATUS_OK;
 }
 
 /*
@@ -470,7 +472,13 @@ struct netlogon_creds_CredentialState *netlogon_creds_client_init(TALLOC_CTX *me
 		}
 	}
 
-	netlogon_creds_first_step(creds, client_challenge, server_challenge);
+	status = netlogon_creds_first_step(creds,
+					   client_challenge,
+					   server_challenge);
+	if (!NT_STATUS_IS_OK(status)) {
+		talloc_free(creds);
+		return NULL;
+	}
 
 	dump_data_pw("Session key", creds->session_key, 16);
 	dump_data_pw("Credential ", creds->client.data, 8);
@@ -643,7 +651,13 @@ struct netlogon_creds_CredentialState *netlogon_creds_server_init(TALLOC_CTX *me
 		}
 	}
 
-	netlogon_creds_first_step(creds, client_challenge, server_challenge);
+	status = netlogon_creds_first_step(creds,
+					   client_challenge,
+					   server_challenge);
+	if (!NT_STATUS_IS_OK(status)) {
+		talloc_free(creds);
+		return NULL;
+	}
 
 	dump_data_pw("Session key", creds->session_key, 16);
 	dump_data_pw("Client Credential ", creds->client.data, 8);
-- 
2.23.0