s3:smbd: disconnect the socket if we got an unexpected request
authorStefan Metzmacher <metze@samba.org>
Fri, 23 Sep 2011 04:37:35 +0000 (06:37 +0200)
committerStefan Metzmacher <metze@samba.org>
Fri, 23 Sep 2011 10:30:50 +0000 (12:30 +0200)
If we got a SMB2_OP_NEGPROT after the protocol is already negotiated
or if we got a non SMB2_OP_NEGPROT before the protocol was negotiated
we should close the connection (as windows does).

metze

Autobuild-User: Stefan Metzmacher <metze@samba.org>
Autobuild-Date: Fri Sep 23 12:30:50 CEST 2011 on sn-devel-104

source3/smbd/smb2_negprot.c
source3/smbd/smb2_server.c

index 15bff823ef814cfcf92117cbd6835fe5abaf77d7..c5ac2d553aec7694bc2b3e34313a503cecb99e82 100644 (file)
@@ -101,7 +101,6 @@ NTSTATUS smbd_smb2_request_process_negprot(struct smbd_smb2_request *req)
        uint32_t max_read = lp_smb2_max_read();
        uint32_t max_write = lp_smb2_max_write();
 
-/* TODO: drop the connection with INVALID_PARAMETER */
 
        status = smbd_smb2_request_verify_sizes(req, 0x24);
        if (!NT_STATUS_IS_OK(status)) {
index 368f342dd5f4b60dc055e32d13a7c72492dd2c38..35da2af9774ea8cc99f42dcaaa93f8d4d4e77f96 100644 (file)
@@ -1333,6 +1333,26 @@ NTSTATUS smbd_smb2_request_dispatch(struct smbd_smb2_request *req)
                smb2_opcode_name(opcode),
                (unsigned long long)mid));
 
+       if (get_Protocol() >= PROTOCOL_SMB2_02) {
+               /*
+                * once the protocol is negotiated
+                * SMB2_OP_NEGPROT is not allowed anymore
+                */
+               if (opcode == SMB2_OP_NEGPROT) {
+                       /* drop the connection */
+                       return NT_STATUS_INVALID_PARAMETER;
+               }
+       } else {
+               /*
+                * if the protocol is not negotiated yet
+                * only SMB2_OP_NEGPROT is allowed.
+                */
+               if (opcode != SMB2_OP_NEGPROT) {
+                       /* drop the connection */
+                       return NT_STATUS_INVALID_PARAMETER;
+               }
+       }
+
        allowed_flags = SMB2_HDR_FLAG_CHAINED |
                        SMB2_HDR_FLAG_SIGNED |
                        SMB2_HDR_FLAG_DFS;