Skip to content

Commit 4a3acbc

Browse files
committed
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.
1 parent 0a4b508 commit 4a3acbc

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
set names utf8mb4;
2+
create table t1 (a int, b text, fulltext (b)) charset=utf8mb4 collate=utf8mb4_unicode_ci;
3+
insert t1 values (1000, 'C͓̙̯͔̩ͅͅi̩̘̜̲a̯̲̬̳̜̖̤o͕͓̜͓̺̖̗,̠̬͚ ̺T͇̲h͈̱e ̬̜D̖o̦̖͔̗͖̩̘c̣̼t̝͉̫̮̗o͉̫̭r̙͎̗.͓̪̥');
4+
select a from t1 where match(b) against ('ciao' in boolean mode);
5+
a
6+
1000
7+
drop table t1;
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#
2+
# MDEV-11241 Certain combining marks cause MariaDB to crash when doing Full-Text searches
3+
#
4+
set names utf8mb4;
5+
6+
create table t1 (a int, b text, fulltext (b)) charset=utf8mb4 collate=utf8mb4_unicode_ci;
7+
insert t1 values (1000, 'C͓̙̯͔̩ͅͅi̩̘̜̲a̯̲̬̳̜̖̤o͕͓̜͓̺̖̗,̠̬͚ ̺T͇̲h͈̱e ̬̜D̖o̦̖͔̗͖̩̘c̣̼t̝͉̫̮̗o͉̫̭r̙͎̗.͓̪̥');
8+
select a from t1 where match(b) against ('ciao' in boolean mode);
9+
drop table t1;
10+

storage/myisam/ft_boolean_search.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -195,12 +195,7 @@ static int ftb_query_add_word(MYSQL_FTPARSER_PARAM *param,
195195
switch (info->type) {
196196
case FT_TOKEN_WORD:
197197
ftbw= (FTB_WORD *)alloc_root(&ftb_param->ftb->mem_root,
198-
sizeof(FTB_WORD) +
199-
(info->trunc ? HA_MAX_KEY_BUFF :
200-
(word_len + 1) *
201-
ftb_param->ftb->charset->mbmaxlen +
202-
HA_FT_WLEN +
203-
ftb_param->ftb->info->s->rec_reflength));
198+
sizeof(FTB_WORD) + HA_MAX_KEY_BUFF);
204199
ftbw->len= word_len + 1;
205200
ftbw->flags= 0;
206201
ftbw->off= 0;

0 commit comments

Comments
 (0)