From f30ff10c8d02d8385bafa290b8c73367d49aece2 Mon Sep 17 00:00:00 2001 From: Varun Gupta Date: Fri, 29 May 2020 00:32:08 +0530 Subject: MDEV-22715: SIGSEGV in radixsort_for_str_ptr and in native_compare/my_qsort2 (optimized builds) For DECIMAL[(M[,D])] datatype max_sort_length was not being honoured which was leading to buffer overflow while making the sort key. The fix to this problem would be to create sort keys for decimals with atmost max_sort_key bytes Important: The minimum value of max_sort_length has been raised to 8 (previously was 4), so fixed size datatypes like DOUBLE and BIGINIT are not truncated for lower values of max_sort_length. --- sql/field.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'sql/field.h') diff --git a/sql/field.h b/sql/field.h index 60849ea8099..5e8f39d903e 100644 --- a/sql/field.h +++ b/sql/field.h @@ -1099,6 +1099,13 @@ public: void make_sort_key(uchar *buff, uint length); virtual void make_field(Send_field *); + + /* + Some implementations actually may write up to 8 bytes regardless of what + size was requested. This is due to the minimum value of the system variable + max_sort_length. + */ + virtual void sort_string(uchar *buff,uint length)=0; virtual bool optimize_range(uint idx, uint part); virtual void free() {} -- cgit v1.2.1