Add code to torture the fragmentation code a bit
authorVolker Lendecke <vl@samba.org>
Sun, 18 Jan 2009 11:22:14 +0000 (12:22 +0100)
committerVolker Lendecke <vl@samba.org>
Sun, 18 Jan 2009 14:40:45 +0000 (15:40 +0100)
source3/rpc_client/cli_pipe.c

index 85085ad504591018dbca5251a859efa272d40354..f3affd1cd894f63909176e33bdc833f31c791a45 100644 (file)
@@ -1367,6 +1367,7 @@ static struct async_req *rpc_api_pipe_send(TALLOC_CTX *mem_ctx,
 {
        struct async_req *result, *subreq;
        struct rpc_api_pipe_state *state;
+       uint16_t max_recv_frag;
        NTSTATUS status;
 
        result = async_req_new(mem_ctx);
@@ -1402,9 +1403,14 @@ static struct async_req *rpc_api_pipe_send(TALLOC_CTX *mem_ctx,
 
        DEBUG(5,("rpc_api_pipe: %s\n", rpccli_pipe_txt(debug_ctx(), cli)));
 
-       subreq = cli_api_pipe_send(state, ev, cli,
-                                  (uint8_t *)prs_data_p(data),
-                                  prs_offset(data), cli->max_recv_frag);
+       max_recv_frag = cli->max_recv_frag;
+
+#ifdef DEVELOPER
+       max_recv_frag = RPC_HEADER_LEN + 10 + (sys_random() % 32);
+#endif
+
+       subreq = cli_api_pipe_send(state, ev, cli, (uint8_t *)prs_data_p(data),
+                                  prs_offset(data), max_recv_frag);
        if (subreq == NULL) {
                status = NT_STATUS_NO_MEMORY;
                goto post_status;
@@ -2085,6 +2091,12 @@ static uint32 calculate_data_len_tosend(struct rpc_pipe_client *cli,
 {
        uint32 data_space, data_len;
 
+#ifdef DEVELOPER
+       if ((data_left > 0) && (sys_random() % 2)) {
+               data_left = MAX(data_left/2, 1);
+       }
+#endif
+
        switch (cli->auth->auth_level) {
                case PIPE_AUTH_LEVEL_NONE:
                case PIPE_AUTH_LEVEL_CONNECT: