>From 1e2b7eff6eefa0a412603ef575d7d9955752e0c1 Mon Sep 17 00:00:00 2001 From: Douglas Bagnall Date: Fri, 19 Jun 2015 15:20:26 +1200 Subject: [PATCH 1/2] Avoid segfault in durable_open tests There are "goto done"s hiding in CHECK_STATUS in parts of the code where tree1 is unequivocally NULL. Signed-off-by: Douglas Bagnall --- source4/torture/smb2/durable_open.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/source4/torture/smb2/durable_open.c b/source4/torture/smb2/durable_open.c index fd6af33..7bb8e75 100644 --- a/source4/torture/smb2/durable_open.c +++ b/source4/torture/smb2/durable_open.c @@ -2136,12 +2136,14 @@ static bool test_durable_open_open2_lease(struct torture_context *tctx, h1 = io1.out.file.handle; done: + if (tree1){ + smb2_util_close(tree1, h1); + smb2_util_unlink(tree1, fname); + talloc_free(tree1); + } + smb2_util_close(tree2, h2); smb2_util_unlink(tree2, fname); - smb2_util_close(tree1, h1); - smb2_util_unlink(tree1, fname); - - talloc_free(tree1); talloc_free(tree2); return ret; -- 1.9.1 >From 62c81c570ed8ad0de3ea78a6d2439342159c85e0 Mon Sep 17 00:00:00 2001 From: Douglas Bagnall Date: Fri, 19 Jun 2015 15:25:02 +1200 Subject: [PATCH 2/2] rename CHECK_STATUS in durable_open.c CHECK_STATUS() hides a `goto done` in its heart. If we rename it to CHECK_STATUS_OR_GOTO_DONE() the secret is out. Signed-off-by: Douglas Bagnall --- source4/torture/smb2/durable_open.c | 162 ++++++++++++++++++------------------ 1 file changed, 81 insertions(+), 81 deletions(-) diff --git a/source4/torture/smb2/durable_open.c b/source4/torture/smb2/durable_open.c index 7bb8e75..33ac942 100644 --- a/source4/torture/smb2/durable_open.c +++ b/source4/torture/smb2/durable_open.c @@ -49,7 +49,7 @@ ret = false; \ }} while (0) -#define CHECK_STATUS(status, correct) do { \ +#define CHECK_STATUS_OR_GOTO_DONE(status, correct) do { \ if (!NT_STATUS_EQUAL(status, correct)) { \ torture_result(tctx, TORTURE_FAIL, __location__": Incorrect status %s - should be %s", \ nt_errstr(status), nt_errstr(correct)); \ @@ -153,7 +153,7 @@ static bool test_one_durable_open_open_oplock(struct torture_context *tctx, io.in.durable_open = true; status = smb2_create(tree, mem_ctx, &io); - CHECK_STATUS(status, NT_STATUS_OK); + CHECK_STATUS_OR_GOTO_DONE(status, NT_STATUS_OK); _h = io.out.file.handle; h = &_h; CHECK_CREATED(&io, CREATED, FILE_ATTRIBUTE_ARCHIVE); @@ -298,7 +298,7 @@ static bool test_one_durable_open_open_lease(struct torture_context *tctx, io.in.durable_open = true; status = smb2_create(tree, mem_ctx, &io); - CHECK_STATUS(status, NT_STATUS_OK); + CHECK_STATUS_OR_GOTO_DONE(status, NT_STATUS_OK); _h = io.out.file.handle; h = &_h; CHECK_CREATED(&io, CREATED, FILE_ATTRIBUTE_ARCHIVE); @@ -386,7 +386,7 @@ static bool test_durable_open_reopen1(struct torture_context *tctx, io1.in.durable_open = true; status = smb2_create(tree, mem_ctx, &io1); - CHECK_STATUS(status, NT_STATUS_OK); + CHECK_STATUS_OR_GOTO_DONE(status, NT_STATUS_OK); _h = io1.out.file.handle; h = &_h; CHECK_CREATED(&io1, CREATED, FILE_ATTRIBUTE_ARCHIVE); @@ -399,7 +399,7 @@ static bool test_durable_open_reopen1(struct torture_context *tctx, io2.in.durable_handle = h; status = smb2_create(tree, mem_ctx, &io2); - CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_NOT_FOUND); + CHECK_STATUS_OR_GOTO_DONE(status, NT_STATUS_OBJECT_NAME_NOT_FOUND); done: if (h != NULL) { @@ -451,7 +451,7 @@ static bool test_durable_open_reopen1a(struct torture_context *tctx, io1.in.durable_open = true; status = smb2_create(tree, mem_ctx, &io1); - CHECK_STATUS(status, NT_STATUS_OK); + CHECK_STATUS_OR_GOTO_DONE(status, NT_STATUS_OK); _h = io1.out.file.handle; h = &_h; CHECK_CREATED(&io1, CREATED, FILE_ATTRIBUTE_ARCHIVE); @@ -481,7 +481,7 @@ static bool test_durable_open_reopen1a(struct torture_context *tctx, io2.in.durable_handle = h; status = smb2_create(tree, mem_ctx, &io2); - CHECK_STATUS(status, NT_STATUS_USER_SESSION_DELETED); + CHECK_STATUS_OR_GOTO_DONE(status, NT_STATUS_USER_SESSION_DELETED); /* * but a durable reconnect on the new session succeeds: @@ -492,7 +492,7 @@ static bool test_durable_open_reopen1a(struct torture_context *tctx, io2.in.durable_handle = h; status = smb2_create(tree2, mem_ctx, &io2); - CHECK_STATUS(status, NT_STATUS_OK); + CHECK_STATUS_OR_GOTO_DONE(status, NT_STATUS_OK); CHECK_CREATED(&io2, EXISTED, FILE_ATTRIBUTE_ARCHIVE); CHECK_VAL(io2.out.oplock_level, smb2_util_oplock_level("b")); _h = io2.out.file.handle; @@ -541,7 +541,7 @@ static bool test_durable_open_reopen2(struct torture_context *tctx, io.in.durable_open = true; status = smb2_create(tree, mem_ctx, &io); - CHECK_STATUS(status, NT_STATUS_OK); + CHECK_STATUS_OR_GOTO_DONE(status, NT_STATUS_OK); _h = io.out.file.handle; h = &_h; CHECK_CREATED(&io, CREATED, FILE_ATTRIBUTE_ARCHIVE); @@ -564,7 +564,7 @@ static bool test_durable_open_reopen2(struct torture_context *tctx, h = NULL; status = smb2_create(tree, mem_ctx, &io); - CHECK_STATUS(status, NT_STATUS_OK); + CHECK_STATUS_OR_GOTO_DONE(status, NT_STATUS_OK); CHECK_CREATED(&io, EXISTED, FILE_ATTRIBUTE_ARCHIVE); CHECK_VAL(io.out.oplock_level, smb2_util_oplock_level("b")); _h = io.out.file.handle; @@ -601,7 +601,7 @@ static bool test_durable_open_reopen2(struct torture_context *tctx, h = NULL; status = smb2_create(tree, mem_ctx, &io); - CHECK_STATUS(status, NT_STATUS_OK); + CHECK_STATUS_OR_GOTO_DONE(status, NT_STATUS_OK); CHECK_CREATED(&io, EXISTED, FILE_ATTRIBUTE_ARCHIVE); CHECK_VAL(io.out.oplock_level, smb2_util_oplock_level("b")); _h = io.out.file.handle; @@ -630,7 +630,7 @@ static bool test_durable_open_reopen2(struct torture_context *tctx, h = NULL; status = smb2_create(tree, mem_ctx, &io); - CHECK_STATUS(status, NT_STATUS_OK); + CHECK_STATUS_OR_GOTO_DONE(status, NT_STATUS_OK); CHECK_CREATED(&io, EXISTED, FILE_ATTRIBUTE_ARCHIVE); CHECK_VAL(io.out.oplock_level, smb2_util_oplock_level("b")); _h = io.out.file.handle; @@ -691,7 +691,7 @@ static bool test_durable_open_reopen2_lease(struct torture_context *tctx, io.in.durable_open = true; status = smb2_create(tree, mem_ctx, &io); - CHECK_STATUS(status, NT_STATUS_OK); + CHECK_STATUS_OR_GOTO_DONE(status, NT_STATUS_OK); _h = io.out.file.handle; h = &_h; CHECK_CREATED(&io, CREATED, FILE_ATTRIBUTE_ARCHIVE); @@ -727,19 +727,19 @@ static bool test_durable_open_reopen2_lease(struct torture_context *tctx, io.in.fname = ""; io.in.durable_handle = h; status = smb2_create(tree, mem_ctx, &io); - CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_NOT_FOUND); + CHECK_STATUS_OR_GOTO_DONE(status, NT_STATUS_OBJECT_NAME_NOT_FOUND); ZERO_STRUCT(io); io.in.fname = "__non_existing_fname__"; io.in.durable_handle = h; status = smb2_create(tree, mem_ctx, &io); - CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_NOT_FOUND); + CHECK_STATUS_OR_GOTO_DONE(status, NT_STATUS_OBJECT_NAME_NOT_FOUND); ZERO_STRUCT(io); io.in.fname = fname; io.in.durable_handle = h; status = smb2_create(tree, mem_ctx, &io); - CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_NOT_FOUND); + CHECK_STATUS_OR_GOTO_DONE(status, NT_STATUS_OBJECT_NAME_NOT_FOUND); /* * attempt with lease provided, but @@ -755,7 +755,7 @@ static bool test_durable_open_reopen2_lease(struct torture_context *tctx, ls.lease_key.data[0]++; status = smb2_create(tree, mem_ctx, &io); - CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_NOT_FOUND); + CHECK_STATUS_OR_GOTO_DONE(status, NT_STATUS_OBJECT_NAME_NOT_FOUND); /* restore the correct lease key */ ls.lease_key.data[0]--; @@ -774,7 +774,7 @@ static bool test_durable_open_reopen2_lease(struct torture_context *tctx, io.in.oplock_level = SMB2_OPLOCK_LEVEL_LEASE; status = smb2_create(tree, mem_ctx, &io); - CHECK_STATUS(status, NT_STATUS_INVALID_PARAMETER); + CHECK_STATUS_OR_GOTO_DONE(status, NT_STATUS_INVALID_PARAMETER); /* * Now for a succeeding reconnect: @@ -793,7 +793,7 @@ static bool test_durable_open_reopen2_lease(struct torture_context *tctx, h = NULL; status = smb2_create(tree, mem_ctx, &io); - CHECK_STATUS(status, NT_STATUS_OK); + CHECK_STATUS_OR_GOTO_DONE(status, NT_STATUS_OK); CHECK_CREATED(&io, EXISTED, FILE_ATTRIBUTE_ARCHIVE); CHECK_VAL(io.out.durable_open, false); @@ -856,7 +856,7 @@ static bool test_durable_open_reopen2_lease(struct torture_context *tctx, h = NULL; status = smb2_create(tree, mem_ctx, &io); - CHECK_STATUS(status, NT_STATUS_OK); + CHECK_STATUS_OR_GOTO_DONE(status, NT_STATUS_OK); CHECK_CREATED(&io, EXISTED, FILE_ATTRIBUTE_ARCHIVE); CHECK_VAL(io.out.durable_open, false); @@ -929,7 +929,7 @@ static bool test_durable_open_reopen2_lease_v2(struct torture_context *tctx, io.in.durable_open = true; status = smb2_create(tree, mem_ctx, &io); - CHECK_STATUS(status, NT_STATUS_OK); + CHECK_STATUS_OR_GOTO_DONE(status, NT_STATUS_OK); _h = io.out.file.handle; h = &_h; CHECK_CREATED(&io, CREATED, FILE_ATTRIBUTE_ARCHIVE); @@ -964,19 +964,19 @@ static bool test_durable_open_reopen2_lease_v2(struct torture_context *tctx, io.in.fname = ""; io.in.durable_handle = h; status = smb2_create(tree, mem_ctx, &io); - CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_NOT_FOUND); + CHECK_STATUS_OR_GOTO_DONE(status, NT_STATUS_OBJECT_NAME_NOT_FOUND); ZERO_STRUCT(io); io.in.fname = "__non_existing_fname__"; io.in.durable_handle = h; status = smb2_create(tree, mem_ctx, &io); - CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_NOT_FOUND); + CHECK_STATUS_OR_GOTO_DONE(status, NT_STATUS_OBJECT_NAME_NOT_FOUND); ZERO_STRUCT(io); io.in.fname = fname; io.in.durable_handle = h; status = smb2_create(tree, mem_ctx, &io); - CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_NOT_FOUND); + CHECK_STATUS_OR_GOTO_DONE(status, NT_STATUS_OBJECT_NAME_NOT_FOUND); /* * attempt with lease provided, but @@ -992,7 +992,7 @@ static bool test_durable_open_reopen2_lease_v2(struct torture_context *tctx, ls.lease_key.data[0]++; status = smb2_create(tree, mem_ctx, &io); - CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_NOT_FOUND); + CHECK_STATUS_OR_GOTO_DONE(status, NT_STATUS_OBJECT_NAME_NOT_FOUND); /* restore the correct lease key */ ls.lease_key.data[0]--; @@ -1011,7 +1011,7 @@ static bool test_durable_open_reopen2_lease_v2(struct torture_context *tctx, io.in.oplock_level = SMB2_OPLOCK_LEVEL_LEASE; status = smb2_create(tree, mem_ctx, &io); - CHECK_STATUS(status, NT_STATUS_INVALID_PARAMETER); + CHECK_STATUS_OR_GOTO_DONE(status, NT_STATUS_INVALID_PARAMETER); /* * Now for a succeeding reconnect: @@ -1030,7 +1030,7 @@ static bool test_durable_open_reopen2_lease_v2(struct torture_context *tctx, h = NULL; status = smb2_create(tree, mem_ctx, &io); - CHECK_STATUS(status, NT_STATUS_OK); + CHECK_STATUS_OR_GOTO_DONE(status, NT_STATUS_OK); CHECK_CREATED(&io, EXISTED, FILE_ATTRIBUTE_ARCHIVE); CHECK_VAL(io.out.durable_open, false); @@ -1093,7 +1093,7 @@ static bool test_durable_open_reopen2_lease_v2(struct torture_context *tctx, h = NULL; status = smb2_create(tree, mem_ctx, &io); - CHECK_STATUS(status, NT_STATUS_OK); + CHECK_STATUS_OR_GOTO_DONE(status, NT_STATUS_OK); CHECK_CREATED(&io, EXISTED, FILE_ATTRIBUTE_ARCHIVE); CHECK_VAL(io.out.durable_open, false); @@ -1158,7 +1158,7 @@ static bool test_durable_open_reopen2a(struct torture_context *tctx, io1.in.durable_open = true; status = smb2_create(tree, mem_ctx, &io1); - CHECK_STATUS(status, NT_STATUS_OK); + CHECK_STATUS_OR_GOTO_DONE(status, NT_STATUS_OK); _h = io1.out.file.handle; h = &_h; CHECK_CREATED(&io1, CREATED, FILE_ATTRIBUTE_ARCHIVE); @@ -1184,7 +1184,7 @@ static bool test_durable_open_reopen2a(struct torture_context *tctx, h = NULL; status = smb2_create(tree, mem_ctx, &io2); - CHECK_STATUS(status, NT_STATUS_OK); + CHECK_STATUS_OR_GOTO_DONE(status, NT_STATUS_OK); CHECK_CREATED(&io2, EXISTED, FILE_ATTRIBUTE_ARCHIVE); CHECK_VAL(io2.out.oplock_level, smb2_util_oplock_level("b")); _h = io2.out.file.handle; @@ -1235,7 +1235,7 @@ static bool test_durable_open_reopen3(struct torture_context *tctx, io1.in.durable_open = true; status = smb2_create(tree, mem_ctx, &io1); - CHECK_STATUS(status, NT_STATUS_OK); + CHECK_STATUS_OR_GOTO_DONE(status, NT_STATUS_OK); _h = io1.out.file.handle; h = &_h; CHECK_CREATED(&io1, CREATED, FILE_ATTRIBUTE_ARCHIVE); @@ -1244,7 +1244,7 @@ static bool test_durable_open_reopen3(struct torture_context *tctx, /* disconnect, reconnect and then do durable reopen */ status = smb2_tdis(tree); - CHECK_STATUS(status, NT_STATUS_OK); + CHECK_STATUS_OR_GOTO_DONE(status, NT_STATUS_OK); if (!torture_smb2_tree_connect(tctx, tree->session, mem_ctx, &tree2)) { torture_warning(tctx, "couldn't reconnect to share, bailing\n"); @@ -1258,7 +1258,7 @@ static bool test_durable_open_reopen3(struct torture_context *tctx, io2.in.durable_handle = h; status = smb2_create(tree2, mem_ctx, &io2); - CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_NOT_FOUND); + CHECK_STATUS_OR_GOTO_DONE(status, NT_STATUS_OBJECT_NAME_NOT_FOUND); done: if (tree != NULL) { @@ -1306,7 +1306,7 @@ static bool test_durable_open_reopen4(struct torture_context *tctx, io1.in.durable_open = true; status = smb2_create(tree, mem_ctx, &io1); - CHECK_STATUS(status, NT_STATUS_OK); + CHECK_STATUS_OR_GOTO_DONE(status, NT_STATUS_OK); _h = io1.out.file.handle; h = &_h; CHECK_CREATED(&io1, CREATED, FILE_ATTRIBUTE_ARCHIVE); @@ -1319,7 +1319,7 @@ static bool test_durable_open_reopen4(struct torture_context *tctx, */ transport = tree->session->transport; status = smb2_logoff(tree->session); - CHECK_STATUS(status, NT_STATUS_OK); + CHECK_STATUS_OR_GOTO_DONE(status, NT_STATUS_OK); if (!torture_smb2_session_setup(tctx, transport, 0, /* previous_session_id */ @@ -1348,7 +1348,7 @@ static bool test_durable_open_reopen4(struct torture_context *tctx, h = NULL; status = smb2_create(tree2, mem_ctx, &io2); - CHECK_STATUS(status, NT_STATUS_OK); + CHECK_STATUS_OR_GOTO_DONE(status, NT_STATUS_OK); _h = io2.out.file.handle; h = &_h; @@ -1396,7 +1396,7 @@ static bool test_durable_open_delete_on_close1(struct torture_context *tctx, io1.in.create_options |= NTCREATEX_OPTIONS_DELETE_ON_CLOSE; status = smb2_create(tree, mem_ctx, &io1); - CHECK_STATUS(status, NT_STATUS_OK); + CHECK_STATUS_OR_GOTO_DONE(status, NT_STATUS_OK); _h = io1.out.file.handle; h = &_h; CHECK_CREATED(&io1, CREATED, FILE_ATTRIBUTE_ARCHIVE); @@ -1404,7 +1404,7 @@ static bool test_durable_open_delete_on_close1(struct torture_context *tctx, CHECK_VAL(io1.out.oplock_level, smb2_util_oplock_level("b")); status = smb2_util_write(tree, *h, &b, 0, 1); - CHECK_STATUS(status, NT_STATUS_OK); + CHECK_STATUS_OR_GOTO_DONE(status, NT_STATUS_OK); /* disconnect, leaving the durable handle in place */ TALLOC_FREE(tree); @@ -1428,7 +1428,7 @@ static bool test_durable_open_delete_on_close1(struct torture_context *tctx, io2.in.create_options |= NTCREATEX_OPTIONS_DELETE_ON_CLOSE; status = smb2_create(tree, mem_ctx, &io2); - CHECK_STATUS(status, NT_STATUS_OK); + CHECK_STATUS_OR_GOTO_DONE(status, NT_STATUS_OK); _h = io2.out.file.handle; h = &_h; CHECK_CREATED_SIZE(&io2, CREATED, FILE_ATTRIBUTE_ARCHIVE, 0, 0); @@ -1482,7 +1482,7 @@ static bool test_durable_open_delete_on_close2(struct torture_context *tctx, io.in.create_options |= NTCREATEX_OPTIONS_DELETE_ON_CLOSE; status = smb2_create(tree, mem_ctx, &io); - CHECK_STATUS(status, NT_STATUS_OK); + CHECK_STATUS_OR_GOTO_DONE(status, NT_STATUS_OK); _h = io.out.file.handle; h = &_h; CHECK_CREATED(&io, CREATED, FILE_ATTRIBUTE_ARCHIVE); @@ -1490,7 +1490,7 @@ static bool test_durable_open_delete_on_close2(struct torture_context *tctx, CHECK_VAL(io.out.oplock_level, smb2_util_oplock_level("b")); status = smb2_util_write(tree, *h, &b, 0, 1); - CHECK_STATUS(status, NT_STATUS_OK); + CHECK_STATUS_OR_GOTO_DONE(status, NT_STATUS_OK); previous_session_id = smb2cli_session_current_id(tree->session->smbXcli); @@ -1510,7 +1510,7 @@ static bool test_durable_open_delete_on_close2(struct torture_context *tctx, io.in.durable_handle = h; status = smb2_create(tree, mem_ctx, &io); - CHECK_STATUS(status, NT_STATUS_OK); + CHECK_STATUS_OR_GOTO_DONE(status, NT_STATUS_OK); _h = io.out.file.handle; h = &_h; alloc_size_step = io.out.alloc_size; @@ -1543,7 +1543,7 @@ static bool test_durable_open_delete_on_close2(struct torture_context *tctx, io.in.create_options |= NTCREATEX_OPTIONS_DELETE_ON_CLOSE; status = smb2_create(tree, mem_ctx, &io); - CHECK_STATUS(status, NT_STATUS_OK); + CHECK_STATUS_OR_GOTO_DONE(status, NT_STATUS_OK); _h = io.out.file.handle; h = &_h; CHECK_CREATED_SIZE(&io, CREATED, FILE_ATTRIBUTE_ARCHIVE, 0, 0); @@ -1593,7 +1593,7 @@ static bool test_durable_open_file_position(struct torture_context *tctx, io.in.durable_open = true; status = smb2_create(tree, mem_ctx, &io); - CHECK_STATUS(status, NT_STATUS_OK); + CHECK_STATUS_OR_GOTO_DONE(status, NT_STATUS_OK); h = io.out.file.handle; CHECK_CREATED(&io, CREATED, FILE_ATTRIBUTE_ARCHIVE); CHECK_VAL(io.out.durable_open, true); @@ -1605,7 +1605,7 @@ static bool test_durable_open_file_position(struct torture_context *tctx, qfinfo.generic.level = RAW_FILEINFO_POSITION_INFORMATION; qfinfo.generic.in.file.handle = h; status = smb2_getinfo_file(tree, mem_ctx, &qfinfo); - CHECK_STATUS(status, NT_STATUS_OK); + CHECK_STATUS_OR_GOTO_DONE(status, NT_STATUS_OK); CHECK_VAL(qfinfo.position_information.out.position, 0); pos = qfinfo.position_information.out.position; torture_comment(tctx, "position: %llu\n", @@ -1616,13 +1616,13 @@ static bool test_durable_open_file_position(struct torture_context *tctx, sfinfo.generic.in.file.handle = h; sfinfo.position_information.in.position = 0x1000; status = smb2_setinfo_file(tree, &sfinfo); - CHECK_STATUS(status, NT_STATUS_OK); + CHECK_STATUS_OR_GOTO_DONE(status, NT_STATUS_OK); ZERO_STRUCT(qfinfo); qfinfo.generic.level = RAW_FILEINFO_POSITION_INFORMATION; qfinfo.generic.in.file.handle = h; status = smb2_getinfo_file(tree, mem_ctx, &qfinfo); - CHECK_STATUS(status, NT_STATUS_OK); + CHECK_STATUS_OR_GOTO_DONE(status, NT_STATUS_OK); CHECK_VAL(qfinfo.position_information.out.position, 0x1000); pos = qfinfo.position_information.out.position; torture_comment(tctx, "position: %llu\n", @@ -1647,14 +1647,14 @@ static bool test_durable_open_file_position(struct torture_context *tctx, qfinfo.generic.level = RAW_FILEINFO_POSITION_INFORMATION; qfinfo.generic.in.file.handle = h; status = smb2_getinfo_file(tree, mem_ctx, &qfinfo); - CHECK_STATUS(status, NT_STATUS_FILE_CLOSED); + CHECK_STATUS_OR_GOTO_DONE(status, NT_STATUS_FILE_CLOSED); ZERO_STRUCT(io); io.in.fname = fname; io.in.durable_handle = &h; status = smb2_create(tree, mem_ctx, &io); - CHECK_STATUS(status, NT_STATUS_OK); + CHECK_STATUS_OR_GOTO_DONE(status, NT_STATUS_OK); CHECK_VAL(io.out.oplock_level, SMB2_OPLOCK_LEVEL_BATCH); CHECK_VAL(io.out.reserved, 0x00); CHECK_VAL(io.out.create_action, NTCREATEX_ACTION_EXISTED); @@ -1669,7 +1669,7 @@ static bool test_durable_open_file_position(struct torture_context *tctx, qfinfo.generic.level = RAW_FILEINFO_POSITION_INFORMATION; qfinfo.generic.in.file.handle = h; status = smb2_getinfo_file(tree, mem_ctx, &qfinfo); - CHECK_STATUS(status, NT_STATUS_OK); + CHECK_STATUS_OR_GOTO_DONE(status, NT_STATUS_OK); CHECK_VAL(qfinfo.position_information.out.position, 0x1000); pos = qfinfo.position_information.out.position; torture_comment(tctx, "position: %llu\n", @@ -1715,7 +1715,7 @@ static bool test_durable_open_oplock(struct torture_context *tctx, io2.in.create_disposition = NTCREATEX_DISP_OPEN; status = smb2_create(tree1, mem_ctx, &io1); - CHECK_STATUS(status, NT_STATUS_OK); + CHECK_STATUS_OR_GOTO_DONE(status, NT_STATUS_OK); h1 = io1.out.file.handle; CHECK_CREATED(&io1, CREATED, FILE_ATTRIBUTE_ARCHIVE); CHECK_VAL(io1.out.durable_open, true); @@ -1731,7 +1731,7 @@ static bool test_durable_open_oplock(struct torture_context *tctx, * some time for the client to reconnect!) */ status = smb2_create(tree2, mem_ctx, &io2); - CHECK_STATUS(status, NT_STATUS_OK); + CHECK_STATUS_OR_GOTO_DONE(status, NT_STATUS_OK); h2 = io2.out.file.handle; CHECK_CREATED(&io2, EXISTED, FILE_ATTRIBUTE_ARCHIVE); CHECK_VAL(io2.out.durable_open, true); @@ -1749,7 +1749,7 @@ static bool test_durable_open_oplock(struct torture_context *tctx, io1.in.durable_handle = &h1; status = smb2_create(tree1, mem_ctx, &io1); - CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_NOT_FOUND); + CHECK_STATUS_OR_GOTO_DONE(status, NT_STATUS_OBJECT_NAME_NOT_FOUND); done: smb2_util_close(tree2, h2); @@ -1805,7 +1805,7 @@ static bool test_durable_open_lease(struct torture_context *tctx, io2.in.create_disposition = NTCREATEX_DISP_OPEN; status = smb2_create(tree1, mem_ctx, &io1); - CHECK_STATUS(status, NT_STATUS_OK); + CHECK_STATUS_OR_GOTO_DONE(status, NT_STATUS_OK); h1 = io1.out.file.handle; CHECK_VAL(io1.out.durable_open, true); CHECK_CREATED(&io1, CREATED, FILE_ATTRIBUTE_ARCHIVE); @@ -1824,12 +1824,12 @@ static bool test_durable_open_lease(struct torture_context *tctx, * Windows7 (build 7000) will grant an RH lease immediate (not an RHW?) * even if the original client is gone. (ZML: This seems like a bug. It * should give some time for the client to reconnect! And why RH?) - * + * * obnox: Current windows 7 and w2k8r2 grant RHW instead of RH. * Test is adapted accordingly. */ status = smb2_create(tree2, mem_ctx, &io2); - CHECK_STATUS(status, NT_STATUS_OK); + CHECK_STATUS_OR_GOTO_DONE(status, NT_STATUS_OK); h2 = io2.out.file.handle; CHECK_VAL(io2.out.durable_open, true); CHECK_CREATED(&io2, EXISTED, FILE_ATTRIBUTE_ARCHIVE); @@ -1853,7 +1853,7 @@ static bool test_durable_open_lease(struct torture_context *tctx, io1.in.lease_request = &ls1; status = smb2_create(tree1, mem_ctx, &io1); - CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_NOT_FOUND); + CHECK_STATUS_OR_GOTO_DONE(status, NT_STATUS_OBJECT_NAME_NOT_FOUND); done: smb2_util_close(tree2, h2); @@ -1892,7 +1892,7 @@ static bool test_durable_open_lock_oplock(struct torture_context *tctx, io.in.durable_open = true; status = smb2_create(tree, mem_ctx, &io); - CHECK_STATUS(status, NT_STATUS_OK); + CHECK_STATUS_OR_GOTO_DONE(status, NT_STATUS_OK); h = io.out.file.handle; CHECK_CREATED(&io, CREATED, FILE_ATTRIBUTE_ARCHIVE); @@ -1910,7 +1910,7 @@ static bool test_durable_open_lock_oplock(struct torture_context *tctx, el[0].reserved = 0x00000000; el[0].flags = SMB2_LOCK_FLAG_EXCLUSIVE; status = smb2_lock(tree, &lck); - CHECK_STATUS(status, NT_STATUS_OK); + CHECK_STATUS_OR_GOTO_DONE(status, NT_STATUS_OK); /* Disconnect/Reconnect. */ talloc_free(tree); @@ -1927,13 +1927,13 @@ static bool test_durable_open_lock_oplock(struct torture_context *tctx, io.in.durable_handle = &h; status = smb2_create(tree, mem_ctx, &io); - CHECK_STATUS(status, NT_STATUS_OK); + CHECK_STATUS_OR_GOTO_DONE(status, NT_STATUS_OK); h = io.out.file.handle; lck.in.file.handle = h; el[0].flags = SMB2_LOCK_FLAG_UNLOCK; status = smb2_lock(tree, &lck); - CHECK_STATUS(status, NT_STATUS_OK); + CHECK_STATUS_OR_GOTO_DONE(status, NT_STATUS_OK); done: smb2_util_close(tree, h); @@ -1986,7 +1986,7 @@ static bool test_durable_open_lock_lease(struct torture_context *tctx, io.in.durable_open = true; status = smb2_create(tree, mem_ctx, &io); - CHECK_STATUS(status, NT_STATUS_OK); + CHECK_STATUS_OR_GOTO_DONE(status, NT_STATUS_OK); h = io.out.file.handle; CHECK_CREATED(&io, CREATED, FILE_ATTRIBUTE_ARCHIVE); @@ -2008,7 +2008,7 @@ static bool test_durable_open_lock_lease(struct torture_context *tctx, el[0].reserved = 0x00000000; el[0].flags = SMB2_LOCK_FLAG_EXCLUSIVE; status = smb2_lock(tree, &lck); - CHECK_STATUS(status, NT_STATUS_OK); + CHECK_STATUS_OR_GOTO_DONE(status, NT_STATUS_OK); /* Disconnect/Reconnect. */ talloc_free(tree); @@ -2026,13 +2026,13 @@ static bool test_durable_open_lock_lease(struct torture_context *tctx, io.in.lease_request = &ls; status = smb2_create(tree, mem_ctx, &io); - CHECK_STATUS(status, NT_STATUS_OK); + CHECK_STATUS_OR_GOTO_DONE(status, NT_STATUS_OK); h = io.out.file.handle; lck.in.file.handle = h; el[0].flags = SMB2_LOCK_FLAG_UNLOCK; status = smb2_lock(tree, &lck); - CHECK_STATUS(status, NT_STATUS_OK); + CHECK_STATUS_OR_GOTO_DONE(status, NT_STATUS_OK); done: smb2_util_close(tree, h); @@ -2091,7 +2091,7 @@ static bool test_durable_open_open2_lease(struct torture_context *tctx, io1.in.durable_open = true; status = smb2_create(tree1, mem_ctx, &io1); - CHECK_STATUS(status, NT_STATUS_OK); + CHECK_STATUS_OR_GOTO_DONE(status, NT_STATUS_OK); h1 = io1.out.file.handle; CHECK_VAL(io1.out.durable_open, true); CHECK_CREATED(&io1, CREATED, FILE_ATTRIBUTE_ARCHIVE); @@ -2110,7 +2110,7 @@ static bool test_durable_open_open2_lease(struct torture_context *tctx, smb2_oplock_create(&io2, fname, SMB2_OPLOCK_LEVEL_NONE); status = smb2_create(tree2, mem_ctx, &io2); - CHECK_STATUS(status, NT_STATUS_OK); + CHECK_STATUS_OR_GOTO_DONE(status, NT_STATUS_OK); h2 = io2.out.file.handle; CHECK_CREATED(&io1, CREATED, FILE_ATTRIBUTE_ARCHIVE); @@ -2132,7 +2132,7 @@ static bool test_durable_open_open2_lease(struct torture_context *tctx, * some time for the client to reconnect!) */ status = smb2_create(tree1, mem_ctx, &io1); - CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_NOT_FOUND); + CHECK_STATUS_OR_GOTO_DONE(status, NT_STATUS_OBJECT_NAME_NOT_FOUND); h1 = io1.out.file.handle; done: @@ -2183,7 +2183,7 @@ static bool test_durable_open_open2_oplock(struct torture_context *tctx, io1.in.durable_open = true; status = smb2_create(tree1, mem_ctx, &io1); - CHECK_STATUS(status, NT_STATUS_OK); + CHECK_STATUS_OR_GOTO_DONE(status, NT_STATUS_OK); h1 = io1.out.file.handle; CHECK_CREATED(&io1, CREATED, FILE_ATTRIBUTE_ARCHIVE); CHECK_VAL(io1.out.durable_open, true); @@ -2197,7 +2197,7 @@ static bool test_durable_open_open2_oplock(struct torture_context *tctx, smb2_oplock_create(&io2, fname, SMB2_OPLOCK_LEVEL_NONE); status = smb2_create(tree2, mem_ctx, &io2); - CHECK_STATUS(status, NT_STATUS_OK); + CHECK_STATUS_OR_GOTO_DONE(status, NT_STATUS_OK); h2 = io2.out.file.handle; CHECK_CREATED(&io1, CREATED, FILE_ATTRIBUTE_ARCHIVE); @@ -2213,7 +2213,7 @@ static bool test_durable_open_open2_oplock(struct torture_context *tctx, io1.in.durable_handle = &h1; status = smb2_create(tree1, mem_ctx, &io1); - CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_NOT_FOUND); + CHECK_STATUS_OR_GOTO_DONE(status, NT_STATUS_OBJECT_NAME_NOT_FOUND); h1 = io1.out.file.handle; done: @@ -2264,7 +2264,7 @@ static bool test_durable_open_alloc_size(struct torture_context *tctx, io.in.alloc_size = initial_alloc_size; status = smb2_create(tree, mem_ctx, &io); - CHECK_STATUS(status, NT_STATUS_OK); + CHECK_STATUS_OR_GOTO_DONE(status, NT_STATUS_OK); _h = io.out.file.handle; h = &_h; CHECK_NOT_VAL(io.out.alloc_size, 0); @@ -2298,7 +2298,7 @@ static bool test_durable_open_alloc_size(struct torture_context *tctx, h = NULL; status = smb2_create(tree, mem_ctx, &io); - CHECK_STATUS(status, NT_STATUS_OK); + CHECK_STATUS_OR_GOTO_DONE(status, NT_STATUS_OK); CHECK_CREATED_SIZE(&io, EXISTED, FILE_ATTRIBUTE_ARCHIVE, alloc_size_step, 0); CHECK_VAL(io.out.oplock_level, smb2_util_oplock_level("b")); @@ -2309,7 +2309,7 @@ static bool test_durable_open_alloc_size(struct torture_context *tctx, /* write one byte */ status = smb2_util_write(tree, *h, b, 0, 1); - CHECK_STATUS(status, NT_STATUS_OK); + CHECK_STATUS_OR_GOTO_DONE(status, NT_STATUS_OK); /* disconnect, reconnect and then do durable reopen */ talloc_free(tree); @@ -2329,7 +2329,7 @@ static bool test_durable_open_alloc_size(struct torture_context *tctx, h = NULL; status = smb2_create(tree, mem_ctx, &io); - CHECK_STATUS(status, NT_STATUS_OK); + CHECK_STATUS_OR_GOTO_DONE(status, NT_STATUS_OK); CHECK_CREATED_SIZE(&io, EXISTED, FILE_ATTRIBUTE_ARCHIVE, alloc_size_step, 1); CHECK_VAL(io.out.oplock_level, smb2_util_oplock_level("b")); @@ -2359,7 +2359,7 @@ static bool test_durable_open_alloc_size(struct torture_context *tctx, h = NULL; status = smb2_create(tree, mem_ctx, &io); - CHECK_STATUS(status, NT_STATUS_OK); + CHECK_STATUS_OR_GOTO_DONE(status, NT_STATUS_OK); CHECK_CREATED_SIZE(&io, EXISTED, FILE_ATTRIBUTE_ARCHIVE, alloc_size_step * 2, alloc_size_step + 1); CHECK_VAL(io.out.oplock_level, smb2_util_oplock_level("b")); @@ -2413,7 +2413,7 @@ static bool test_durable_open_read_only(struct torture_context *tctx, io.in.file_attributes = FILE_ATTRIBUTE_READONLY; status = smb2_create(tree, mem_ctx, &io); - CHECK_STATUS(status, NT_STATUS_OK); + CHECK_STATUS_OR_GOTO_DONE(status, NT_STATUS_OK); _h = io.out.file.handle; h = &_h; CHECK_CREATED(&io, CREATED, FILE_ATTRIBUTE_READONLY|FILE_ATTRIBUTE_ARCHIVE); @@ -2424,7 +2424,7 @@ static bool test_durable_open_read_only(struct torture_context *tctx, /* write one byte */ status = smb2_util_write(tree, *h, &b, 0, 1); - CHECK_STATUS(status, NT_STATUS_OK); + CHECK_STATUS_OR_GOTO_DONE(status, NT_STATUS_OK); /* disconnect, reconnect and then do durable reopen */ talloc_free(tree); @@ -2444,7 +2444,7 @@ static bool test_durable_open_read_only(struct torture_context *tctx, h = NULL; status = smb2_create(tree, mem_ctx, &io); - CHECK_STATUS(status, NT_STATUS_OK); + CHECK_STATUS_OR_GOTO_DONE(status, NT_STATUS_OK); alloc_size = io.out.alloc_size; CHECK_CREATED_SIZE(&io, EXISTED, FILE_ATTRIBUTE_READONLY|FILE_ATTRIBUTE_ARCHIVE, @@ -2455,7 +2455,7 @@ static bool test_durable_open_read_only(struct torture_context *tctx, /* write one byte */ status = smb2_util_write(tree, *h, &b, 1, 1); - CHECK_STATUS(status, NT_STATUS_OK); + CHECK_STATUS_OR_GOTO_DONE(status, NT_STATUS_OK); done: if (h != NULL) { @@ -2502,7 +2502,7 @@ static bool test_durable_open_oplock_disconnect(struct torture_context *tctx, io.in.durable_open = true; status = smb2_create(tree, mem_ctx, &io); - CHECK_STATUS(status, NT_STATUS_OK); + CHECK_STATUS_OR_GOTO_DONE(status, NT_STATUS_OK); _h = io.out.file.handle; h = &_h; -- 1.9.1