diff options
author | Varun Gupta <varun.gupta@mariadb.com> | 2018-12-19 10:34:30 +0530 |
---|---|---|
committer | Varun Gupta <varun.gupta@mariadb.com> | 2018-12-19 10:38:46 +0530 |
commit | 7e606a2d5ca59dbd901b7c8909214a0fc12fbadd (patch) | |
tree | b3c9ae6e97a542395f6e6f41fc3f465ca7786872 /sql/handler.h | |
parent | da4efd56aa9bc3c39d94a73eb216ca7f559ce734 (diff) | |
download | mariadb-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/handler.h')
-rw-r--r-- | sql/handler.h | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/sql/handler.h b/sql/handler.h index 52396b84c0d..606adade679 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -384,6 +384,12 @@ enum enum_alter_inplace_result { #define HA_KEY_NULL_LENGTH 1 #define HA_KEY_BLOB_LENGTH 2 +/* Maximum length of any index lookup key, in bytes */ + +#define MAX_KEY_LENGTH (MAX_DATA_LENGTH_FOR_KEY \ + +(MAX_REF_PARTS \ + *(HA_KEY_NULL_LENGTH + HA_KEY_BLOB_LENGTH))) + #define HA_LEX_CREATE_TMP_TABLE 1 #define HA_LEX_CREATE_IF_NOT_EXISTS 2 #define HA_LEX_CREATE_TABLE_LIKE 4 @@ -3233,14 +3239,14 @@ public: uint max_key_parts() const { return MY_MIN(MAX_REF_PARTS, max_supported_key_parts()); } uint max_key_length() const - { return MY_MIN(MAX_KEY_LENGTH, max_supported_key_length()); } + { return MY_MIN(MAX_DATA_LENGTH_FOR_KEY, max_supported_key_length()); } uint max_key_part_length() const - { return MY_MIN(MAX_KEY_LENGTH, max_supported_key_part_length()); } + { return MY_MIN(MAX_DATA_LENGTH_FOR_KEY, max_supported_key_part_length()); } virtual uint max_supported_record_length() const { return HA_MAX_REC_LENGTH; } virtual uint max_supported_keys() const { return 0; } virtual uint max_supported_key_parts() const { return MAX_REF_PARTS; } - virtual uint max_supported_key_length() const { return MAX_KEY_LENGTH; } + virtual uint max_supported_key_length() const { return MAX_DATA_LENGTH_FOR_KEY; } virtual uint max_supported_key_part_length() const { return 255; } virtual uint min_record_length(uint options) const { return 1; } |