mirror of
https://github.com/samba-team/samba.git
synced 2024-12-22 13:34:15 +03:00
libcli/smb: make sure the session->{smb2->,smb2_channel.}signing_key is never NULL!
Before commit 17e22e020f
they we not a
pointer and always be present.
We used the local pointer variable 'signing_key = NULL' and logic like
this:
if (state->smb2.should_sign) {
signing_key = state->session->smb2_channel.signing_key;
}
if (signing_key != NULL ...
In order to keep this we need to nake sure
state->session->smb2_channel.signing_key is never NULL!
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
This commit is contained in:
parent
2ad02acf38
commit
7b1eab1093
@ -5526,9 +5526,27 @@ struct smbXcli_session *smbXcli_session_create(TALLOC_CTX *mem_ctx,
|
||||
}
|
||||
talloc_set_destructor(session, smbXcli_session_destructor);
|
||||
|
||||
session->smb2->signing_key = talloc_zero(session,
|
||||
struct smb2_signing_key);
|
||||
if (session->smb2->signing_key == NULL) {
|
||||
talloc_free(session);
|
||||
return NULL;
|
||||
}
|
||||
talloc_set_destructor(session->smb2->signing_key,
|
||||
smb2_signing_key_destructor);
|
||||
|
||||
DLIST_ADD_END(conn->sessions, session);
|
||||
session->conn = conn;
|
||||
|
||||
session->smb2_channel.signing_key =
|
||||
talloc_zero(session, struct smb2_signing_key);
|
||||
if (session->smb2_channel.signing_key == NULL) {
|
||||
talloc_free(session);
|
||||
return NULL;
|
||||
}
|
||||
talloc_set_destructor(session->smb2_channel.signing_key,
|
||||
smb2_signing_key_destructor);
|
||||
|
||||
memcpy(session->smb2_channel.preauth_sha512,
|
||||
conn->smb2.preauth_sha512,
|
||||
sizeof(session->smb2_channel.preauth_sha512));
|
||||
@ -6038,15 +6056,6 @@ NTSTATUS smb2cli_session_set_session_key(struct smbXcli_session *session,
|
||||
memcpy(session_key, _session_key.data,
|
||||
MIN(_session_key.length, sizeof(session_key)));
|
||||
|
||||
session->smb2->signing_key = talloc_zero(session,
|
||||
struct smb2_signing_key);
|
||||
if (session->smb2->signing_key == NULL) {
|
||||
ZERO_STRUCT(session_key);
|
||||
return NT_STATUS_NO_MEMORY;
|
||||
}
|
||||
talloc_set_destructor(session->smb2->signing_key,
|
||||
smb2_signing_key_destructor);
|
||||
|
||||
session->smb2->signing_key->blob =
|
||||
data_blob_talloc(session->smb2->signing_key,
|
||||
session_key,
|
||||
@ -6117,14 +6126,6 @@ NTSTATUS smb2cli_session_set_session_key(struct smbXcli_session *session,
|
||||
}
|
||||
ZERO_STRUCT(session_key);
|
||||
|
||||
session->smb2_channel.signing_key =
|
||||
talloc_zero(session, struct smb2_signing_key);
|
||||
if (session->smb2_channel.signing_key == NULL) {
|
||||
return NT_STATUS_NO_MEMORY;
|
||||
}
|
||||
talloc_set_destructor(session->smb2_channel.signing_key,
|
||||
smb2_signing_key_destructor);
|
||||
|
||||
session->smb2_channel.signing_key->blob =
|
||||
data_blob_dup_talloc(session->smb2_channel.signing_key,
|
||||
session->smb2->signing_key->blob);
|
||||
@ -6243,6 +6244,15 @@ NTSTATUS smb2cli_session_create_channel(TALLOC_CTX *mem_ctx,
|
||||
DLIST_ADD_END(conn->sessions, session2);
|
||||
session2->conn = conn;
|
||||
|
||||
session2->smb2_channel.signing_key =
|
||||
talloc_zero(session2, struct smb2_signing_key);
|
||||
if (session2->smb2_channel.signing_key == NULL) {
|
||||
talloc_free(session2);
|
||||
return NT_STATUS_NO_MEMORY;
|
||||
}
|
||||
talloc_set_destructor(session2->smb2_channel.signing_key,
|
||||
smb2_signing_key_destructor);
|
||||
|
||||
memcpy(session2->smb2_channel.preauth_sha512,
|
||||
conn->smb2.preauth_sha512,
|
||||
sizeof(session2->smb2_channel.preauth_sha512));
|
||||
|
Loading…
Reference in New Issue
Block a user