summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGordon Ross <gordon.ross@tintri.com>2021-04-19 18:31:13 -0400
committerJeremy Allison <jra@samba.org>2021-04-22 18:48:30 +0000
commit993ae77fba40f3758f0c1a66af687268c6e67e8c (patch)
tree5a7748448ea19ffc9b0b435efd9cea1115dcbc0e
parenta72bc3e15d3ed62e9ad2c0a97ce5d6d653abb048 (diff)
downloadsamba-993ae77fba40f3758f0c1a66af687268c6e67e8c.tar.gz
Fix sigsegv in check_stream in smbtorture smb2.streams.io
torture_comment calls need a struct torture_context arg, not its mem_ctx child. Use talloc_parent(). Also need to call torture_result somewhere on failure. Signed-off-by: Gordon Ross <gordon.ross@tintri.com> Reviewed-by: Jeremy Allison <jra@samba.org> Reviewed-by: David Mulder <dmulder@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Thu Apr 22 18:48:30 UTC 2021 on sn-devel-184
-rw-r--r--source4/torture/smb2/streams.c43
1 files changed, 28 insertions, 15 deletions
diff --git a/source4/torture/smb2/streams.c b/source4/torture/smb2/streams.c
index c0516b7cc80..814ed1666c7 100644
--- a/source4/torture/smb2/streams.c
+++ b/source4/torture/smb2/streams.c
@@ -91,7 +91,8 @@ static int qsort_stream(const struct stream_struct * s1, const struct stream_str
return strcmp(s1->stream_name.s, s2->stream_name.s);
}
-static bool check_stream(struct smb2_tree *tree,
+static bool check_stream(struct torture_context *tctx,
+ struct smb2_tree *tree,
const char *location,
TALLOC_CTX *mem_ctx,
const char *fname,
@@ -117,7 +118,7 @@ static bool check_stream(struct smb2_tree *tree,
if (value == NULL) {
return true;
} else {
- torture_comment(mem_ctx, "Unable to open stream %s\n",
+ torture_comment(tctx, "Unable to open stream %s\n",
full_name);
return false;
}
@@ -137,13 +138,13 @@ static bool check_stream(struct smb2_tree *tree,
status = smb2_read(tree, tree, &r);
if (!NT_STATUS_IS_OK(status)) {
- torture_comment(mem_ctx, "(%s) Failed to read %lu bytes from "
+ torture_comment(tctx, "(%s) Failed to read %lu bytes from "
"stream '%s'\n", location, (long)strlen(value), full_name);
return false;
}
if (memcmp(r.out.data.data, value, strlen(value)) != 0) {
- torture_comment(mem_ctx, "(%s) Bad data in stream\n", location);
+ torture_comment(tctx, "(%s) Bad data in stream\n", location);
return false;
}
@@ -349,7 +350,7 @@ static bool test_stream_io(struct torture_context *tctx,
CHECK_STATUS(status, NT_STATUS_OK);
h2 = io.smb2.out.file.handle;
- ret &= check_stream(tree, __location__, mem_ctx, fname,
+ ret &= check_stream(tctx, tree, __location__, mem_ctx, fname,
"Stream One", NULL);
torture_comment(tctx, "(%s) check that open of base file is allowed\n", __location__);
@@ -365,7 +366,7 @@ static bool test_stream_io(struct torture_context *tctx,
smb2_util_close(tree, h2);
- ret &= check_stream(tree, __location__, mem_ctx, fname,
+ ret &= check_stream(tctx, tree, __location__, mem_ctx, fname,
"Stream One", "test data");
io.smb2.in.create_disposition = NTCREATEX_DISP_OPEN;
@@ -380,7 +381,7 @@ static bool test_stream_io(struct torture_context *tctx,
smb2_util_close(tree, h2);
- ret &= check_stream(tree, __location__, mem_ctx, fname,
+ ret &= check_stream(tctx, tree, __location__, mem_ctx, fname,
"Stream One:$FOO", NULL);
torture_comment(tctx, "(%s) creating a stream2 on a existing file\n",
@@ -396,29 +397,41 @@ static bool test_stream_io(struct torture_context *tctx,
CHECK_STATUS(status, NT_STATUS_OK);
smb2_util_close(tree, h2);
- ret &= check_stream(tree, __location__, mem_ctx, fname,
+ ret &= check_stream(tctx, tree, __location__, mem_ctx, fname,
"Stream One", "test MORE DATA ");
- ret &= check_stream(tree, __location__, mem_ctx, fname,
+ ret &= check_stream(tctx, tree, __location__, mem_ctx, fname,
"Stream One:$DATA", "test MORE DATA ");
- ret &= check_stream(tree, __location__, mem_ctx, fname,
+ ret &= check_stream(tctx, tree, __location__, mem_ctx, fname,
"Stream One:", NULL);
- ret &= check_stream(tree, __location__, mem_ctx, fname,
+ if (!ret) {
+ torture_result(tctx, TORTURE_FAIL,
+ "check_stream(\"Stream One:*\") failed\n");
+ goto done;
+ }
+
+ ret &= check_stream(tctx, tree, __location__, mem_ctx, fname,
"Second Stream", "SECOND STREAM");
- ret &= check_stream(tree, __location__, mem_ctx, fname,
+ ret &= check_stream(tctx, tree, __location__, mem_ctx, fname,
"SECOND STREAM:$DATA", "SECOND STREAM");
- ret &= check_stream(tree, __location__, mem_ctx, fname,
+ ret &= check_stream(tctx, tree, __location__, mem_ctx, fname,
"Second Stream:$DATA", "SECOND STREAM");
- ret &= check_stream(tree, __location__, mem_ctx, fname,
+ ret &= check_stream(tctx, tree, __location__, mem_ctx, fname,
"Second Stream:", NULL);
- ret &= check_stream(tree, __location__, mem_ctx, fname,
+ ret &= check_stream(tctx, tree, __location__, mem_ctx, fname,
"Second Stream:$FOO", NULL);
+ if (!ret) {
+ torture_result(tctx, TORTURE_FAIL,
+ "check_stream(\"Second Stream:*\") failed\n");
+ goto done;
+ }
+
io.smb2.in.fname = sname2;
io.smb2.in.create_disposition = NTCREATEX_DISP_OPEN_IF;
status = smb2_create(tree, mem_ctx, &(io.smb2));