summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2001-10-02 05:52:11 +0000
committerAndrew Tridgell <tridge@samba.org>2001-10-02 05:52:11 +0000
commit58bc10518bad61e6c8dee38fda82eb8fb1de4bf6 (patch)
tree15237049383eea4e762937374ba489bea8d905ff
parentdc1fc3ee8ec2199bc73bb5d7ec711c6800f61d65 (diff)
downloadsamba-58bc10518bad61e6c8dee38fda82eb8fb1de4bf6.tar.gz
samba-58bc10518bad61e6c8dee38fda82eb8fb1de4bf6.tar.bz2
samba-58bc10518bad61e6c8dee38fda82eb8fb1de4bf6.zip
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. (This used to be commit 441f9415b365787854fb0d3e04d1ea4938d7af73)
-rw-r--r--source3/torture/torture.c1
-rw-r--r--source3/torture/utable.c74
2 files changed, 75 insertions, 0 deletions
diff --git a/source3/torture/torture.c b/source3/torture/torture.c
index a34f9aa085..e92c933015 100644
--- a/source3/torture/torture.c
+++ b/source3/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/source3/torture/utable.c b/source3/torture/utable.c
index c710815d9c..ea36487f64 100644
--- a/source3/torture/utable.c
+++ b/source3/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;
+}