1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-01 03:47:19 +03:00

MDEV-25343 add read secret size in file key plugin

This commit is contained in:
kurt
2022-09-21 11:29:07 +08:00
committed by Daniel Black
parent 64d85c369b
commit cee7175b79
5 changed files with 33 additions and 1 deletions

View File

@ -174,13 +174,24 @@ bool Parser::read_filekey(const char *filekey, char *secret)
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);
close(f);
return 1;
}
if (len > MAX_SECRET_SIZE)
{
my_printf_error(EE_READ,
"Cannot decrypt %s, the secret file has incorrect length, "
"max secret size is %dB ",
ME_ERROR_LOG, filekey, MAX_SECRET_SIZE);
close(f);
return 1;
}
close(f);
while (secret[len - 1] == '\r' || secret[len - 1] == '\n') len--;
secret[len]= '\0';