diff options
author | Andrew Tridgell <tridge@samba.org> | 2001-10-02 05:52:11 +0000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2001-10-02 05:52:11 +0000 |
commit | 441f9415b365787854fb0d3e04d1ea4938d7af73 (patch) | |
tree | f2e9ef1685b659e5e62aec5ef22fde54f5a7ca28 /source | |
parent | 2d0922b0eabfdc0aaf1d0797482fef47ed7fde8e (diff) | |
download | samba-441f9415b365787854fb0d3e04d1ea4938d7af73.tar.gz |
the CASETABLE torture target now generates the complete unicode
equivalence table for a server. This was inspired by the chargen win32
code from monyo.
This takes a *long* time to run against a Samba server due to the case
insensitive comparisons in the filesystem. That makes it a N^2
operation, and N is 64k. It is linear on NT.
Diffstat (limited to 'source')
-rw-r--r-- | source/torture/torture.c | 1 | ||||
-rw-r--r-- | source/torture/utable.c | 74 |
2 files changed, 75 insertions, 0 deletions
diff --git a/source/torture/torture.c b/source/torture/torture.c index a34f9aa0853..e92c933015f 100644 --- a/source/torture/torture.c +++ b/source/torture/torture.c @@ -2990,6 +2990,7 @@ static struct { {"TRANS2SCAN", torture_trans2_scan, 0}, {"NTTRANSSCAN", torture_nttrans_scan, 0}, {"UTABLE", torture_utable, 0}, + {"CASETABLE", torture_casetable, 0}, {NULL, NULL, 0}}; diff --git a/source/torture/utable.c b/source/torture/utable.c index c710815d9cd..ea36487f64e 100644 --- a/source/torture/utable.c +++ b/source/torture/utable.c @@ -80,3 +80,77 @@ BOOL torture_utable(int dummy) return True; } + + +static char *form_name(int c) +{ + static fstring fname; + smb_ucs2_t c2; + char *p; + int len; + + fstrcpy(fname, "\\utable\\x"); + p = fname+strlen(fname); + SSVAL(&c2, 0, c); + + len = convert_string(CH_UCS2, CH_UNIX, + &c2, 2, + p, sizeof(fname)-strlen(fname)); + p[len] = 0; + fstrcat(fname,"_a_long_extension"); + return fname; +} + +BOOL torture_casetable(int dummy) +{ + static struct cli_state cli; + char *fname; + int fnum; + int c; + + printf("starting utable\n"); + + if (!torture_open_connection(&cli)) { + return False; + } + + cli_mkdir(&cli, "\\utable"); + cli_unlink(&cli, "\\utable\\*"); + + for (c=1; c < 0x10000; c++) { + fname = form_name(c); + fnum = cli_nt_create_full(&cli, fname, + GENERIC_ALL_ACCESS, + FILE_ATTRIBUTE_NORMAL, + FILE_SHARE_NONE, + FILE_CREATE, 0); + + if (fnum == -1 && + NT_STATUS_EQUAL(cli_nt_error(&cli),NT_STATUS_OBJECT_NAME_COLLISION)) { + /* found a character equivalence! */ + int c2; + + fnum = cli_nt_create_full(&cli, fname, + GENERIC_ALL_ACCESS, + FILE_ATTRIBUTE_NORMAL, + FILE_SHARE_NONE, + FILE_OPEN, 0); + if (fnum == -1 || + cli_read(&cli, fnum, (char *)&c2, 0, sizeof(c2)) != sizeof(c2)) { + continue; + } + + printf("%04x == %04x\n", c, c2); + cli_close(&cli, fnum); + continue; + } + + cli_write(&cli, fnum, 0, (char *)&c, 0, sizeof(c)); + cli_close(&cli, fnum); + } + + cli_unlink(&cli, "\\utable\\*"); + cli_rmdir(&cli, "\\utable"); + + return True; +} |