[SCM] Samba Shared Repository - branch master updated

Jeremy Allison jra at samba.org
Tue Sep 10 18:57:02 UTC 2019


The branch, master has been updated
       via  849e3842cd9 s4:torture/smb2: try to fix a RESOURCE_LEAK in smb2.samba3misc.localposixlock1
       via  8270b8c0b21 lib/torture: protect torture_assert[_goto]() with a do { } while(0) block
       via  c6b48490ac6 s4:torture: always add ';' after torture_assert()
      from  f5a51061470 Create SECURITY.md

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 849e3842cd9a0000fb4393b6e770945b8d4d1dc2
Author: Stefan Metzmacher <metze at samba.org>
Date:   Tue Sep 10 12:37:52 2019 +0200

    s4:torture/smb2: try to fix a RESOURCE_LEAK in smb2.samba3misc.localposixlock1
    
    CID 1453656:    (RESOURCE_LEAK)
    Handle variable "fd" going out of scope leaks the handle.
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    
    Autobuild-User(master): Jeremy Allison <jra at samba.org>
    Autobuild-Date(master): Tue Sep 10 18:56:45 UTC 2019 on sn-devel-184

commit 8270b8c0b2141e3db1cba16b72d152686efe824f
Author: Stefan Metzmacher <metze at samba.org>
Date:   Tue Sep 10 10:55:15 2019 +0200

    lib/torture: protect torture_assert[_goto]() with a do { } while(0) block
    
    This hopefully fixes a lot of coverity defects like:
    
    Control flow issues  (DEADCODE)
    Execution cannot reach this statement: ";".
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit c6b48490ac68f23c9f172bdfa91954a960928795
Author: Stefan Metzmacher <metze at samba.org>
Date:   Tue Sep 10 12:33:34 2019 +0200

    s4:torture: always add ';' after torture_assert()
    
    The next commit will require this.
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

-----------------------------------------------------------------------

Summary of changes:
 lib/torture/torture.h                | 10 ++++++----
 source4/torture/drs/rpc/msds_intid.c |  4 ++--
 source4/torture/rpc/samba3rpc.c      |  2 +-
 source4/torture/smb2/multichannel.c  |  2 +-
 source4/torture/smb2/samba3misc.c    |  7 ++++---
 5 files changed, 14 insertions(+), 11 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/torture/torture.h b/lib/torture/torture.h
index 3507740967c..dbc711e25a1 100644
--- a/lib/torture/torture.h
+++ b/lib/torture/torture.h
@@ -249,18 +249,20 @@ void torture_warning(struct torture_context *test, const char *comment, ...) PRI
 void torture_result(struct torture_context *test,
 			enum torture_result, const char *reason, ...) PRINTF_ATTRIBUTE(3,4);
 
-#define torture_assert(torture_ctx,expr,cmt) \
+#define torture_assert(torture_ctx,expr,cmt) do { \
 	if (!(expr)) { \
 		torture_result(torture_ctx, TORTURE_FAIL, __location__": Expression `%s' failed: %s", __STRING(expr), cmt); \
 		return false; \
-	}
+	} \
+} while(0)
 
-#define torture_assert_goto(torture_ctx,expr,ret,label,cmt) \
+#define torture_assert_goto(torture_ctx,expr,ret,label,cmt) do { \
 	if (!(expr)) { \
 		torture_result(torture_ctx, TORTURE_FAIL, __location__": Expression `%s' failed: %s", __STRING(expr), cmt); \
 		ret = false; \
 		goto label; \
-	}
+	} \
+} while(0)
 
 #define torture_assert_werr_equal(torture_ctx, got, expected, cmt) \
 	do { WERROR __got = got, __expected = expected; \
diff --git a/source4/torture/drs/rpc/msds_intid.c b/source4/torture/drs/rpc/msds_intid.c
index 1fb5c782bdf..4e840aa332f 100644
--- a/source4/torture/drs/rpc/msds_intid.c
+++ b/source4/torture/drs/rpc/msds_intid.c
@@ -600,13 +600,13 @@ static bool test_dsintid_schema(struct torture_context *tctx, struct DsIntIdTest
 			       la->attid == dsdb_attr->attributeID_id,
 			       _make_error_message(ctx, la->attid,
 						   dsdb_attr,
-						   la->identifier))
+						   la->identifier));
 		if (dsdb_attr->msDS_IntId) {
 			torture_assert(tctx,
 				       la->attid != dsdb_attr->msDS_IntId,
 				       _make_error_message(ctx, la->attid,
 							   dsdb_attr,
-							   la->identifier))
+							   la->identifier));
 		}
 	}
 
