diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2022-10-25 14:25:42 +0300 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2022-10-25 14:25:42 +0300 |
commit | aeccbbd926e759a5c3b9818d9948a35918404478 (patch) | |
tree | e3ee68a92d2c77f986979e1638169280ede35a96 /plugin/file_key_management/parser.cc | |
parent | 75f7c5681c2592b50c26feff2371bd7ee973e535 (diff) | |
parent | 4b4c2b8cc0da949895292121ed5ef3e0c2dbaae1 (diff) | |
download | mariadb-git-aeccbbd926e759a5c3b9818d9948a35918404478.tar.gz |
Merge 10.5 into 10.6
To prevent ASAN heap-use-after-poison in the MDEV-16549 part of
./mtr --repeat=6 main.derived
the initialization of Name_resolution_context was cleaned up.
Diffstat (limited to 'plugin/file_key_management/parser.cc')
-rw-r--r-- | plugin/file_key_management/parser.cc | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/plugin/file_key_management/parser.cc b/plugin/file_key_management/parser.cc index 818c026495f..57e0139a57d 100644 --- a/plugin/file_key_management/parser.cc +++ b/plugin/file_key_management/parser.cc @@ -162,19 +162,28 @@ bool Parser::read_filekey(const char *filekey, char *secret) int f= open(filekey, O_RDONLY|O_BINARY); if (f == -1) { - my_error(EE_FILENOTFOUND,ME_ERROR_LOG, filekey, errno); + my_error(EE_FILENOTFOUND, ME_ERROR_LOG, filekey, errno); return 1; } - int len= read(f, secret, MAX_SECRET_SIZE); + int len= read(f, secret, MAX_SECRET_SIZE + 1); if (len <= 0) { - my_error(EE_READ,ME_ERROR_LOG, filekey, errno); + my_error(EE_READ, ME_ERROR_LOG, filekey, errno); close(f); return 1; } close(f); + while (secret[len - 1] == '\r' || secret[len - 1] == '\n') len--; + if (len > MAX_SECRET_SIZE) + { + my_printf_error(EE_READ, + "Cannot read %s, the filekey is too long, " + "max secret size is %dB ", + ME_ERROR_LOG, filekey, MAX_SECRET_SIZE); + return 1; + } secret[len]= '\0'; return 0; } |