mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-04-04 21:17:43 +03:00
Improve KDBX error messages
This commit is contained in:
parent
17aefc3cf7
commit
1ca358f3fd
2 changed files with 16 additions and 7 deletions
|
@ -43,7 +43,7 @@ bool Kdbx3Reader::readDatabaseImpl(QIODevice* device,
|
|||
// check if all required headers were present
|
||||
if (m_masterSeed.isEmpty() || m_encryptionIV.isEmpty() || m_streamStartBytes.isEmpty()
|
||||
|| m_protectedStreamKey.isEmpty() || db->cipher().isNull()) {
|
||||
raiseError(tr("missing database headers"));
|
||||
raiseError(tr("Missing database headers"));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -147,7 +147,7 @@ bool Kdbx3Reader::readHeaderField(StoreDataStream& headerStream, Database* db)
|
|||
bool ok;
|
||||
auto fieldLen = Endian::readSizedInt<quint16>(&headerStream, KeePass2::BYTEORDER, &ok);
|
||||
if (!ok) {
|
||||
raiseError(tr("Invalid header field length"));
|
||||
raiseError(tr("Invalid header field length: field %1").arg(fieldID));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -155,7 +155,10 @@ bool Kdbx3Reader::readHeaderField(StoreDataStream& headerStream, Database* db)
|
|||
if (fieldLen != 0) {
|
||||
fieldData = headerStream.read(fieldLen);
|
||||
if (fieldData.size() != fieldLen) {
|
||||
raiseError(tr("Invalid header data length"));
|
||||
raiseError(tr("Invalid header data length: field %1, %2 expected, %3 found")
|
||||
.arg(fieldID)
|
||||
.arg(fieldLen)
|
||||
.arg(fieldData.size()));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -166,7 +166,7 @@ bool Kdbx4Reader::readHeaderField(StoreDataStream& device, Database* db)
|
|||
bool ok;
|
||||
auto fieldLen = Endian::readSizedInt<quint32>(&device, KeePass2::BYTEORDER, &ok);
|
||||
if (!ok) {
|
||||
raiseError(tr("Invalid header field length"));
|
||||
raiseError(tr("Invalid header field length: field %1").arg(fieldID));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -174,7 +174,10 @@ bool Kdbx4Reader::readHeaderField(StoreDataStream& device, Database* db)
|
|||
if (fieldLen != 0) {
|
||||
fieldData = device.read(fieldLen);
|
||||
if (static_cast<quint32>(fieldData.size()) != fieldLen) {
|
||||
raiseError(tr("Invalid header data length"));
|
||||
raiseError(tr("Invalid header data length: field %1, %2 expected, %3 found")
|
||||
.arg(static_cast<int>(fieldID))
|
||||
.arg(fieldLen)
|
||||
.arg(fieldData.size()));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -258,7 +261,7 @@ bool Kdbx4Reader::readInnerHeaderField(QIODevice* device)
|
|||
bool ok;
|
||||
auto fieldLen = Endian::readSizedInt<quint32>(device, KeePass2::BYTEORDER, &ok);
|
||||
if (!ok) {
|
||||
raiseError(tr("Invalid inner header field length"));
|
||||
raiseError(tr("Invalid inner header field length: field %1").arg(static_cast<int>(fieldID)));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -266,7 +269,10 @@ bool Kdbx4Reader::readInnerHeaderField(QIODevice* device)
|
|||
if (fieldLen != 0) {
|
||||
fieldData = device->read(fieldLen);
|
||||
if (static_cast<quint32>(fieldData.size()) != fieldLen) {
|
||||
raiseError(tr("Invalid header data length"));
|
||||
raiseError(tr("Invalid inner header data length: field %1, %2 expected, %3 found")
|
||||
.arg(static_cast<int>(fieldID))
|
||||
.arg(fieldLen)
|
||||
.arg(fieldData.size()));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue