summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2016-12-02 00:19:49 +0100
committerSergei Golubchik <serg@mariadb.org>2016-12-03 22:03:38 +0100
commit4a3acbcfd07291ecc141f37200eec79eb1713882 (patch)
tree3266c4d33a5af196d997a965dc6239e3486b5dd8
parent0a4b508173a0cd32f329df3514bf34c2f2001317 (diff)
downloadmariadb-git-4a3acbcfd07291ecc141f37200eec79eb1713882.tar.gz
MDEV-11241 Certain combining marks cause MariaDB to crash when doing Full-Text searches
Don't assume that a word of n bytes can match a word of at most n * charset->mbmaxlen bytes, always go for the worst.
-rw-r--r--mysql-test/r/fulltext_charsets.result7
-rw-r--r--mysql-test/t/fulltext_charsets.test10
-rw-r--r--storage/myisam/ft_boolean_search.c7
3 files changed, 18 insertions, 6 deletions
diff --git a/mysql-test/r/fulltext_charsets.result b/mysql-test/r/fulltext_charsets.result
new file mode 100644
index 00000000000..39ce02a3fce
--- /dev/null
+++ b/mysql-test/r/fulltext_charsets.result
@@ -0,0 +1,7 @@
+set names utf8mb4;
+create table t1 (a int, b text, fulltext (b)) charset=utf8mb4 collate=utf8mb4_unicode_ci;
+insert t1 values (1000, 'C͓̙̯͔̩ͅͅi̩̘̜̲a̯̲̬̳̜̖̤o͕͓̜͓̺̖̗,̠̬͚ ̺T͇̲h͈̱e ̬̜D̖o̦̖͔̗͖̩̘c̣̼t̝͉̫̮̗o͉̫̭r̙͎̗.͓̪̥');
+select a from t1 where match(b) against ('ciao' in boolean mode);
+a
+1000
+drop table t1;
diff --git a/mysql-test/t/fulltext_charsets.test b/mysql-test/t/fulltext_charsets.test
new file mode 100644
index 00000000000..3ac9791bd1a
--- /dev/null
+++ b/mysql-test/t/fulltext_charsets.test
@@ -0,0 +1,10 @@
+#
+# MDEV-11241 Certain combining marks cause MariaDB to crash when doing Full-Text searches
+#
+set names utf8mb4;
+
+create table t1 (a int, b text, fulltext (b)) charset=utf8mb4 collate=utf8mb4_unicode_ci;
+insert t1 values (1000, 'C͓̙̯͔̩ͅͅi̩̘̜̲a̯̲̬̳̜̖̤o͕͓̜͓̺̖̗,̠̬͚ ̺T͇̲h͈̱e ̬̜D̖o̦̖͔̗͖̩̘c̣̼t̝͉̫̮̗o͉̫̭r̙͎̗.͓̪̥');
+select a from t1 where match(b) against ('ciao' in boolean mode);
+drop table t1;
+
diff --git a/storage/myisam/ft_boolean_search.c b/storage/myisam/ft_boolean_search.c
index b67f1ea6a25..16432d0161c 100644
--- a/storage/myisam/ft_boolean_search.c
+++ b/storage/myisam/ft_boolean_search.c
@@ -195,12 +195,7 @@ static int ftb_query_add_word(MYSQL_FTPARSER_PARAM *param,
switch (info->type) {
case FT_TOKEN_WORD:
ftbw= (FTB_WORD *)alloc_root(&ftb_param->ftb->mem_root,
- sizeof(FTB_WORD) +
- (info->trunc ? HA_MAX_KEY_BUFF :
- (word_len + 1) *
- ftb_param->ftb->charset->mbmaxlen +
- HA_FT_WLEN +
- ftb_param->ftb->info->s->rec_reflength));
+ sizeof(FTB_WORD) + HA_MAX_KEY_BUFF);
ftbw->len= word_len + 1;
ftbw->flags= 0;
ftbw->off= 0;