mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-11-22 16:00:38 -05:00
Check XML key file for valid base64 before using it.
QByteArray::fromBase64() doesn't validate the input. Closes #366
This commit is contained in:
parent
820941fd40
commit
2fa531745f
6 changed files with 25 additions and 1 deletions
|
|
@ -160,6 +160,16 @@ bool isHex(const QByteArray& ba)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool isBase64(const QByteArray& ba)
|
||||
{
|
||||
QRegExp regexp("^(?:[a-z0-9+/]{4})*(?:[a-z0-9+/]{3}=|[a-z0-9+/]{2}==)?$",
|
||||
Qt::CaseInsensitive, QRegExp::RegExp2);
|
||||
|
||||
QString base64 = QString::fromLatin1(ba.constData(), ba.size());
|
||||
|
||||
return regexp.exactMatch(base64);
|
||||
}
|
||||
|
||||
void sleep(int ms)
|
||||
{
|
||||
Q_ASSERT(ms >= 0);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue