summaryrefslogtreecommitdiff
path: root/sql/sql_const.h
diff options
context:
space:
mode:
authorVarun Gupta <varun.gupta@mariadb.com>2018-12-19 10:34:30 +0530
committerVarun Gupta <varun.gupta@mariadb.com>2018-12-19 10:38:46 +0530
commit7e606a2d5ca59dbd901b7c8909214a0fc12fbadd (patch)
treeb3c9ae6e97a542395f6e6f41fc3f465ca7786872 /sql/sql_const.h
parentda4efd56aa9bc3c39d94a73eb216ca7f559ce734 (diff)
downloadmariadb-git-7e606a2d5ca59dbd901b7c8909214a0fc12fbadd.tar.gz
MDEV-17589: Stack-buffer-overflow with indexed varchar (utf8) fieldbb-10.0-varun
Create a new constant MAX_DATA_LENGTH_FOR_KEY. Replace the value of MAX_KEY_LENGTH to also include the LENGTH and NULL BYTES of a field.
Diffstat (limited to 'sql/sql_const.h')
-rw-r--r--sql/sql_const.h12
1 files changed, 11 insertions, 1 deletions
diff --git a/sql/sql_const.h b/sql/sql_const.h
index c37d8dd68f7..c0b343c6ca4 100644
--- a/sql/sql_const.h
+++ b/sql/sql_const.h
@@ -33,7 +33,17 @@
#define MAX_SYS_VAR_LENGTH 32
#define MAX_KEY MAX_INDEXES /* Max used keys */
#define MAX_REF_PARTS 32 /* Max parts used as ref */
-#define MAX_KEY_LENGTH 3072 /* max possible key */
+
+/*
+ Maximum length of the data part of an index lookup key.
+
+ The "data part" is defined as the value itself, not including the
+ NULL-indicator bytes or varchar length bytes ("the Extras"). We need this
+ value because there was a bug where length of the Extras were not counted.
+
+ You probably need MAX_KEY_LENGTH, not this constant.
+*/
+#define MAX_DATA_LENGTH_FOR_KEY 3072
#if SIZEOF_OFF_T > 4
#define MAX_REFLENGTH 8 /* Max length for record ref */
#else