Check XML key file for valid base64 before using it.

QByteArray::fromBase64() doesn't validate the input.

Closes #366
This commit is contained in:
Felix Geyer 2015-11-01 18:30:50 +01:00
parent 820941fd40
commit 2fa531745f
6 changed files with 25 additions and 1 deletions

View file

@ -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);