summaryrefslogtreecommitdiff
path: root/mysys/charset.c
diff options
context:
space:
mode:
authorbar@bar.intranet.mysql.r18.ru <>2004-01-15 17:07:29 +0400
committerbar@bar.intranet.mysql.r18.ru <>2004-01-15 17:07:29 +0400
commitdb83208d36fa183d9433898c47246561e365866f (patch)
treeacb345bdc9b8d4413080f84daaa2696494f56a56 /mysys/charset.c
parent7aa82031dc50867bcc6ec6b08c27bca7185610f8 (diff)
downloadmariadb-git-db83208d36fa183d9433898c47246561e365866f.tar.gz
charset.c:
http://bugs.mysql.com/bug.php?id=2386 Index.xml file larger than 1024*16 Fix for the above bug.
Diffstat (limited to 'mysys/charset.c')
-rw-r--r--mysys/charset.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/mysys/charset.c b/mysys/charset.c
index b911f29627c..5e9e3c3fcaa 100644
--- a/mysys/charset.c
+++ b/mysys/charset.c
@@ -357,7 +357,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 +369,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))