[PATCH] Add a test for 0-byte sized streams
Ralph Böhme
rb at sernet.de
Tue Sep 22 01:35:55 UTC 2015
Hi!
Attached is a patch with a new torture streams test that checks
whether 0-byte size streams are returned in a getinfo(streamlist).
Please review and push if ok. Thanks!
-Ralph
--
SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
phone: +49-551-370000-0, fax: +49-551-370000-9
AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
http://www.sernet.de,mailto:kontakt@sernet.de
-------------- next part --------------
From 862a93974da69e5d45bf07200bd02c900cb92308 Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow at samba.org>
Date: Tue, 22 Sep 2015 03:15:14 +0200
Subject: [PATCH] s4:torture: add a test for 0 byte sized streams
Signed-off-by: Ralph Boehme <slow at samba.org>
---
source4/torture/smb2/streams.c | 74 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 74 insertions(+)
diff --git a/source4/torture/smb2/streams.c b/source4/torture/smb2/streams.c
index 2db893c..688fd4c 100644
--- a/source4/torture/smb2/streams.c
+++ b/source4/torture/smb2/streams.c
@@ -484,6 +484,79 @@ done:
return ret;
}
+static bool test_zero_byte_stream(struct torture_context *tctx,
+ struct smb2_tree *tree)
+{
+ TALLOC_CTX *mem_ctx = talloc_new(tctx);
+ NTSTATUS status;
+ union smb_open io;
+ const char *fname = DNAME "\\stream.txt";
+ const char *sname;
+ bool ret = true;
+ struct smb2_handle h, bh;
+ const char *streams[] = { "::$DATA", ":foo:$DATA" };
+
+ sname = talloc_asprintf(mem_ctx, "%s:%s", fname, "foo");
+
+ smb2_util_unlink(tree, fname);
+ smb2_deltree(tree, DNAME);
+
+ status = torture_smb2_testdir(tree, DNAME, &h);
+ torture_assert_ntstatus_ok_goto(tctx, status, ret, done, "testdir");
+ smb2_util_close(tree, h);
+
+ torture_comment(tctx, "(%s) Check 0 byte named stream\n",
+ __location__);
+
+ /* Create basefile */
+ ZERO_STRUCT(io);
+ io.smb2.in.create_disposition = NTCREATEX_DISP_CREATE;
+ io.smb2.in.fname = fname;
+ io.smb2.in.desired_access = SEC_FILE_READ_ATTRIBUTE |
+ SEC_FILE_WRITE_ATTRIBUTE |
+ SEC_FILE_READ_DATA |
+ SEC_FILE_WRITE_DATA;
+ status = smb2_create(tree, mem_ctx, &(io.smb2));
+ torture_assert_ntstatus_ok_goto(tctx, status, ret, done, "create");
+ smb2_util_close(tree, io.smb2.out.file.handle);
+
+ /* Create named stream and close it */
+ ZERO_STRUCT(io);
+ io.smb2.in.create_disposition = NTCREATEX_DISP_CREATE;
+ io.smb2.in.fname = sname;
+ io.smb2.in.desired_access = SEC_FILE_READ_ATTRIBUTE |
+ SEC_FILE_WRITE_ATTRIBUTE |
+ SEC_FILE_READ_DATA |
+ SEC_FILE_WRITE_DATA;
+ status = smb2_create(tree, mem_ctx, &(io.smb2));
+ torture_assert_ntstatus_ok_goto(tctx, status, ret, done, "create");
+ smb2_util_close(tree, io.smb2.out.file.handle);
+
+ /*
+ * Check stream list, the 0 byte stream MUST be returned by
+ * the server.
+ */
+ ZERO_STRUCT(io);
+ io.smb2.in.fname = fname;
+ io.smb2.in.create_disposition = NTCREATEX_DISP_OPEN;
+ io.smb2.in.desired_access = SEC_FILE_READ_ATTRIBUTE |
+ SEC_FILE_WRITE_ATTRIBUTE |
+ SEC_FILE_READ_DATA |
+ SEC_FILE_WRITE_DATA;
+ status = smb2_create(tree, mem_ctx, &(io.smb2));
+ bh = io.smb2.out.file.handle;
+
+ ret = check_stream_list(tree,tctx, fname, 2, streams, bh);
+ torture_assert_goto(tctx, ret == ok, ret, done, "smb2_create");
+ smb2_util_close(tree, bh);
+
+done:
+ smb2_deltree(tree, DNAME);
+ talloc_free(mem_ctx);
+
+ return ret;
+}
+
/*
test stream sharemodes
*/
@@ -1754,6 +1827,7 @@ struct torture_suite *torture_smb2_streams_init(void)
torture_suite_add_1smb2_test(suite, "create-disposition", test_stream_create_disposition);
torture_suite_add_1smb2_test(suite, "attributes", test_stream_attributes);
torture_suite_add_1smb2_test(suite, "delete", test_stream_delete);
+ torture_suite_add_1smb2_test(suite, "zero-byte", test_zero_byte_stream);
suite->description = talloc_strdup(suite, "SMB2-STREAM tests");
--
2.1.0
More information about the samba-technical
mailing list