SMB2-NOTIFY: windows7 uses a different maximum buffer size
authorStefan Metzmacher <metze@samba.org>
Mon, 6 Jul 2009 10:03:33 +0000 (12:03 +0200)
committerStefan Metzmacher <metze@samba.org>
Mon, 6 Jul 2009 11:28:12 +0000 (13:28 +0200)
metze

source4/torture/smb2/notify.c

index 574136ab3f2d320ec8bc7e71a156b2bf3ca7aafb..f8def193b2d62f0351636b198d10213cda50be01 100644 (file)
 
 #define FNAME "smb2-notify01.dat"
 
-static bool test_valid_request(TALLOC_CTX *mem_ctx, struct smb2_tree *tree)
+#define TARGET_IS_WIN7(_tctx) (torture_setting_bool(_tctx, "win7", false))
+
+static bool test_valid_request(struct torture_context *tctx, struct smb2_tree *tree)
 {
        bool ret = true;
        NTSTATUS status;
        struct smb2_handle dh;
        struct smb2_notify n;
        struct smb2_request *req;
+       uint32_t max_buffer_size = 0x00080000;
+
+       if (TARGET_IS_WIN7(tctx)) {
+               max_buffer_size = 0x00010000;
+       }
+
+       smb2_util_unlink(tree, FNAME);
 
        status = smb2_util_roothandle(tree, &dh);
        CHECK_STATUS(status, NT_STATUS_OK);
 
        n.in.recursive          = 0x0000;
-       n.in.buffer_size        = 0x00080000;
+       n.in.buffer_size        = max_buffer_size;
        n.in.file.handle        = dh;
        n.in.completion_filter  = 0x00000FFF;
        n.in.unknown            = 0x00000000;
@@ -82,10 +91,10 @@ static bool test_valid_request(TALLOC_CTX *mem_ctx, struct smb2_tree *tree)
        status = torture_setup_complex_file(tree, FNAME);
        CHECK_STATUS(status, NT_STATUS_OK);
 
-       status = smb2_notify_recv(req, mem_ctx, &n);
+       status = smb2_notify_recv(req, tctx, &n);
        CHECK_STATUS(status, NT_STATUS_OK);
        CHECK_VALUE(n.out.num_changes, 1);
-       CHECK_VALUE(n.out.changes[0].action, NOTIFY_ACTION_REMOVED);
+       CHECK_VALUE(n.out.changes[0].action, NOTIFY_ACTION_ADDED);
        CHECK_WIRE_STR(n.out.changes[0].name, FNAME);
 
        /* 
@@ -104,14 +113,14 @@ static bool test_valid_request(TALLOC_CTX *mem_ctx, struct smb2_tree *tree)
        status = torture_setup_complex_file(tree, FNAME);
        CHECK_STATUS(status, NT_STATUS_OK);
 
-       status = smb2_notify_recv(req, mem_ctx, &n);
+       status = smb2_notify_recv(req, tctx, &n);
        CHECK_STATUS(status, STATUS_NOTIFY_ENUM_DIR);
 
        /* 
         * if the change response fits in the buffer we get
         * NT_STATUS_OK again
         */
-       n.in.buffer_size        = 0x00080000;
+       n.in.buffer_size        = max_buffer_size;
        req = smb2_notify_send(tree, &n);
 
        while (!req->cancel.can_cancel && req->state <= SMB2_REQUEST_RECV) {
@@ -123,7 +132,7 @@ static bool test_valid_request(TALLOC_CTX *mem_ctx, struct smb2_tree *tree)
        status = torture_setup_complex_file(tree, FNAME);
        CHECK_STATUS(status, NT_STATUS_OK);
 
-       status = smb2_notify_recv(req, mem_ctx, &n);
+       status = smb2_notify_recv(req, tctx, &n);
        CHECK_STATUS(status, NT_STATUS_OK);
        CHECK_VALUE(n.out.num_changes, 3);
        CHECK_VALUE(n.out.changes[0].action, NOTIFY_ACTION_REMOVED);
@@ -155,10 +164,10 @@ static bool test_valid_request(TALLOC_CTX *mem_ctx, struct smb2_tree *tree)
        status = torture_setup_complex_file(tree, FNAME);
        CHECK_STATUS(status, NT_STATUS_OK);
 
-       status = smb2_notify_recv(req, mem_ctx, &n);
+       status = smb2_notify_recv(req, tctx, &n);
        CHECK_STATUS(status, STATUS_NOTIFY_ENUM_DIR);
 
-       n.in.buffer_size        = 0x00080000;
+       n.in.buffer_size        = max_buffer_size;
        req = smb2_notify_send(tree, &n);
        while (!req->cancel.can_cancel && req->state <= SMB2_REQUEST_RECV) {
                if (event_loop_once(req->transport->socket->event.ctx) != 0) {
@@ -169,17 +178,17 @@ static bool test_valid_request(TALLOC_CTX *mem_ctx, struct smb2_tree *tree)
        status = torture_setup_complex_file(tree, FNAME);
        CHECK_STATUS(status, NT_STATUS_OK);
 
-       status = smb2_notify_recv(req, mem_ctx, &n);
+       status = smb2_notify_recv(req, tctx, &n);
        CHECK_STATUS(status, STATUS_NOTIFY_ENUM_DIR);
 
        /* if the buffer size is too large, we get invalid parameter */
        n.in.recursive          = 0x0000;
-       n.in.buffer_size        = 0x00080001;
+       n.in.buffer_size        = max_buffer_size + 1;
        n.in.file.handle        = dh;
        n.in.completion_filter  = 0x00000FFF;
        n.in.unknown            = 0x00000000;
        req = smb2_notify_send(tree, &n);
-       status = smb2_notify_recv(req, mem_ctx, &n);
+       status = smb2_notify_recv(req, tctx, &n);
        CHECK_STATUS(status, NT_STATUS_INVALID_PARAMETER);
 
 done: