Skip to content

Commit bdc5ecd

Browse files
author
Ole John Aske
committed
Bug#35155005 Buffers for holding a key of 'MAX_KEY_SIZE' are allocated too small
NdbIndexScanOperation::getDistKeyFromRange() allocated the tmp[] buffer as a working area for Ndb::computeHash() to xfrm the key into if need. The buffer was allocated with the correct size for transforming a key of NDB_MAX_KEY_SIZE, multiplied with the MAX_XFRM_MULTIPLY. However, the same buffer was also used in case a key column needed shrink_varchar()-reformat (and copy) of the key. Thus, possibly leaving a too small buffer remaining for the hash-xfrm of the key in ::computeHash() Patch divide the buffer usage into two seperate buffers: - Uint32 xfrmbuf[ MAX_KEY_SIZE_IN_WORDS * MAX_XFRM_MULTIPLY ] Used only as argument to ::computeHash() - Uint32 shrinkbuf[ MAX_KEY_SIZE_IN_WORDS ] Used in case we need to shrink_varchar()-copy the key. Change-Id: I9589269ce0e2dc084f262817f0708797032a9e84
1 parent 2118f5c commit bdc5ecd

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

storage/ndb/src/ndbapi/NdbScanOperation.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -766,11 +766,11 @@ NdbIndexScanOperation::getDistKeyFromRange(const NdbRecord *key_record,
766766
const char *row,
767767
Uint32* distKey)
768768
{
769-
const Uint32 MaxKeySizeInLongWords= (NDB_MAX_KEY_SIZE + 7) / 8;
770-
// Note: xfrm:ed key can/will be bigger than MaxKeySizeInLongWords
771-
Uint64 tmp[ MaxKeySizeInLongWords * MAX_XFRM_MULTIPLY ];
772-
char* tmpshrink = (char*)tmp;
773-
Uint32 tmplen = (Uint32)sizeof(tmp);
769+
// Note: xfrm:ed key can/will be bigger than MAX_KEY_SIZE_IN_WORDS
770+
Uint32 xfrmbuf[MAX_KEY_SIZE_IN_WORDS * MAX_XFRM_MULTIPLY];
771+
char shrinkbuf[NDB_MAX_KEY_SIZE];
772+
char* tmpshrink = shrinkbuf;
773+
Uint32 tmplen = (Uint32)sizeof(shrinkbuf);
774774

775775
/* This can't work for User Defined partitioning */
776776
assert(key_record->table->m_fragmentType !=
@@ -815,7 +815,7 @@ NdbIndexScanOperation::getDistKeyFromRange(const NdbRecord *key_record,
815815

816816
Uint32 hashValue;
817817
int ret = Ndb::computeHash(&hashValue, result_record->table,
818-
ptrs, tmpshrink, tmplen);
818+
ptrs, xfrmbuf, sizeof(xfrmbuf));
819819
if (ret == 0)
820820
{
821821
*distKey = hashValue;

0 commit comments

Comments
 (0)