diff --git a/source4/torture/rpc/samba3rpc.c b/source4/torture/rpc/samba3rpc.c
index d55d6c47b57..83b2107e9fc 100644
--- a/source4/torture/rpc/samba3rpc.c
+++ b/source4/torture/rpc/samba3rpc.c
@@ -2517,7 +2517,7 @@ static bool torture_samba3_rpc_sharesec(struct torture_context *torture)
 			torture, torture, sd, cli->session,
 			torture_setting_string(torture, "share", NULL),
 			user_sid, SEC_FILE_ALL, NT_STATUS_OK, NT_STATUS_OK),
-			"failed to test tcon with SEC_FILE_ALL access_mask")
+			"failed to test tcon with SEC_FILE_ALL access_mask");
 
 	return true;
 }
diff --git a/source4/torture/smb2/multichannel.c b/source4/torture/smb2/multichannel.c
index 6fc94dd2b8c..4e532d23468 100644
--- a/source4/torture/smb2/multichannel.c
+++ b/source4/torture/smb2/multichannel.c
@@ -722,7 +722,7 @@ static bool test_multichannel_oplock_break_test2(struct torture_context *tctx,
 						  credentials,
 						  &transport2_options,
 						  &tree2A, &tree2B, &tree2C);
-	torture_assert(tctx, ret, "Could not create channels.\n")
+	torture_assert(tctx, ret, "Could not create channels.\n");
 
 	torture_comment(tctx, "client2 opens fname1 via session 2A\n");
 	io1.in.oplock_level = smb2_util_oplock_level("b");
diff --git a/source4/torture/smb2/samba3misc.c b/source4/torture/smb2/samba3misc.c
index a5fe6c1bbea..cf4d9bbe18f 100644
--- a/source4/torture/smb2/samba3misc.c
+++ b/source4/torture/smb2/samba3misc.c
@@ -127,7 +127,8 @@ static bool torture_samba3_localposixlock1(struct torture_context *tctx,
 	rc = fcntl(fd, F_SETLK, &posix_lock);
 	if (rc == -1) {
 		torture_warning(tctx, "fcntl failed: %s\n", strerror(errno));
-		torture_assert(tctx, rc != -1, "fcntl lock\n");
+		torture_assert_goto(tctx, rc != -1, ret, done,
+				    "fcntl lock\n");
 	}
 
 	el[0].offset		= 0;
@@ -147,13 +148,13 @@ static bool torture_samba3_localposixlock1(struct torture_context *tctx,
 	torture_comment(tctx, "  remote async blocking lock\n");
 	el[0].flags		= SMB2_LOCK_FLAG_EXCLUSIVE;
 	req = smb2_lock_send(tree, &lck);
-	torture_assert(tctx, req != NULL, "smb2_lock_send()\n");
+	torture_assert_goto(tctx, req != NULL, ret, done, "smb2_lock_send()\n");
 
 	te = tevent_add_timer(tctx->ev,
 			      tctx, timeval_current_ofs(5, 0),
 			      torture_smb2_tree_disconnect_timer,
 			      tree);
-	torture_assert(tctx, te != NULL, "tevent_add_timer\n");
+	torture_assert_goto(tctx, te != NULL, ret, done, "tevent_add_timer\n");
 
 	torture_comment(tctx, "  remote wait for STATUS_PENDING\n");
 	WAIT_FOR_ASYNC_RESPONSE(req);


-- 
Samba Shared Repository



More information about the samba-cvs mailing list