diff options
author | Alexander Barkov <bar@mariadb.org> | 2015-04-24 11:00:34 +0400 |
---|---|---|
committer | Alexander Barkov <bar@mariadb.org> | 2015-04-24 11:00:34 +0400 |
commit | 44d1e85fe54734f7102dae8dac62360d50f94157 (patch) | |
tree | 95be6e0790d761b0fab8e60621133e2980dcb1b0 /strings | |
parent | f9b2704f3c78028812e8cb5fb61365aec940257a (diff) | |
download | mariadb-git-44d1e85fe54734f7102dae8dac62360d50f94157.tar.gz |
MDEV-7649 wrong result when comparing utf8 column with an invalid literal
Diffstat (limited to 'strings')
-rw-r--r-- | strings/ctype-uca.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/strings/ctype-uca.c b/strings/ctype-uca.c index ad484acd21e..6bc71bcade3 100644 --- a/strings/ctype-uca.c +++ b/strings/ctype-uca.c @@ -7075,7 +7075,25 @@ static int my_uca_scanner_next_any(my_uca_scanner *scanner) if (((mb_len= scanner->cs->cset->mb_wc(scanner->cs, &wc, scanner->sbeg, scanner->send)) <= 0)) - return -1; + { + if (scanner->sbeg >= scanner->send) + return -1; /* No more bytes, end of line reached */ + /* + There are some more bytes left. Non-positive mb_len means that + we got an incomplete or a bad byte sequence. Consume mbminlen bytes. + */ + if ((scanner->sbeg+= scanner->cs->mbminlen) > scanner->send) + { + /* For safety purposes don't go beyond the string range. */ + scanner->sbeg= scanner->send; + } + /* + Treat every complete or incomplete mbminlen unit as a weight which is + greater than weight for any possible normal character. + 0xFFFF is greater than any possible weight in the UCA weight table. + */ + return 0xFFFF; + } scanner->sbeg+= mb_len; if (wc > MAX_UCA_CHAR_WITH_EXPLICIT_WEIGHT) |