summaryrefslogtreecommitdiff
path: root/source4/torture/smb2
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2008-05-28 08:11:05 +1000
committerAndrew Bartlett <abartlet@samba.org>2008-05-28 08:11:05 +1000
commit51ae2302a68033b1b79a4ebc8d4cbab64adcf843 (patch)
treed8b1af54efe4ec70607ef2bcbd873c2cd667d894 /source4/torture/smb2
parent5d0d239d1ab826c91839a603f93d2c0061658888 (diff)
parent52b230141b5ad9f317f97e7d257703614bab3985 (diff)
downloadsamba-51ae2302a68033b1b79a4ebc8d4cbab64adcf843.tar.gz
samba-51ae2302a68033b1b79a4ebc8d4cbab64adcf843.tar.bz2
samba-51ae2302a68033b1b79a4ebc8d4cbab64adcf843.zip
Merge branch 'v4-0-test' of ssh://git.samba.org/data/git/samba into 4-0-abartlet
It seems the format of main.mk changed in my sleep... Conflicts: source/main.mk (This used to be commit 56f2288e4f4f1aa70d11fc5f118458baf5803627)
Diffstat (limited to 'source4/torture/smb2')
-rw-r--r--source4/torture/smb2/config.mk4
-rw-r--r--source4/torture/smb2/connect.c6
-rw-r--r--source4/torture/smb2/create.c201
-rw-r--r--source4/torture/smb2/getinfo.c12
-rw-r--r--source4/torture/smb2/lock.c110
-rw-r--r--source4/torture/smb2/read.c141
-rw-r--r--source4/torture/smb2/smb2.c2
7 files changed, 461 insertions, 15 deletions
diff --git a/source4/torture/smb2/config.mk b/source4/torture/smb2/config.mk
index 11c4e1fa2c..9785303629 100644
--- a/source4/torture/smb2/config.mk
+++ b/source4/torture/smb2/config.mk
@@ -20,7 +20,9 @@ TORTURE_SMB2_OBJ_FILES = $(addprefix $(torturesrcdir)/smb2/, \
notify.o \
smb2.o \
persistent_handles.o \
- oplocks.o)
+ oplocks.o \
+ create.o \
+ read.o)
$(eval $(call proto_header_template,$(torturesrcdir)/smb2/proto.h,$(TORTURE_SMB2_OBJ_FILES:.o=.c)))
diff --git a/source4/torture/smb2/connect.c b/source4/torture/smb2/connect.c
index 0004ea958e..826bb2d719 100644
--- a/source4/torture/smb2/connect.c
+++ b/source4/torture/smb2/connect.c
@@ -139,7 +139,7 @@ static NTSTATUS torture_smb2_write(struct torture_context *tctx, struct smb2_tre
/*
send a create
*/
-static struct smb2_handle torture_smb2_create(struct smb2_tree *tree,
+static struct smb2_handle torture_smb2_createfile(struct smb2_tree *tree,
const char *fname)
{
struct smb2_create io;
@@ -200,8 +200,8 @@ bool torture_smb2_connect(struct torture_context *torture)
return false;
}
- h1 = torture_smb2_create(tree, "test9.dat");
- h2 = torture_smb2_create(tree, "test9.dat");
+ h1 = torture_smb2_createfile(tree, "test9.dat");
+ h2 = torture_smb2_createfile(tree, "test9.dat");
status = torture_smb2_write(torture, tree, h1);
if (!NT_STATUS_IS_OK(status)) {
printf("Write failed - %s\n", nt_errstr(status));
diff --git a/source4/torture/smb2/create.c b/source4/torture/smb2/create.c
new file mode 100644
index 0000000000..9c9e7e2997
--- /dev/null
+++ b/source4/torture/smb2/create.c
@@ -0,0 +1,201 @@
+/*
+ Unix SMB/CIFS implementation.
+
+ SMB2 create test suite
+
+ Copyright (C) Andrew Tridgell 2008
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "includes.h"
+#include "libcli/smb2/smb2.h"
+#include "libcli/smb2/smb2_calls.h"
+#include "torture/torture.h"
+#include "torture/smb2/proto.h"
+#include "param/param.h"
+#include "librpc/gen_ndr/ndr_security.h"
+
+#define FNAME "test_create.dat"
+
+#define CHECK_STATUS(status, correct) do { \
+ if (!NT_STATUS_EQUAL(status, correct)) { \
+ printf("(%s) Incorrect status %s - should be %s\n", \
+ __location__, nt_errstr(status), nt_errstr(correct)); \
+ return false; \
+ }} while (0)
+
+#define CHECK_EQUAL(v, correct) do { \
+ if (v != correct) { \
+ printf("(%s) Incorrect value for %s 0x%08x - should be 0x%08x\n", \
+ __location__, #v, v, correct); \
+ return false; \
+ }} while (0)
+
+/*
+ test some interesting combinations found by gentest
+ */
+bool torture_smb2_create_gentest(struct torture_context *torture, struct smb2_tree *tree)
+{
+ struct smb2_create io;
+ NTSTATUS status;
+ TALLOC_CTX *tmp_ctx = talloc_new(tree);
+ uint32_t access_mask, file_attributes, denied_mask;
+
+ ZERO_STRUCT(io);
+ io.in.desired_access = SEC_FLAG_MAXIMUM_ALLOWED;
+ io.in.file_attributes = FILE_ATTRIBUTE_NORMAL;
+ io.in.create_disposition = NTCREATEX_DISP_OVERWRITE_IF;
+ io.in.share_access =
+ NTCREATEX_SHARE_ACCESS_DELETE|
+ NTCREATEX_SHARE_ACCESS_READ|
+ NTCREATEX_SHARE_ACCESS_WRITE;
+ io.in.create_options = 0;
+ io.in.fname = FNAME;
+
+ status = smb2_create(tree, tmp_ctx, &io);
+ CHECK_STATUS(status, NT_STATUS_OK);
+
+ status = smb2_util_close(tree, io.out.file.handle);
+ CHECK_STATUS(status, NT_STATUS_OK);
+
+ io.in.create_options = 0xF0000000;
+ status = smb2_create(tree, tmp_ctx, &io);
+ CHECK_STATUS(status, NT_STATUS_INVALID_PARAMETER);
+
+ io.in.create_options = 0x00100000;
+ status = smb2_create(tree, tmp_ctx, &io);
+ CHECK_STATUS(status, NT_STATUS_NOT_SUPPORTED);
+
+ io.in.create_options = 0xF0100000;
+ status = smb2_create(tree, tmp_ctx, &io);
+ CHECK_STATUS(status, NT_STATUS_NOT_SUPPORTED);
+
+ io.in.create_options = 0;
+
+ io.in.file_attributes = FILE_ATTRIBUTE_DEVICE;
+ status = smb2_create(tree, tmp_ctx, &io);
+ CHECK_STATUS(status, NT_STATUS_INVALID_PARAMETER);
+
+ io.in.file_attributes = FILE_ATTRIBUTE_VOLUME;
+ status = smb2_create(tree, tmp_ctx, &io);
+ CHECK_STATUS(status, NT_STATUS_INVALID_PARAMETER);
+
+ io.in.create_disposition = NTCREATEX_DISP_OPEN;
+ io.in.file_attributes = FILE_ATTRIBUTE_VOLUME;
+ status = smb2_create(tree, tmp_ctx, &io);
+ CHECK_STATUS(status, NT_STATUS_INVALID_PARAMETER);
+
+ io.in.create_disposition = NTCREATEX_DISP_CREATE;
+ io.in.desired_access = 0x08000000;
+ status = smb2_create(tree, tmp_ctx, &io);
+ CHECK_STATUS(status, NT_STATUS_ACCESS_DENIED);
+
+ io.in.desired_access = 0x04000000;
+ status = smb2_create(tree, tmp_ctx, &io);
+ CHECK_STATUS(status, NT_STATUS_ACCESS_DENIED);
+
+ io.in.create_disposition = NTCREATEX_DISP_OPEN_IF;
+ io.in.file_attributes = 0;
+ access_mask = 0;
+ {
+ int i;
+ for (i=0;i<32;i++) {
+ io.in.desired_access = 1<<i;
+ status = smb2_create(tree, tmp_ctx, &io);
+ if (NT_STATUS_EQUAL(status, NT_STATUS_ACCESS_DENIED)) {
+ access_mask |= io.in.desired_access;
+ } else {
+ CHECK_STATUS(status, NT_STATUS_OK);
+ status = smb2_util_close(tree, io.out.file.handle);
+ CHECK_STATUS(status, NT_STATUS_OK);
+ }
+ }
+ }
+
+ CHECK_EQUAL(access_mask, 0x0df0fe00);
+
+ io.in.create_disposition = NTCREATEX_DISP_OPEN_IF;
+ io.in.desired_access = SEC_FLAG_MAXIMUM_ALLOWED;
+ io.in.file_attributes = 0;
+ file_attributes = 0;
+ denied_mask = 0;
+ {
+ int i;
+ for (i=0;i<32;i++) {
+ io.in.file_attributes = 1<<i;
+ smb2_deltree(tree, FNAME);
+ status = smb2_create(tree, tmp_ctx, &io);
+ if (NT_STATUS_EQUAL(status, NT_STATUS_INVALID_PARAMETER)) {
+ file_attributes |= io.in.file_attributes;
+ } else if (NT_STATUS_EQUAL(status, NT_STATUS_ACCESS_DENIED)) {
+ denied_mask |= io.in.file_attributes;
+ } else {
+ CHECK_STATUS(status, NT_STATUS_OK);
+ status = smb2_util_close(tree, io.out.file.handle);
+ CHECK_STATUS(status, NT_STATUS_OK);
+ }
+ }
+ }
+
+ CHECK_EQUAL(file_attributes, 0xffff8048);
+ CHECK_EQUAL(denied_mask, 0x4000);
+
+ smb2_deltree(tree, FNAME);
+
+ ZERO_STRUCT(io);
+ io.in.desired_access = SEC_FLAG_MAXIMUM_ALLOWED;
+ io.in.file_attributes = 0;
+ io.in.create_disposition = NTCREATEX_DISP_OVERWRITE_IF;
+ io.in.share_access =
+ NTCREATEX_SHARE_ACCESS_READ|
+ NTCREATEX_SHARE_ACCESS_WRITE;
+ io.in.create_options = 0;
+ io.in.fname = FNAME ":stream1";
+ status = smb2_create(tree, tmp_ctx, &io);
+ CHECK_STATUS(status, NT_STATUS_OK);
+
+ io.in.fname = FNAME;
+ io.in.file_attributes = 0x8040;
+ io.in.share_access =
+ NTCREATEX_SHARE_ACCESS_READ;
+ status = smb2_create(tree, tmp_ctx, &io);
+ CHECK_STATUS(status, NT_STATUS_INVALID_PARAMETER);
+
+ talloc_free(tmp_ctx);
+
+ return true;
+}
+
+/*
+ basic testing of SMB2 create calls
+*/
+bool torture_smb2_create(struct torture_context *torture)
+{
+ TALLOC_CTX *mem_ctx = talloc_new(NULL);
+ struct smb2_tree *tree;
+ bool ret = true;
+
+ if (!torture_smb2_connection(torture, &tree)) {
+ return false;
+ }
+
+ ret &= torture_smb2_create_gentest(torture, tree);
+
+ smb2_deltree(tree, FNAME);
+
+ talloc_free(mem_ctx);
+
+ return ret;
+}
diff --git a/source4/torture/smb2/getinfo.c b/source4/torture/smb2/getinfo.c
index c47a26277c..906d6e4f8d 100644
--- a/source4/torture/smb2/getinfo.c
+++ b/source4/torture/smb2/getinfo.c
@@ -51,9 +51,9 @@ static struct {
{ LEVEL(RAW_FILEINFO_COMPRESSION_INFORMATION) },
{ LEVEL(RAW_FILEINFO_NETWORK_OPEN_INFORMATION) },
{ LEVEL(RAW_FILEINFO_ATTRIBUTE_TAG_INFORMATION) },
-/*
-disabled until we know how the alignment now works
-{ LEVEL(RAW_FILEINFO_SMB2_ALL_EAS) }, */
+/*
+ { LEVEL(RAW_FILEINFO_SMB2_ALL_EAS) },
+*/
{ LEVEL(RAW_FILEINFO_SMB2_ALL_INFORMATION) },
{ LEVEL(RAW_FILEINFO_SEC_DESC) }
};
@@ -107,9 +107,6 @@ static bool torture_smb2_fileinfo(struct torture_context *tctx, struct smb2_tree
file_levels[i].dinfo.query_secdesc.in.secinfo_flags = 0x7;
}
if (file_levels[i].level == RAW_FILEINFO_SMB2_ALL_EAS) {
- if (torture_setting_bool(tctx, "samba4", false)) {
- continue;
- }
file_levels[i].finfo.all_eas.in.continue_flags =
SMB2_CONTINUE_FLAG_RESTART;
file_levels[i].dinfo.all_eas.in.continue_flags =
@@ -183,6 +180,9 @@ bool torture_smb2_getinfo(struct torture_context *torture)
return false;
}
+ smb2_deltree(tree, FNAME);
+ smb2_deltree(tree, DNAME);
+
status = torture_setup_complex_file(tree, FNAME);
if (!NT_STATUS_IS_OK(status)) {
return false;
diff --git a/source4/torture/smb2/lock.c b/source4/torture/smb2/lock.c
index e81647b497..4e21045a33 100644
--- a/source4/torture/smb2/lock.c
+++ b/source4/torture/smb2/lock.c
@@ -51,7 +51,7 @@ static bool test_valid_request(struct torture_context *torture, struct smb2_tree
struct smb2_handle h;
uint8_t buf[200];
struct smb2_lock lck;
- struct smb2_lock_element el[1];
+ struct smb2_lock_element el[2];
ZERO_STRUCT(buf);
@@ -90,7 +90,7 @@ static bool test_valid_request(struct torture_context *torture, struct smb2_tree
lck.in.file.handle.data[0] -=1;
lck.in.lock_count = 0x0001;
- lck.in.reserved = 0xFFFFFFFF;
+ lck.in.reserved = 0x123ab1;
lck.in.file.handle = h;
el[0].offset = UINT64_MAX;
el[0].length = UINT64_MAX;
@@ -100,16 +100,20 @@ static bool test_valid_request(struct torture_context *torture, struct smb2_tree
CHECK_STATUS(status, NT_STATUS_OK);
CHECK_VALUE(lck.out.reserved, 0);
+ lck.in.reserved = 0x123ab2;
status = smb2_lock(tree, &lck);
CHECK_STATUS(status, NT_STATUS_LOCK_NOT_GRANTED);
+ lck.in.reserved = 0x123ab3;
status = smb2_lock(tree, &lck);
CHECK_STATUS(status, NT_STATUS_OK);
CHECK_VALUE(lck.out.reserved, 0);
+ lck.in.reserved = 0x123ab4;
status = smb2_lock(tree, &lck);
CHECK_STATUS(status, NT_STATUS_LOCK_NOT_GRANTED);
+ lck.in.reserved = 0x123ab5;
status = smb2_lock(tree, &lck);
CHECK_STATUS(status, NT_STATUS_OK);
CHECK_VALUE(lck.out.reserved, 0);
@@ -162,27 +166,123 @@ static bool test_valid_request(struct torture_context *torture, struct smb2_tree
lck.in.file.handle = h;
el[0].offset = 0x00000000FFFFFFFF;
el[0].length = 0x00000000FFFFFFFF;
- el[0].reserved = 0x12345678;
+ el[0].reserved = 0x1234567;
el[0].flags = SMB2_LOCK_FLAG_UNLOCK;
status = smb2_lock(tree, &lck);
- CHECK_STATUS(status, NT_STATUS_RANGE_NOT_LOCKED);
+ CHECK_STATUS(status, NT_STATUS_OK);
lck.in.lock_count = 0x0001;
- lck.in.reserved = 0x12345678;
+ lck.in.reserved = 0x1234567;
lck.in.file.handle = h;
el[0].offset = 0x00000000FFFFFFFF;
el[0].length = 0x00000000FFFFFFFF;
el[0].reserved = 0x00000000;
el[0].flags = SMB2_LOCK_FLAG_UNLOCK;
status = smb2_lock(tree, &lck);
+ CHECK_STATUS(status, NT_STATUS_OK);
+
+ status = smb2_lock(tree, &lck);
+ CHECK_STATUS(status, NT_STATUS_OK);
+ status = smb2_lock(tree, &lck);
+ CHECK_STATUS(status, NT_STATUS_OK);
+ status = smb2_lock(tree, &lck);
+ CHECK_STATUS(status, NT_STATUS_OK);
+ status = smb2_lock(tree, &lck);
CHECK_STATUS(status, NT_STATUS_RANGE_NOT_LOCKED);
+ lck.in.lock_count = 0x0001;
+ lck.in.reserved = 0;
+ lck.in.file.handle = h;
+ el[0].offset = 1;
+ el[0].length = 1;
+ el[0].reserved = 0x00000000;
+ el[0].flags = ~SMB2_LOCK_FLAG_ALL_MASK;
+
+ status = smb2_lock(tree, &lck);
+ CHECK_STATUS(status, NT_STATUS_OK);
+
+ el[0].flags = SMB2_LOCK_FLAG_UNLOCK;
+ status = smb2_lock(tree, &lck);
+ CHECK_STATUS(status, NT_STATUS_OK);
+
+ el[0].flags = SMB2_LOCK_FLAG_UNLOCK;
status = smb2_lock(tree, &lck);
CHECK_STATUS(status, NT_STATUS_RANGE_NOT_LOCKED);
+
+ el[0].flags = SMB2_LOCK_FLAG_UNLOCK | SMB2_LOCK_FLAG_EXCLUSIVE;
+ status = smb2_lock(tree, &lck);
+ CHECK_STATUS(status, NT_STATUS_INVALID_PARAMETER);
+
+ el[0].flags = SMB2_LOCK_FLAG_UNLOCK | SMB2_LOCK_FLAG_SHARED;
+ status = smb2_lock(tree, &lck);
+ CHECK_STATUS(status, NT_STATUS_INVALID_PARAMETER);
+
+ el[0].flags = SMB2_LOCK_FLAG_UNLOCK | SMB2_LOCK_FLAG_FAIL_IMMEDIATELY;
status = smb2_lock(tree, &lck);
CHECK_STATUS(status, NT_STATUS_RANGE_NOT_LOCKED);
+
+ lck.in.lock_count = 2;
+ lck.in.reserved = 0;
+ lck.in.file.handle = h;
+ el[0].offset = 9999;
+ el[0].length = 1;
+ el[0].reserved = 0x00000000;
+ el[1].offset = 9999;
+ el[1].length = 1;
+ el[1].reserved = 0x00000000;
+
+ lck.in.lock_count = 2;
+ el[0].flags = 0;
+ el[1].flags = SMB2_LOCK_FLAG_UNLOCK;
+ status = smb2_lock(tree, &lck);
+ CHECK_STATUS(status, NT_STATUS_INVALID_PARAMETER);
+
+ lck.in.lock_count = 2;
+ el[0].flags = 0;
+ el[1].flags = 0;
+ status = smb2_lock(tree, &lck);
+ CHECK_STATUS(status, NT_STATUS_OK);
+
+ lck.in.lock_count = 2;
+ el[0].flags = SMB2_LOCK_FLAG_UNLOCK;
+ el[1].flags = 0;
+ status = smb2_lock(tree, &lck);
+ CHECK_STATUS(status, NT_STATUS_OK);
+
+ lck.in.lock_count = 1;
+ el[0].flags = SMB2_LOCK_FLAG_UNLOCK;
+ status = smb2_lock(tree, &lck);
+ CHECK_STATUS(status, NT_STATUS_OK);
+
+ lck.in.lock_count = 1;
+ el[0].flags = SMB2_LOCK_FLAG_UNLOCK;
+ status = smb2_lock(tree, &lck);
+ CHECK_STATUS(status, NT_STATUS_OK);
+
+ lck.in.lock_count = 1;
+ el[0].flags = SMB2_LOCK_FLAG_UNLOCK;
+ status = smb2_lock(tree, &lck);
+ CHECK_STATUS(status, NT_STATUS_RANGE_NOT_LOCKED);
+
+ lck.in.lock_count = 1;
+ el[0].flags = 0;
+ status = smb2_lock(tree, &lck);
+ CHECK_STATUS(status, NT_STATUS_OK);
+
+ status = smb2_lock(tree, &lck);
+ CHECK_STATUS(status, NT_STATUS_OK);
+
+ lck.in.lock_count = 2;
+ el[0].flags = SMB2_LOCK_FLAG_UNLOCK;
+ el[1].flags = SMB2_LOCK_FLAG_UNLOCK;
+ status = smb2_lock(tree, &lck);
+ CHECK_STATUS(status, NT_STATUS_OK);
+
+ lck.in.lock_count = 1;
+ el[0].flags = SMB2_LOCK_FLAG_UNLOCK;
status = smb2_lock(tree, &lck);
CHECK_STATUS(status, NT_STATUS_RANGE_NOT_LOCKED);
+
done:
return ret;
diff --git a/source4/torture/smb2/read.c b/source4/torture/smb2/read.c
new file mode 100644
index 0000000000..3e1d077b7d
--- /dev/null
+++ b/source4/torture/smb2/read.c
@@ -0,0 +1,141 @@
+/*
+ Unix SMB/CIFS implementation.
+
+ SMB2 read test suite
+
+ Copyright (C) Andrew Tridgell 2008
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "includes.h"
+#include "libcli/smb2/smb2.h"
+#include "libcli/smb2/smb2_calls.h"
+
+#include "torture/torture.h"
+#include "torture/smb2/proto.h"
+
+#include "librpc/gen_ndr/ndr_security.h"
+
+#define CHECK_STATUS(status, correct) do { \
+ if (!NT_STATUS_EQUAL(status, correct)) { \
+ printf("(%s) Incorrect status %s - should be %s\n", \
+ __location__, nt_errstr(status), nt_errstr(correct)); \
+ ret = false; \
+ goto done; \
+ }} while (0)
+
+#define CHECK_VALUE(v, correct) do { \
+ if ((v) != (correct)) { \
+ printf("(%s) Incorrect value %s=%d - should be %d\n", \
+ __location__, #v, v, correct); \
+ ret = false; \
+ goto done; \
+ }} while (0)
+
+static bool test_read(struct torture_context *torture, struct smb2_tree *tree)
+{
+ bool ret = true;
+ NTSTATUS status;
+ struct smb2_handle h;
+ uint8_t buf[70000];
+ struct smb2_read rd;
+ TALLOC_CTX *tmp_ctx = talloc_new(tree);
+
+ ZERO_STRUCT(buf);
+
+ status = torture_smb2_testfile(tree, "lock1.txt", &h);
+ CHECK_STATUS(status, NT_STATUS_OK);
+
+ status = smb2_util_write(tree, h, buf, 0, ARRAY_SIZE(buf));
+ CHECK_STATUS(status, NT_STATUS_OK);
+
+ ZERO_STRUCT(rd);
+ rd.in.file.handle = h;
+ rd.in.length = 10;
+ rd.in.offset = 0;
+ rd.in.min_count = 1;
+
+ status = smb2_read(tree, tmp_ctx, &rd);
+ CHECK_STATUS(status, NT_STATUS_OK);
+ CHECK_VALUE(rd.out.data.length, 10);
+
+ rd.in.min_count = 0;
+ rd.in.length = 10;
+ rd.in.offset = sizeof(buf);
+ status = smb2_read(tree, tmp_ctx, &rd);
+ CHECK_STATUS(status, NT_STATUS_END_OF_FILE);
+
+ rd.in.min_count = 0;
+ rd.in.length = 0;
+ rd.in.offset = sizeof(buf);
+ status = smb2_read(tree, tmp_ctx, &rd);
+ CHECK_STATUS(status, NT_STATUS_OK);
+ CHECK_VALUE(rd.out.data.length, 0);
+
+ rd.in.min_count = 1;
+ rd.in.length = 0;
+ rd.in.offset = sizeof(buf);
+ status = smb2_read(tree, tmp_ctx, &rd);
+ CHECK_STATUS(status, NT_STATUS_END_OF_FILE);
+
+ rd.in.min_count = 0;
+ rd.in.length = 2;
+ rd.in.offset = sizeof(buf) - 1;
+ status = smb2_read(tree, tmp_ctx, &rd);
+ CHECK_STATUS(status, NT_STATUS_OK);
+ CHECK_VALUE(rd.out.data.length, 1);
+
+ rd.in.min_count = 2;
+ rd.in.length = 1;
+ rd.in.offset = sizeof(buf) - 1;
+ status = smb2_read(tree, tmp_ctx, &rd);
+ CHECK_STATUS(status, NT_STATUS_END_OF_FILE);
+
+ rd.in.min_count = 0x10000;
+ rd.in.length = 1;
+ rd.in.offset = 0;
+ status = smb2_read(tree, tmp_ctx, &rd);
+ CHECK_STATUS(status, NT_STATUS_END_OF_FILE);
+
+ rd.in.min_count = 0x10000 - 2;
+ rd.in.length = 1;
+ rd.in.offset = 0;
+ status = smb2_read(tree, tmp_ctx, &rd);
+ CHECK_STATUS(status, NT_STATUS_END_OF_FILE);
+
+ rd.in.min_count = 10;
+ rd.in.length = 5;
+ rd.in.offset = 0;
+ status = smb2_read(tree, tmp_ctx, &rd);
+ CHECK_STATUS(status, NT_STATUS_END_OF_FILE);
+
+done:
+ talloc_free(tmp_ctx);
+ return ret;
+}
+
+/* basic testing of SMB2 read
+*/
+struct torture_suite *torture_smb2_read_init(void)
+{
+ struct torture_suite *suite = torture_suite_create(talloc_autofree_context(), "READ");
+
+ torture_suite_add_1smb2_test(suite, "READ", test_read);
+
+ suite->description = talloc_strdup(suite, "SMB2-READ tests");
+
+ return suite;
+}
+
diff --git a/source4/torture/smb2/smb2.c b/source4/torture/smb2/smb2.c
index 37eadcf7fd..f813148e1d 100644
--- a/source4/torture/smb2/smb2.c
+++ b/source4/torture/smb2/smb2.c
@@ -135,7 +135,9 @@ NTSTATUS torture_smb2_init(void)
torture_suite_add_simple_test(suite, "GETINFO", torture_smb2_getinfo);
torture_suite_add_simple_test(suite, "SETINFO", torture_smb2_setinfo);
torture_suite_add_simple_test(suite, "FIND", torture_smb2_find);
+ torture_suite_add_simple_test(suite, "CREATE", torture_smb2_create);
torture_suite_add_suite(suite, torture_smb2_lock_init());
+ torture_suite_add_suite(suite, torture_smb2_read_init());
torture_suite_add_simple_test(suite, "NOTIFY", torture_smb2_notify);
torture_suite_add_2smb2_test(suite, "PERSISTENT-HANDLES1", torture_smb2_persistent_handles1);
torture_suite_add_1smb2_test(suite, "OPLOCK-BATCH1", torture_smb2_oplock_batch1);