From 72cc1a1f12d4a44e3993cd958cd6e51e8fc1d693 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 25 May 2005 19:16:18 +0000 Subject: r6975: Test opening filenames with control characters in fails with INVALID_NAME. Jeremy. (This used to be commit ec72d7d614caf9504d98c96c86906ed598f8be78) --- source4/torture/torture.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'source4') diff --git a/source4/torture/torture.c b/source4/torture/torture.c index b7e2168319..d5ca41f9c2 100644 --- a/source4/torture/torture.c +++ b/source4/torture/torture.c @@ -1384,12 +1384,14 @@ static BOOL run_vuidtest(void) static struct smbcli_state *cli1; static struct smbcli_state *cli2; const char *fname = "\\readonly.file"; + char *control_char_fname; int fnum1, fnum2; uint8_t buf[20]; size_t fsize; BOOL correct = True; char *tmp_path; int failures = 0; + int i; printf("starting open test\n"); @@ -1397,6 +1399,30 @@ static BOOL run_vuidtest(void) return False; } + asprintf(&control_char_fname, "\\readonly.afile"); + for (i = 1; i <= 0x1f; i++) { + control_char_fname[10] = i; + fnum1 = smbcli_nt_create_full(cli1->tree, control_char_fname, 0, SEC_FILE_WRITE_DATA, FILE_ATTRIBUTE_NORMAL, + NTCREATEX_SHARE_ACCESS_NONE, NTCREATEX_DISP_OVERWRITE_IF, 0, 0); + + if (!check_error(__location__, cli1, ERRDOS, ERRinvalidname, + NT_STATUS_OBJECT_NAME_INVALID)) { + printf("Error code should be NT_STATUS_OBJECT_NAME_INVALID, was %s for file with %d char\n", + smbcli_errstr(cli1->tree), i); + failures++; + } + + if (fnum1 != -1) { + smbcli_close(cli1->tree, fnum1); + } + smbcli_setatr(cli1->tree, control_char_fname, 0, 0); + smbcli_unlink(cli1->tree, control_char_fname); + } + free(control_char_fname); + + if (!failures) + printf("Create file with control char names passed.\n"); + smbcli_setatr(cli1->tree, fname, 0, 0); smbcli_unlink(cli1->tree, fname); -- cgit