/* see if the server recognises composed characters */ static BOOL test_composed(struct torture_context *tctx, struct smbcli_state *cli, TALLOC_CTX *mem_ctx) { const uint32_t name1[] = {0x61, 0x308}; const uint32_t name2[] = {0xe4}; NTSTATUS status1, status2; printf("Testing composite character (a umlaut)\n"); status1 = unicode_open(tctx, cli->tree, mem_ctx, NTCREATEX_DISP_CREATE, name1, 2); if (!NT_STATUS_IS_OK(status1)) { printf("Failed to create composed name - %s\n", nt_errstr(status1)); return False; } status2 = unicode_open(tctx, cli->tree, mem_ctx, NTCREATEX_DISP_CREATE, name2, 1); if (!NT_STATUS_IS_OK(status2)) { printf("Failed to create accented character - %s\n", nt_errstr(status2)); return False; } return True; }
/* see if the server recognises a naked diacritical */ static BOOL test_diacritical(struct torture_context *tctx, struct smbcli_state *cli, TALLOC_CTX *mem_ctx) { const uint32_t name1[] = {0x308}; const uint32_t name2[] = {0x308, 0x308}; NTSTATUS status1, status2; printf("Testing naked diacritical (umlaut)\n"); status1 = unicode_open(tctx, cli->tree, mem_ctx, NTCREATEX_DISP_CREATE, name1, 1); if (!NT_STATUS_IS_OK(status1)) { printf("Failed to create naked diacritical - %s\n", nt_errstr(status1)); return False; } /* try a double diacritical */ status2 = unicode_open(tctx, cli->tree, mem_ctx, NTCREATEX_DISP_CREATE, name2, 2); if (!NT_STATUS_IS_OK(status2)) { printf("Failed to create double naked diacritical - %s\n", nt_errstr(status2)); return False; } return True; }
/* see if the server recognises wide-a characters */ static bool test_widea(struct torture_context *tctx, struct smbcli_state *cli) { const uint32_t name1[] = {'a'}; const uint32_t name2[] = {0xff41}; const uint32_t name3[] = {0xff21}; NTSTATUS status; torture_assert(tctx, torture_setup_dir(cli, BASEDIR), "setting up basedir"); status = unicode_open(tctx, cli->tree, tctx, NTCREATEX_DISP_CREATE, name1, 1); torture_assert_ntstatus_ok(tctx, status, "Failed to create 'a'"); status = unicode_open(tctx, cli->tree, tctx, NTCREATEX_DISP_CREATE, name2, 1); torture_assert_ntstatus_ok(tctx, status, "Failed to create wide-a"); status = unicode_open(tctx, cli->tree, tctx, NTCREATEX_DISP_CREATE, name3, 1); torture_assert_ntstatus_equal(tctx, status, NT_STATUS_OBJECT_NAME_COLLISION, "Failed to create wide-A"); return true; }
/* see if the server recognises a partial surrogate pair */ static bool test_surrogate(struct torture_context *tctx, struct smbcli_state *cli) { const uint32_t name1[] = {0xd800}; const uint32_t name2[] = {0xdc00}; const uint32_t name3[] = {0xd800, 0xdc00}; NTSTATUS status; torture_assert(tctx, torture_setup_dir(cli, BASEDIR), "setting up basedir"); status = unicode_open(tctx, cli->tree, tctx, NTCREATEX_DISP_CREATE, name1, 1); torture_assert_ntstatus_ok(tctx, status, "Failed to create partial surrogate 1"); status = unicode_open(tctx, cli->tree, tctx, NTCREATEX_DISP_CREATE, name2, 1); torture_assert_ntstatus_ok(tctx, status, "Failed to create partial surrogate 2"); status = unicode_open(tctx, cli->tree, tctx, NTCREATEX_DISP_CREATE, name3, 2); torture_assert_ntstatus_ok(tctx, status, "Failed to create full surrogate"); return true; }
/* see if the server recognises composed characters */ static bool test_composed(struct torture_context *tctx, struct smbcli_state *cli) { const uint32_t name1[] = {0x61, 0x308}; const uint32_t name2[] = {0xe4}; NTSTATUS status1, status2; torture_assert(tctx, torture_setup_dir(cli, BASEDIR), "setting up basedir"); status1 = unicode_open(tctx, cli->tree, tctx, NTCREATEX_DISP_CREATE, name1, 2); torture_assert_ntstatus_ok(tctx, status1, "Failed to create composed name"); status2 = unicode_open(tctx, cli->tree, tctx, NTCREATEX_DISP_CREATE, name2, 1); torture_assert_ntstatus_ok(tctx, status2, "Failed to create accented character"); return true; }
/* see if the server recognises a naked diacritical */ static bool test_diacritical(struct torture_context *tctx, struct smbcli_state *cli) { const uint32_t name1[] = {0x308}; const uint32_t name2[] = {0x308, 0x308}; NTSTATUS status1, status2; torture_assert(tctx, torture_setup_dir(cli, BASEDIR), "setting up basedir"); status1 = unicode_open(tctx, cli->tree, tctx, NTCREATEX_DISP_CREATE, name1, 1); torture_assert_ntstatus_ok(tctx, status1, "Failed to create naked diacritical"); /* try a double diacritical */ status2 = unicode_open(tctx, cli->tree, tctx, NTCREATEX_DISP_CREATE, name2, 2); torture_assert_ntstatus_ok(tctx, status2, "Failed to create double naked diacritical"); return true; }
/* see if the server recognises wide-a characters */ static BOOL test_widea(struct torture_context *tctx, struct smbcli_state *cli, TALLOC_CTX *mem_ctx) { const uint32_t name1[] = {'a'}; const uint32_t name2[] = {0xff41}; const uint32_t name3[] = {0xff21}; NTSTATUS status; printf("Testing wide-a\n"); status = unicode_open(tctx, cli->tree, mem_ctx, NTCREATEX_DISP_CREATE, name1, 1); if (!NT_STATUS_IS_OK(status)) { printf("Failed to create 'a' - %s\n", nt_errstr(status)); return False; } status = unicode_open(tctx, cli->tree, mem_ctx, NTCREATEX_DISP_CREATE, name2, 1); if (!NT_STATUS_IS_OK(status)) { printf("Failed to create wide-a - %s\n", nt_errstr(status)); return False; } status = unicode_open(tctx, cli->tree, mem_ctx, NTCREATEX_DISP_CREATE, name3, 1); if (!NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_COLLISION)) { printf("Expected %s creating wide-A - %s\n", nt_errstr(NT_STATUS_OBJECT_NAME_COLLISION), nt_errstr(status)); return False; } return True; }
/* see if the server recognises a partial surrogate pair */ static BOOL test_surrogate(struct torture_context *tctx, struct smbcli_state *cli, TALLOC_CTX *mem_ctx) { const uint32_t name1[] = {0xd800}; const uint32_t name2[] = {0xdc00}; const uint32_t name3[] = {0xd800, 0xdc00}; NTSTATUS status; printf("Testing partial surrogate\n"); status = unicode_open(tctx, cli->tree, mem_ctx, NTCREATEX_DISP_CREATE, name1, 1); if (!NT_STATUS_IS_OK(status)) { printf("Failed to create partial surrogate 1 - %s\n", nt_errstr(status)); return False; } status = unicode_open(tctx, cli->tree, mem_ctx, NTCREATEX_DISP_CREATE, name2, 1); if (!NT_STATUS_IS_OK(status)) { printf("Failed to create partial surrogate 2 - %s\n", nt_errstr(status)); return False; } status = unicode_open(tctx, cli->tree, mem_ctx, NTCREATEX_DISP_CREATE, name3, 2); if (!NT_STATUS_IS_OK(status)) { printf("Failed to create full surrogate - %s\n", nt_errstr(status)); return False; } return True; }