Skip to content

Commit bb72525

Browse files
Robert Golebiowskibjornmu
authored andcommitted
Bug #22540394: ASSERT FAILURE IN KEYRING_FILE.SO (MEMORY_SIZE %
SIZEOF(SIZE_T) == 0) (cherry picked from commit 5acbbaab4bf97841590a5d862b0bc6ebb9399387)
1 parent 1e6e199 commit bb72525

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

plugin/keyring/buffered_file_io.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ my_bool Buffered_file_io::load_keyring_into_input_buffer(File file)
106106
if (check_file_structure(file, file_size))
107107
return TRUE;
108108
size_t input_buffer_size= file_size - EOF_TAG_SIZE - file_version.length(); //result has to be positive
109+
if (input_buffer_size % sizeof(size_t) != 0)
110+
return TRUE; //buffer size in the keyring file must be multiplication of size_t
109111
mysql_file_seek(file, file_version.length(), MY_SEEK_SET, MYF(0)); //skip file version
110112
if (likely(input_buffer_size > 0))
111113
{

plugin/keyring/keyring_impl.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,21 +97,28 @@ int check_keyring_file_data(IKeyring_io* keyring_io, unique_ptr<IKeys_container>
9797

9898
(*(const char **) save)= NULL;
9999
keyring_filename= value->val_str(value, buff, &len);
100+
mysql_rwlock_wrlock(&LOCK_keyring);
100101
if (create_keyring_dir_if_does_not_exist(keyring_filename))
101102
{
103+
mysql_rwlock_unlock(&LOCK_keyring);
102104
logger->log(MY_ERROR_LEVEL, "keyring_file_data cannot be set to new value"
103105
" as the keyring file cannot be created/accessed in the provided path");
104106
return 1;
105107
}
106108
try
107109
{
108110
if (new_keys->init(keyring_io, keyring_filename))
111+
{
112+
mysql_rwlock_unlock(&LOCK_keyring);
109113
return 1;
114+
}
110115
*reinterpret_cast<IKeys_container **>(save)= new_keys.get();
111116
new_keys.release();
117+
mysql_rwlock_unlock(&LOCK_keyring);
112118
}
113119
catch (...)
114120
{
121+
mysql_rwlock_unlock(&LOCK_keyring);
115122
return 1;
116123
}
117124
return(0);

0 commit comments

Comments
 (0)