From 5155a5f5c130ff5b71ce4e37877378a6967046b4 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 18 Feb 2011 11:51:33 +1100 Subject: s3-charcnv Don't genreate valid_table on the fly, rely on valid.dat This file is always installed, and is only even required for the old, depricated mangle hash method. Andrew Bartlett --- source3/include/proto.h | 1 - source3/lib/charcnv.c | 9 --------- source3/lib/util_unistr.c | 50 ++++++++--------------------------------------- 3 files changed, 8 insertions(+), 52 deletions(-) (limited to 'source3') diff --git a/source3/include/proto.h b/source3/include/proto.h index 6af1613afa..0885053098 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -1473,7 +1473,6 @@ char *sanitize_username(TALLOC_CTX *mem_ctx, const char *username); void gfree_case_tables(void); void load_case_tables(void); -void init_valid_table(void); size_t dos_PutUniCode(char *dst,const char *src, size_t len, bool null_terminate); char *skip_unibuf(char *src, size_t len); int rpcstr_push(void *dest, const char *src, size_t dest_len, int flags); diff --git a/source3/lib/charcnv.c b/source3/lib/charcnv.c index f79785ef15..4c98f8f339 100644 --- a/source3/lib/charcnv.c +++ b/source3/lib/charcnv.c @@ -188,15 +188,6 @@ void init_iconv(void) } } } - - if (did_reload) { - /* XXX: Does this really get called every time the dos - * codepage changes? */ - /* XXX: Is the did_reload test too strict? */ - conv_silent = True; - init_valid_table(); - conv_silent = False; - } } /** diff --git a/source3/lib/util_unistr.c b/source3/lib/util_unistr.c index 6199a35fc8..02a95bdbed 100644 --- a/source3/lib/util_unistr.c +++ b/source3/lib/util_unistr.c @@ -28,7 +28,6 @@ /* these 3 tables define the unicode case handling. They are loaded at startup either via mmap() or read() from the lib directory */ static uint8 *valid_table; -static bool valid_table_use_unmap; static bool initialized; /** @@ -37,10 +36,8 @@ static bool initialized; void gfree_case_tables(void) { if ( valid_table ) { - if ( valid_table_use_unmap ) - unmap_file(valid_table, 0x10000); - else - SAFE_FREE(valid_table); + unmap_file(valid_table, 0x10000); + valid_table = NULL; } initialized = false; } @@ -71,49 +68,17 @@ static int check_dos_char_slowly(smb_ucs2_t c) * from a file, because we can't unmap files. **/ -void init_valid_table(void) +static void init_valid_table(void) { - static int mapped_file; - int i; - const char *allowed = ".!#$%&'()_-@^`~"; - uint8 *valid_file; - - if (mapped_file) { - /* Can't unmap files, so stick with what we have */ + if (valid_table) { return; } - valid_file = (uint8 *)map_file(data_path("valid.dat"), 0x10000); - if (valid_file) { - valid_table = valid_file; - mapped_file = 1; - valid_table_use_unmap = True; + valid_table = (uint8 *)map_file(data_path("valid.dat"), 0x10000); + if (!valid_table) { + smb_panic("Could not load valid.dat file required for mangle method=hash"); return; } - - /* Otherwise, we're using a dynamically created valid_table. - * It might need to be regenerated if the code page changed. - * We know that we're not using a mapped file, so we can - * free() the old one. */ - SAFE_FREE(valid_table); - - /* use free rather than unmap */ - valid_table_use_unmap = False; - - DEBUG(2,("creating default valid table\n")); - valid_table = (uint8 *)SMB_MALLOC(0x10000); - SMB_ASSERT(valid_table != NULL); - for (i=0;i<128;i++) { - valid_table[i] = isalnum(i) || strchr(allowed,i); - } - - lazy_initialize_conv(); - - for (;i<0x10000;i++) { - smb_ucs2_t c; - SSVAL(&c, 0, i); - valid_table[i] = check_dos_char_slowly(c); - } } /******************************************************************* @@ -182,6 +147,7 @@ int rpcstr_push_talloc(TALLOC_CTX *ctx, smb_ucs2_t **dest, const char *src) bool isvalid83_w(smb_ucs2_t c) { + init_valid_table(); return valid_table[SVAL(&c,0)] != 0; } -- cgit