s4:torture: make rpc.handles.random-assoc test more robust
authorStefan Metzmacher <metze@samba.org>
Fri, 16 Aug 2019 10:50:21 +0000 (12:50 +0200)
committerStefan Metzmacher <metze@samba.org>
Mon, 9 Sep 2019 14:23:39 +0000 (14:23 +0000)
We've seen failures like this:

  RPC-HANDLE-RANDOM-ASSOC
  connect samr pipe1
  pipe1 uses assoc_group_id[0x00000001]
  connect samr pipe2 with assoc_group_id[0xFFFFFFFF]- should fail
  Failed to bind to uuid 12345778-1234-abcd-ef00-0123456789ac for
    ncacn_np:localdc[\pipe\samr,bigendian,assoc_group_id=0xffffffff,
    abstract_syntax=12345778-1234-abcd-ef00-0123456789ac/0x00000001] NT_STATUS_UNSUCCESSFUL
  connect samr pipe3 with assoc_group_id[0x00000000]- should fail
  UNEXPECTED(failure): samba4.rpc.handles on ncacn_np with bigendian.random-assoc(ad_dc_default)
  REASON: Exception: Exception: ../../source4/torture/rpc/handles.c:546:
    status was NT_STATUS_OK, expected NT_STATUS_UNSUCCESSFUL: opening samr pipe3

Prevent that it wraps to 0x00000000

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
source4/torture/rpc/handles.c

index fcbe7c4ee333cd1ea16116a6ee63c8a89945d9a6..ae6a55eb965ba7af18ba81a259a9632b8692203e 100644 (file)
@@ -525,9 +525,11 @@ static bool test_handles_random_assoc(struct torture_context *torture)
        /*
         * We use ~p1->assoc_group_id instead of p1->assoc_group_id, because
         * this way we are less likely to use an id which is already in use.
+        *
+        * And make sure it doesn't wrap.
         */
        assoc_group_id = dcerpc_binding_get_assoc_group_id(p1->binding);
-       assoc_group_id = ~assoc_group_id;
+       assoc_group_id = MIN(~assoc_group_id, UINT32_MAX - 3);
 
        torture_comment(torture, "connect samr pipe2 with assoc_group_id[0x%08X]- should fail\n", ++assoc_group_id);
        status = torture_rpc_connection_transport(torture, &p2, &ndr_table_samr,