summaryrefslogtreecommitdiffstats
path: root/source4
diff options
context:
space:
mode:
authorDavid Disseldorp <ddiss@samba.org>2014-09-02 20:07:15 +0200
committerJeremy Allison <jra@samba.org>2014-09-08 19:11:12 +0200
commit3fcbfa967ac61da85a959fada5a4d92b54f459eb (patch)
tree21f47b46a3a31b86910d71a184753a6eee626fe3 /source4
parentabe499be569c9087f007331d3ac2e48cea0e2cae (diff)
downloadsamba-3fcbfa967ac61da85a959fada5a4d92b54f459eb.tar.gz
samba-3fcbfa967ac61da85a959fada5a4d92b54f459eb.tar.xz
samba-3fcbfa967ac61da85a959fada5a4d92b54f459eb.zip
torture: test oversize FSCTL_SET_SPARSE request
Signed-off-by: David Disseldorp <ddiss@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'source4')
-rw-r--r--source4/torture/smb2/ioctl.c76
1 files changed, 76 insertions, 0 deletions
diff --git a/source4/torture/smb2/ioctl.c b/source4/torture/smb2/ioctl.c
index df98b048dc..3f8795872c 100644
--- a/source4/torture/smb2/ioctl.c
+++ b/source4/torture/smb2/ioctl.c
@@ -2718,6 +2718,80 @@ static bool test_ioctl_sparse_set_nobuf(struct torture_context *torture,
return true;
}
+static bool test_ioctl_sparse_set_oversize(struct torture_context *torture,
+ struct smb2_tree *tree)
+{
+ struct smb2_handle fh;
+ union smb_ioctl ioctl;
+ NTSTATUS status;
+ TALLOC_CTX *tmp_ctx = talloc_new(tree);
+ bool ok;
+ bool is_sparse;
+ uint8_t buf[100];
+
+ ok = test_setup_create_fill(torture, tree, tmp_ctx,
+ FNAME, &fh, 0, SEC_RIGHTS_FILE_ALL,
+ FILE_ATTRIBUTE_NORMAL);
+ torture_assert(torture, ok, "setup file");
+
+ status = test_ioctl_sparse_fs_supported(torture, tree, tmp_ctx, &fh,
+ &ok);
+ torture_assert_ntstatus_ok(torture, status, "SMB2_GETINFO_FS");
+ if (!ok) {
+ smb2_util_close(tree, fh);
+ torture_skip(torture, "Sparse files not supported\n");
+ }
+
+ status = test_sparse_get(torture, tmp_ctx, tree, fh, &is_sparse);
+ torture_assert_ntstatus_ok(torture, status, "test_sparse_get");
+ torture_assert(torture, !is_sparse, "sparse attr before set");
+
+ ZERO_STRUCT(ioctl);
+ ioctl.smb2.level = RAW_IOCTL_SMB2;
+ ioctl.smb2.in.file.handle = fh;
+ ioctl.smb2.in.function = FSCTL_SET_SPARSE;
+ ioctl.smb2.in.max_response_size = 0;
+ ioctl.smb2.in.flags = SMB2_IOCTL_FLAG_IS_FSCTL;
+
+ /*
+ * Attach a request buffer larger than FILE_SET_SPARSE_BUFFER
+ * Windows still successfully processes the request.
+ */
+ ZERO_ARRAY(buf);
+ buf[0] = 0xFF; /* attempt to set sparse */
+ ioctl.smb2.in.out.data = buf;
+ ioctl.smb2.in.out.length = ARRAY_SIZE(buf);
+
+ status = smb2_ioctl(tree, tmp_ctx, &ioctl.smb2);
+ torture_assert_ntstatus_ok(torture, status, "FSCTL_SET_SPARSE");
+
+ status = test_sparse_get(torture, tmp_ctx, tree, fh, &is_sparse);
+ torture_assert_ntstatus_ok(torture, status, "test_sparse_get");
+ torture_assert(torture, is_sparse, "no sparse attr after set");
+
+ ZERO_STRUCT(ioctl);
+ ioctl.smb2.level = RAW_IOCTL_SMB2;
+ ioctl.smb2.in.file.handle = fh;
+ ioctl.smb2.in.function = FSCTL_SET_SPARSE;
+ ioctl.smb2.in.max_response_size = 0;
+ ioctl.smb2.in.flags = SMB2_IOCTL_FLAG_IS_FSCTL;
+
+ ZERO_ARRAY(buf); /* clear sparse */
+ ioctl.smb2.in.out.data = buf;
+ ioctl.smb2.in.out.length = ARRAY_SIZE(buf);
+
+ status = smb2_ioctl(tree, tmp_ctx, &ioctl.smb2);
+ torture_assert_ntstatus_ok(torture, status, "FSCTL_SET_SPARSE");
+
+ status = test_sparse_get(torture, tmp_ctx, tree, fh, &is_sparse);
+ torture_assert_ntstatus_ok(torture, status, "test_sparse_get");
+ torture_assert(torture, !is_sparse, "sparse attr after clear");
+
+ smb2_util_close(tree, fh);
+ talloc_free(tmp_ctx);
+ return true;
+}
+
/*
* basic testing of SMB2 ioctls
*/
@@ -2793,6 +2867,8 @@ struct torture_suite *torture_smb2_ioctl_init(void)
test_ioctl_sparse_dir_flag);
torture_suite_add_1smb2_test(suite, "sparse_set_nobuf",
test_ioctl_sparse_set_nobuf);
+ torture_suite_add_1smb2_test(suite, "sparse_set_oversize",
+ test_ioctl_sparse_set_oversize);
suite->description = talloc_strdup(suite, "SMB2-IOCTL tests");