Skip to content

Commit 1eda52f

Browse files
author
Ole John Aske
committed
Bug#35155005 Buffers for holding a key of 'MAX_KEY_SIZE' are allocated too small
The #define MAX_KEY_SIZE_IN_WORDS 1023 are used multiple places where we need to define different kind of buffers for holding a tuple key. Some places we define this buffer as an array of Uint64's, probably due to a double word allignment were assumed to be more efficient when accessing the key buffer. As we right shifted-by-1 the MAX_KEY_SIZE_IN_WORDS when defining such Uint64 arrays, *without* adding +1 to compensate for the alignment truncation, the allocated Uint64 buffer ended up being a 'word' too small to buffer a full MAX_KEY. These Uint64 buffers where used for storing a key to calculate a hash key - md5_hash() used to take a Uint64* aligned argument for the value to be hashed. This was changed by patch for Bug#35180841 Remove requirement for md5_hash() input to be 8-byte aligned Thus we can now define these buffers as Uint32[] instead. Patch change these buffer definitions accordingly. Change-Id: If5356bae4a3e997fdb09caa89fd3c3626b782d56
1 parent 1a23610 commit 1eda52f

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

sql/ha_ndbcluster.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8954,7 +8954,7 @@ ha_ndbcluster::start_transaction_row(const NdbRecord *ndb_record,
89548954

89558955
Ndb *ndb= m_thd_ndb->ndb;
89568956

8957-
Uint64 tmp[(MAX_KEY_SIZE_IN_WORDS*MAX_XFRM_MULTIPLY) >> 1];
8957+
Uint32 tmp[MAX_KEY_SIZE_IN_WORDS*MAX_XFRM_MULTIPLY];
89588958
char *buf= (char*)&tmp[0];
89598959
trans= ndb->startTransaction(ndb_record,
89608960
(const char*)record,
@@ -8986,7 +8986,7 @@ ha_ndbcluster::start_transaction_key(uint inx_no,
89868986
Ndb *ndb= m_thd_ndb->ndb;
89878987
const NdbRecord *key_rec= m_index[inx_no].ndb_unique_record_key;
89888988

8989-
Uint64 tmp[(MAX_KEY_SIZE_IN_WORDS*MAX_XFRM_MULTIPLY) >> 1];
8989+
Uint32 tmp[MAX_KEY_SIZE_IN_WORDS*MAX_XFRM_MULTIPLY];
89908990
char *buf= (char*)&tmp[0];
89918991
trans= ndb->startTransaction(key_rec,
89928992
(const char*)key_data,
@@ -17783,7 +17783,7 @@ uint32 ha_ndbcluster::calculate_key_hash_value(Field **field_array)
1778317783
struct Ndb::Key_part_ptr *key_data_ptr= &key_data[0];
1778417784
Uint32 i= 0;
1778517785
int ret_val;
17786-
Uint64 tmp[(MAX_KEY_SIZE_IN_WORDS*MAX_XFRM_MULTIPLY) >> 1];
17786+
Uint32 tmp[MAX_KEY_SIZE_IN_WORDS*MAX_XFRM_MULTIPLY];
1778717787
void *buf= (void*)&tmp[0];
1778817788
DBUG_ENTER("ha_ndbcluster::calculate_key_hash_value");
1778917789

storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6049,28 +6049,28 @@ Dblqh::handle_nr_copy(Signal* signal, Ptr<TcConnectionrec> regTcPtr)
60496049
if (len > 0 && !match &&
60506050
g_key_descriptor_pool.getPtr(tableId)->hasCharAttr)
60516051
{
6052-
Uint64 reqKey[ MAX_KEY_SIZE_IN_WORDS >> 1 ];
6053-
Uint64 dbXfrmKey[ (MAX_KEY_SIZE_IN_WORDS*MAX_XFRM_MULTIPLY) >> 1 ];
6054-
Uint64 reqXfrmKey[ (MAX_KEY_SIZE_IN_WORDS*MAX_XFRM_MULTIPLY) >> 1 ];
6052+
Uint32 reqKey[MAX_KEY_SIZE_IN_WORDS];
6053+
Uint32 dbXfrmKey[MAX_KEY_SIZE_IN_WORDS*MAX_XFRM_MULTIPLY];
6054+
Uint32 reqXfrmKey[MAX_KEY_SIZE_IN_WORDS*MAX_XFRM_MULTIPLY];
60556055
Uint32 keyPartLen[MAX_ATTRIBUTES_IN_INDEX];
60566056

60576057
jam();
60586058

60596059
/* Transform db table key read from DB above into dbXfrmKey */
60606060
const int dbXfrmKeyLen = xfrm_key(tableId,
60616061
&signal->theData[24],
6062-
(Uint32*)dbXfrmKey,
6062+
dbXfrmKey,
60636063
sizeof(dbXfrmKey) >> 2,
60646064
keyPartLen);
60656065
ndbassert(dbXfrmKeyLen > 0);
60666066

60676067
/* Copy request key into linear space */
6068-
copy((Uint32*) reqKey, regTcPtr.p->keyInfoIVal);
6068+
copy(reqKey, regTcPtr.p->keyInfoIVal);
60696069

60706070
/* Transform request key */
60716071
const int reqXfrmKeyLen = xfrm_key(tableId,
6072-
(Uint32*)reqKey,
6073-
(Uint32*)reqXfrmKey,
6072+
reqKey,
6073+
reqXfrmKey,
60746074
sizeof(reqXfrmKey) >> 2,
60756075
keyPartLen);
60766076
ndbassert(reqXfrmKeyLen > 0);
@@ -6410,7 +6410,7 @@ Uint32
64106410
Dblqh::readPrimaryKeys(Uint32 opPtrI, Uint32 * dst, bool xfrm)
64116411
{
64126412
TcConnectionrecPtr regTcPtr;
6413-
Uint64 Tmp[MAX_KEY_SIZE_IN_WORDS >> 1];
6413+
Uint32 Tmp[MAX_KEY_SIZE_IN_WORDS];
64146414

64156415
jamEntry();
64166416
regTcPtr.i = opPtrI;

0 commit comments

Comments
 (0)