#include "includes.h"
#include "libcli/smb2/smb2.h"
#include "libcli/smb2/smb2_calls.h"
+#include "../libcli/smb/smbXcli_base.h"
#include "torture/torture.h"
#include "torture/smb2/proto.h"
bool ret = true;
NTSTATUS status;
struct smb2_handle h;
- uint8_t buf[64*1024];
+ uint8_t buf[2*1024*1024];
struct smb2_read rd;
TALLOC_CTX *tmp_ctx = talloc_new(tree);
-
+ uint32_t size;
ZERO_STRUCT(buf);
+ smb2cli_conn_set_max_credits(tree->session->transport->conn, 30);
+
+ size = smb2cli_conn_max_write_size(tree->session->transport->conn);
+ size = MIN(ARRAY_SIZE(buf), size);
+
smb2_util_unlink(tree, FNAME);
status = torture_smb2_testfile(tree, FNAME, &h);
status = smb2_read(tree, tree, &rd);
CHECK_STATUS(status, NT_STATUS_END_OF_FILE);
- status = smb2_util_write(tree, h, buf, 0, ARRAY_SIZE(buf));
+ status = smb2_util_write(tree, h, buf, 0, size);
CHECK_STATUS(status, NT_STATUS_OK);
ZERO_STRUCT(rd);
rd.in.min_count = 0;
rd.in.length = 10;
- rd.in.offset = sizeof(buf);
+ rd.in.offset = size;
status = smb2_read(tree, tmp_ctx, &rd);
CHECK_STATUS(status, NT_STATUS_END_OF_FILE);
rd.in.min_count = 0;
rd.in.length = 0;
- rd.in.offset = sizeof(buf);
+ rd.in.offset = size;
status = smb2_read(tree, tmp_ctx, &rd);
CHECK_STATUS(status, NT_STATUS_OK);
CHECK_VALUE(rd.out.data.length, 0);
rd.in.min_count = 1;
rd.in.length = 0;
- rd.in.offset = sizeof(buf);
+ rd.in.offset = size;
status = smb2_read(tree, tmp_ctx, &rd);
CHECK_STATUS(status, NT_STATUS_END_OF_FILE);
rd.in.min_count = 0;
rd.in.length = 2;
- rd.in.offset = sizeof(buf) - 1;
+ rd.in.offset = size - 1;
status = smb2_read(tree, tmp_ctx, &rd);
CHECK_STATUS(status, NT_STATUS_OK);
CHECK_VALUE(rd.out.data.length, 1);
rd.in.min_count = 2;
rd.in.length = 1;
- rd.in.offset = sizeof(buf) - 1;
+ rd.in.offset = size - 1;
status = smb2_read(tree, tmp_ctx, &rd);
CHECK_STATUS(status, NT_STATUS_END_OF_FILE);
status = smb2_read(tree, tmp_ctx, &rd);
CHECK_STATUS(status, NT_STATUS_END_OF_FILE);
+ rd.in.min_count = 0;
+ rd.in.length = size;
+ rd.in.offset = 0;
+ status = smb2_read(tree, tmp_ctx, &rd);
+ CHECK_STATUS(status, NT_STATUS_OK);
+
done:
talloc_free(tmp_ctx);
return ret;