svn commit: samba r23662 - in branches: SAMBA_3_0/source
SAMBA_3_0/source/lib SAMBA_3_0/source/torture
SAMBA_3_0_26/source SAMBA_3_0_26/source/lib
SAMBA_3_0_26/source/torture
vlendec at samba.org
vlendec at samba.org
Fri Jun 29 17:51:34 GMT 2007
Author: vlendec
Date: 2007-06-29 17:51:31 +0000 (Fri, 29 Jun 2007)
New Revision: 23662
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=23662
Log:
According to simo, check_dos_char is needed
Added:
branches/SAMBA_3_0/source/torture/t_doschar.c
branches/SAMBA_3_0_26/source/torture/t_doschar.c
Modified:
branches/SAMBA_3_0/source/Makefile.in
branches/SAMBA_3_0/source/lib/charcnv.c
branches/SAMBA_3_0/source/lib/util_unistr.c
branches/SAMBA_3_0_26/source/Makefile.in
branches/SAMBA_3_0_26/source/lib/charcnv.c
branches/SAMBA_3_0_26/source/lib/util_unistr.c
Changeset:
Modified: branches/SAMBA_3_0/source/Makefile.in
===================================================================
--- branches/SAMBA_3_0/source/Makefile.in 2007-06-29 17:40:37 UTC (rev 23661)
+++ branches/SAMBA_3_0/source/Makefile.in 2007-06-29 17:51:31 UTC (rev 23662)
@@ -1735,6 +1735,8 @@
bin/t_stringoverflow at EXEEXT@: $(BINARY_PREREQS) bin/libbigballofmud. at SHLIBEXT@ torture/t_stringoverflow.o
$(CC) $(FLAGS) -o $@ $(DYNEXP) torture/t_stringoverflow.o -L./bin -lbigballofmud
+bin/t_doschar at EXEEXT@: $(BINARY_PREREQS) bin/libbigballofmud. at SHLIBEXT@ torture/t_doschar.o
+ $(CC) $(FLAGS) -o $@ $(DYNEXP) $(LIBS) torture/t_doschar.o -L ./bin -lbigballofmud
bin/t_push_ucs2 at EXEEXT@: $(BINARY_PREREQS) bin/libbigballofmud. at SHLIBEXT@ torture/t_push_ucs2.o
$(CC) $(FLAGS) -o $@ $(DYNEXP) $(LIBS) torture/t_push_ucs2.o -L ./bin -lbigballofmud
Modified: branches/SAMBA_3_0/source/lib/charcnv.c
===================================================================
--- branches/SAMBA_3_0/source/lib/charcnv.c 2007-06-29 17:40:37 UTC (rev 23661)
+++ branches/SAMBA_3_0/source/lib/charcnv.c 2007-06-29 17:51:31 UTC (rev 23662)
@@ -179,6 +179,7 @@
* codepage changes? */
/* XXX: Is the did_reload test too strict? */
conv_silent = True;
+ init_doschar_table();
init_valid_table();
conv_silent = False;
}
Modified: branches/SAMBA_3_0/source/lib/util_unistr.c
===================================================================
--- branches/SAMBA_3_0/source/lib/util_unistr.c 2007-06-29 17:40:37 UTC (rev 23661)
+++ branches/SAMBA_3_0/source/lib/util_unistr.c 2007-06-29 17:51:31 UTC (rev 23662)
@@ -36,6 +36,14 @@
static BOOL valid_table_use_unmap;
/**
+ * This table says which Unicode characters are valid dos
+ * characters.
+ *
+ * Each value is just a single bit.
+ **/
+static uint8 doschar_table[8192]; /* 65536 characters / 8 bits/byte */
+
+/**
* Destroy global objects allocated by load_case_tables()
**/
void gfree_case_tables(void)
@@ -142,6 +150,21 @@
#endif
}
+/*
+ see if a ucs2 character can be mapped correctly to a dos character
+ and mapped back to the same character in ucs2
+*/
+
+int check_dos_char(smb_ucs2_t c)
+{
+ lazy_initialize_conv();
+
+ /* Find the right byte, and right bit within the byte; return
+ * 1 or 0 */
+ return (doschar_table[(c & 0xffff) / 8] & (1 << (c & 7))) != 0;
+}
+
+
static int check_dos_char_slowly(smb_ucs2_t c)
{
char buf[10];
@@ -159,7 +182,34 @@
return (c == c2);
}
+
/**
+ * Fill out doschar table the hard way, by examining each character
+ **/
+
+void init_doschar_table(void)
+{
+ int i, j, byteval;
+
+ /* For each byte of packed table */
+
+ for (i = 0; i <= 0xffff; i += 8) {
+ byteval = 0;
+ for (j = 0; j <= 7; j++) {
+ smb_ucs2_t c;
+
+ c = i + j;
+
+ if (check_dos_char_slowly(c)) {
+ byteval |= 1 << j;
+ }
+ }
+ doschar_table[i/8] = byteval;
+ }
+}
+
+
+/**
* Load the valid character map table from <tt>valid.dat</tt> or
* create from the configured codepage.
*
@@ -207,7 +257,7 @@
for (;i<0x10000;i++) {
smb_ucs2_t c;
SSVAL(&c, 0, i);
- valid_table[i] = check_dos_char_slowly(c);
+ valid_table[i] = check_dos_char(c);
}
}
Copied: branches/SAMBA_3_0/source/torture/t_doschar.c (from rev 23659, branches/SAMBA_3_0/source/torture/t_doschar.c)
Modified: branches/SAMBA_3_0_26/source/Makefile.in
===================================================================
--- branches/SAMBA_3_0_26/source/Makefile.in 2007-06-29 17:40:37 UTC (rev 23661)
+++ branches/SAMBA_3_0_26/source/Makefile.in 2007-06-29 17:51:31 UTC (rev 23662)
@@ -1725,6 +1725,8 @@
bin/t_stringoverflow at EXEEXT@: $(BINARY_PREREQS) bin/libbigballofmud. at SHLIBEXT@ torture/t_stringoverflow.o
$(CC) $(FLAGS) -o $@ $(DYNEXP) torture/t_stringoverflow.o -L./bin -lbigballofmud
+bin/t_doschar at EXEEXT@: $(BINARY_PREREQS) bin/libbigballofmud. at SHLIBEXT@ torture/t_doschar.o
+ $(CC) $(FLAGS) -o $@ $(DYNEXP) $(LIBS) torture/t_doschar.o -L ./bin -lbigballofmud
bin/t_push_ucs2 at EXEEXT@: $(BINARY_PREREQS) bin/libbigballofmud. at SHLIBEXT@ torture/t_push_ucs2.o
$(CC) $(FLAGS) -o $@ $(DYNEXP) $(LIBS) torture/t_push_ucs2.o -L ./bin -lbigballofmud
Modified: branches/SAMBA_3_0_26/source/lib/charcnv.c
===================================================================
--- branches/SAMBA_3_0_26/source/lib/charcnv.c 2007-06-29 17:40:37 UTC (rev 23661)
+++ branches/SAMBA_3_0_26/source/lib/charcnv.c 2007-06-29 17:51:31 UTC (rev 23662)
@@ -179,6 +179,7 @@
* codepage changes? */
/* XXX: Is the did_reload test too strict? */
conv_silent = True;
+ init_doschar_table();
init_valid_table();
conv_silent = False;
}
Modified: branches/SAMBA_3_0_26/source/lib/util_unistr.c
===================================================================
--- branches/SAMBA_3_0_26/source/lib/util_unistr.c 2007-06-29 17:40:37 UTC (rev 23661)
+++ branches/SAMBA_3_0_26/source/lib/util_unistr.c 2007-06-29 17:51:31 UTC (rev 23662)
@@ -36,6 +36,14 @@
static BOOL valid_table_use_unmap;
/**
+ * This table says which Unicode characters are valid dos
+ * characters.
+ *
+ * Each value is just a single bit.
+ **/
+static uint8 doschar_table[8192]; /* 65536 characters / 8 bits/byte */
+
+/**
* Destroy global objects allocated by load_case_tables()
**/
void gfree_case_tables(void)
@@ -142,6 +150,21 @@
#endif
}
+/*
+ see if a ucs2 character can be mapped correctly to a dos character
+ and mapped back to the same character in ucs2
+*/
+
+int check_dos_char(smb_ucs2_t c)
+{
+ lazy_initialize_conv();
+
+ /* Find the right byte, and right bit within the byte; return
+ * 1 or 0 */
+ return (doschar_table[(c & 0xffff) / 8] & (1 << (c & 7))) != 0;
+}
+
+
static int check_dos_char_slowly(smb_ucs2_t c)
{
char buf[10];
@@ -159,7 +182,34 @@
return (c == c2);
}
+
/**
+ * Fill out doschar table the hard way, by examining each character
+ **/
+
+void init_doschar_table(void)
+{
+ int i, j, byteval;
+
+ /* For each byte of packed table */
+
+ for (i = 0; i <= 0xffff; i += 8) {
+ byteval = 0;
+ for (j = 0; j <= 7; j++) {
+ smb_ucs2_t c;
+
+ c = i + j;
+
+ if (check_dos_char_slowly(c)) {
+ byteval |= 1 << j;
+ }
+ }
+ doschar_table[i/8] = byteval;
+ }
+}
+
+
+/**
* Load the valid character map table from <tt>valid.dat</tt> or
* create from the configured codepage.
*
@@ -207,7 +257,7 @@
for (;i<0x10000;i++) {
smb_ucs2_t c;
SSVAL(&c, 0, i);
- valid_table[i] = check_dos_char_slowly(c);
+ valid_table[i] = check_dos_char(c);
}
}
Copied: branches/SAMBA_3_0_26/source/torture/t_doschar.c (from rev 23659, branches/SAMBA_3_0_26/source/torture/t_doschar.c)
More information about the samba-cvs
mailing list