diff options
author | Alexander Barkov <bar@mariadb.com> | 2021-10-29 12:24:47 +0400 |
---|---|---|
committer | Alexander Barkov <bar@mariadb.com> | 2021-10-29 12:37:29 +0400 |
commit | 059797ed44007fe954cf47f6f09db78e60df16fd (patch) | |
tree | e2d8d42bcd0fff79ec545c6d9dffe3a04433b49c /strings | |
parent | 42ae765960869a7ce381341d7b98c1e8aa157b29 (diff) | |
download | mariadb-git-059797ed44007fe954cf47f6f09db78e60df16fd.tar.gz |
MDEV-24901 SIGSEGV in fts_get_table_name, SIGSEGV in ib_vector_size, SIGSEGV in row_merge_fts_doc_tokenize, stack smashingbb-10.2-bar-MDEV-24901
strmake() puts one extra 0x00 byte at the end of the string.
The code in my_strnxfrm_tis620[_nopad] did not take this into
account, so in the reported scenario the 0x00 byte was put outside
of a stack variable, which made ASAN crash.
This problem is already fixed in in MySQL:
commit 19bd66fe43c41f0bde5f36bc6b455a46693069fb
Author: bin.x.su@oracle.com <>
Date: Fri Apr 4 11:35:27 2014 +0800
But the fix does not seem to be correct, as it breaks when finds a zero byte
in the source string.
Using memcpy() instead of strmake().
- Unlike strmake(), memcpy() it does not write beyond the destination
size passed.
- Unlike the MySQL fix, memcpy() does not break on the first 0x00 byte found
in the source string.
Diffstat (limited to 'strings')
-rw-r--r-- | strings/ctype-tis620.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/strings/ctype-tis620.c b/strings/ctype-tis620.c index 66bd1604803..4f1d12ae741 100644 --- a/strings/ctype-tis620.c +++ b/strings/ctype-tis620.c @@ -605,8 +605,8 @@ my_strnxfrm_tis620(CHARSET_INFO *cs, const uchar *src, size_t srclen, uint flags) { size_t len, dstlen0= dstlen; - len= (uint) (strmake((char*) dst, (char*) src, MY_MIN(dstlen, srclen)) - - (char*) dst); + len= MY_MIN(dstlen, srclen); + memcpy(dst, src, len); len= thai2sortable(dst, len); set_if_smaller(dstlen, nweights); set_if_smaller(len, dstlen); @@ -628,8 +628,8 @@ my_strnxfrm_tis620_nopad(CHARSET_INFO *cs, const uchar *src, size_t srclen, uint flags) { size_t len, dstlen0= dstlen; - len= (uint) (strmake((char*) dst, (char*) src, MY_MIN(dstlen, srclen)) - - (char*) dst); + len= MY_MIN(dstlen, srclen); + memcpy(dst, src, len); len= thai2sortable(dst, len); set_if_smaller(dstlen, nweights); set_if_smaller(len, dstlen); |