diff options
author | monty@mysql.com <> | 2004-01-20 00:15:01 +0100 |
---|---|---|
committer | monty@mysql.com <> | 2004-01-20 00:15:01 +0100 |
commit | b078d2df64e46a8fc4f4d266dccd7906e084d559 (patch) | |
tree | d20bcd6bae79e9d29ece05ef1bb92e9041747f39 /mysys/charset.c | |
parent | 0eb607006879210b04278d0a961e28e72616645d (diff) | |
parent | eb0ae211c589ca767a464b47da2fda98fabce674 (diff) | |
download | mariadb-git-b078d2df64e46a8fc4f4d266dccd7906e084d559.tar.gz |
merge
Diffstat (limited to 'mysys/charset.c')
-rw-r--r-- | mysys/charset.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/mysys/charset.c b/mysys/charset.c index fec0778213f..c0d8b183c17 100644 --- a/mysys/charset.c +++ b/mysys/charset.c @@ -131,7 +131,8 @@ static void simple_cs_init_functions(CHARSET_INFO *cs) cs->coll= &my_collation_8bit_simple_ci_handler; cs->cset= &my_charset_8bit_handler; - cs->mbmaxlen = 1; + cs->mbminlen= 1; + cs->mbmaxlen= 1; } @@ -273,6 +274,7 @@ static int simple_cs_copy_data(CHARSET_INFO *to, CHARSET_INFO *from) if (create_fromuni(to)) goto err; } + to->mbminlen= 1; to->mbmaxlen= 1; return 0; @@ -357,7 +359,7 @@ static int add_collation(CHARSET_INFO *cs) } -#define MAX_BUF 1024*16 +#define MY_MAX_ALLOWED_BUF 1024*1024 #define MY_CHARSET_INDEX "Index.xml" const char *charsets_dir= NULL; @@ -369,16 +371,19 @@ static my_bool my_read_charset_file(const char *filename, myf myflags) char *buf; int fd; uint len; + MY_STAT stat_info; - if (!(buf= (char *)my_malloc(MAX_BUF,myflags))) - return FALSE; + if (!my_stat(filename, &stat_info, MYF(MY_WME)) || + ((len= (uint)stat_info.st_size) > MY_MAX_ALLOWED_BUF) || + !(buf= (char *)my_malloc(len,myflags))) + return TRUE; if ((fd=my_open(filename,O_RDONLY,myflags)) < 0) { my_free(buf,myflags); return TRUE; } - len=read(fd,buf,MAX_BUF); + len=read(fd,buf,len); my_close(fd,myflags); if (my_parse_charset_xml(buf,len,add_collation)) @@ -543,6 +548,7 @@ static CHARSET_INFO *get_internal_charset(uint cs_number, myf flags) cs= (cs->state & MY_CS_AVAILABLE) ? cs : NULL; } pthread_mutex_unlock(&THR_LOCK_charset); + pthread_mutex_unlock(&THR_LOCK_charset); return cs; } |