s3:smb2_server: remember the max_{trans,read,write} sizes we negotiated (bug #8473)
authorStefan Metzmacher <metze@samba.org>
Fri, 23 Sep 2011 15:18:14 +0000 (17:18 +0200)
committerKarolin Seeger <kseeger@samba.org>
Thu, 13 Oct 2011 18:09:49 +0000 (20:09 +0200)
We should enforce the negotiated max sizes instead of the
lp_smb2_max_*() sizes.

metze
(cherry picked from commit 40ea66c5dda91ba3f74bed7db1ce02f6c8b4ffeb)

source3/smbd/globals.h
source3/smbd/smb2_find.c
source3/smbd/smb2_negprot.c
source3/smbd/smb2_notify.c
source3/smbd/smb2_read.c
source3/smbd/smb2_write.c

index 70338489402427c91ed30ca6e9ff8ec755c23e71..9304a43cdd3078c0cb4f5f18c4ad954efd2b5050 100644 (file)
@@ -604,6 +604,9 @@ struct smbd_server_connection {
                uint64_t seqnum_low;
                uint32_t credits_granted;
                uint32_t max_credits;
+               uint32_t max_trans;
+               uint32_t max_read;
+               uint32_t max_write;
                struct bitmap *credits_bitmap;
                bool compound_related_in_progress;
        } smb2;
index 4a49f2a7a47824ad0a781ed0d757bf02ed7a139c..3dcc76862b02750eeddbdbecb79b32c4d8ecb87d 100644 (file)
@@ -281,7 +281,7 @@ static struct tevent_req *smbd_smb2_find_send(TALLOC_CTX *mem_ctx,
                return tevent_req_post(req, ev);
        }
 
-       if (in_output_buffer_length > lp_smb2_max_trans()) {
+       if (in_output_buffer_length > smb2req->sconn->smb2.max_trans) {
                tevent_req_nterror(req, NT_STATUS_INVALID_PARAMETER);
                return tevent_req_post(req, ev);
        }
index a9d432ac76d6bd3f5df5dcf6752b2e73e767cdf2..2f45b8c756a509c1e98824d59bd413c27a8f11a9 100644 (file)
@@ -81,7 +81,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();
 
-
        status = smbd_smb2_request_verify_sizes(req, 0x24);
        if (!NT_STATUS_IS_OK(status)) {
                return smbd_smb2_request_error(req, status);
@@ -185,6 +184,9 @@ NTSTATUS smbd_smb2_request_process_negprot(struct smbd_smb2_request *req)
        outdyn = security_buffer;
 
        req->sconn->using_smb2 = true;
+       req->sconn->smb2.max_trans = max_trans;
+       req->sconn->smb2.max_read  = max_read;
+       req->sconn->smb2.max_write = max_write;
 
        return smbd_smb2_request_done(req, outbody, &outdyn);
 }
index a8b1eb433ab852bd713b899e7d477e12c5c03566..49c6a5449722484d562d53d3f23d7a5a27cff232 100644 (file)
@@ -73,7 +73,7 @@ NTSTATUS smbd_smb2_request_process_notify(struct smbd_smb2_request *req)
         * 0x00010000 is what Windows 7 uses,
         * Windows 2008 uses 0x00080000
         */
-       if (in_output_buffer_length > lp_smb2_max_trans()) {
+       if (in_output_buffer_length > req->sconn->smb2.max_trans) {
                return smbd_smb2_request_error(req, NT_STATUS_INVALID_PARAMETER);
        }
 
index 89fc420cd329a85c1fa8213624c161fbf8cef96c..21082e67cd8aef244711c989838d56442d2fc4f1 100644 (file)
@@ -74,9 +74,9 @@ NTSTATUS smbd_smb2_request_process_read(struct smbd_smb2_request *req)
        in_remaining_bytes      = IVAL(inbody, 0x28);
 
        /* check the max read size */
-       if (in_length > lp_smb2_max_read()) {
+       if (in_length > req->sconn->smb2.max_read) {
                DEBUG(0,("here:%s: 0x%08X: 0x%08X\n",
-                       __location__, in_length, lp_smb2_max_read()));
+                       __location__, in_length, req->sconn->smb2.max_read));
                return smbd_smb2_request_error(req, NT_STATUS_INVALID_PARAMETER);
        }
 
index 020209892b11467b17d38576a2d3234630920abc..3a6ea9bfdbfa39c71372aeb639ae64dfdd61651e 100644 (file)
@@ -78,11 +78,10 @@ NTSTATUS smbd_smb2_request_process_write(struct smbd_smb2_request *req)
        }
 
        /* check the max write size */
-       if (in_data_length > lp_smb2_max_write()) {
-               /* This is a warning. */
+       if (in_data_length > req->sconn->smb2.max_write) {
                DEBUG(2,("smbd_smb2_request_process_write : "
                        "client ignored max write :%s: 0x%08X: 0x%08X\n",
-                       __location__, in_data_length, lp_smb2_max_write()));
+                       __location__, in_data_length, req->sconn->smb2.max_write));
 #if 0
                return smbd_smb2_request_error(req, NT_STATUS_INVALID_PARAMETER);
 #endif