s3:smb2_server: allow smbd_smb2_send_break() with session == NULL and tcon == NULL
authorStefan Metzmacher <metze@samba.org>
Thu, 13 Nov 2014 10:50:14 +0000 (11:50 +0100)
committerJeremy Allison <jra@samba.org>
Thu, 4 Dec 2014 04:45:09 +0000 (05:45 +0100)
In future we want to use this for lease breaks and they're not attached
to a session.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/smbd/smb2_server.c

index 138765e5a8528371fee0a41a4e01692eb2916744..4a3ea7d4250e814a70e48961142e2f55ddd1e208 100644 (file)
@@ -2735,14 +2735,19 @@ static NTSTATUS smbd_smb2_send_break(struct smbXsrv_connection *xconn,
                                     size_t body_len)
 {
        struct smbd_smb2_send_break_state *state;
-       bool do_encryption = session->global->encryption_required;
+       bool do_encryption = false;
+       uint64_t session_wire_id = 0;
        uint64_t nonce_high = 0;
        uint64_t nonce_low = 0;
        NTSTATUS status;
        size_t statelen;
 
-       if (tcon->global->encryption_required) {
-               do_encryption = true;
+       if (session != NULL) {
+               session_wire_id = session->global->session_wire_id;
+               do_encryption = session->global->encryption_required;
+               if (tcon->global->encryption_required) {
+                       do_encryption = true;
+               }
        }
 
        statelen = offsetof(struct smbd_smb2_send_break_state, body) +
@@ -2768,7 +2773,7 @@ static NTSTATUS smbd_smb2_send_break(struct smbXsrv_connection *xconn,
        SIVAL(state->tf, SMB2_TF_PROTOCOL_ID, SMB2_TF_MAGIC);
        SBVAL(state->tf, SMB2_TF_NONCE+0, nonce_low);
        SBVAL(state->tf, SMB2_TF_NONCE+8, nonce_high);
-       SBVAL(state->tf, SMB2_TF_SESSION_ID, session->global->session_wire_id);
+       SBVAL(state->tf, SMB2_TF_SESSION_ID, session_wire_id);
 
        SIVAL(state->hdr, 0,                            SMB2_MAGIC);
        SSVAL(state->hdr, SMB2_HDR_LENGTH,              SMB2_HDR_BODY);