mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-08-21 12:38:12 -04:00
Make C++11 mandatory.
This commit is contained in:
parent
0e85c98d02
commit
7fa0eddc5f
112 changed files with 332 additions and 411 deletions
|
@ -49,9 +49,9 @@ private:
|
|||
|
||||
|
||||
KeePass1Reader::KeePass1Reader()
|
||||
: m_db(Q_NULLPTR)
|
||||
, m_tmpParent(Q_NULLPTR)
|
||||
, m_device(Q_NULLPTR)
|
||||
: m_db(nullptr)
|
||||
, m_tmpParent(nullptr)
|
||||
, m_device(nullptr)
|
||||
, m_encryptionFlags(0)
|
||||
, m_transformRounds(0)
|
||||
, m_error(false)
|
||||
|
@ -72,16 +72,16 @@ Database* KeePass1Reader::readDatabase(QIODevice* device, const QString& passwor
|
|||
|
||||
if (keyfileData.isEmpty()) {
|
||||
raiseError(tr("Unable to read keyfile.").append("\n").append(keyfileDevice->errorString()));
|
||||
return Q_NULLPTR;
|
||||
return nullptr;
|
||||
}
|
||||
if (!keyfileDevice->seek(0)) {
|
||||
raiseError(tr("Unable to read keyfile.").append("\n").append(keyfileDevice->errorString()));
|
||||
return Q_NULLPTR;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!newFileKey.load(keyfileDevice)) {
|
||||
raiseError(tr("Unable to read keyfile.").append("\n").append(keyfileDevice->errorString()));
|
||||
return Q_NULLPTR;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -96,72 +96,72 @@ Database* KeePass1Reader::readDatabase(QIODevice* device, const QString& passwor
|
|||
quint32 signature1 = Endian::readUInt32(m_device, KeePass1::BYTEORDER, &ok);
|
||||
if (!ok || signature1 != KeePass1::SIGNATURE_1) {
|
||||
raiseError(tr("Not a KeePass database."));
|
||||
return Q_NULLPTR;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
quint32 signature2 = Endian::readUInt32(m_device, KeePass1::BYTEORDER, &ok);
|
||||
if (!ok || signature2 != KeePass1::SIGNATURE_2) {
|
||||
raiseError(tr("Not a KeePass database."));
|
||||
return Q_NULLPTR;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
m_encryptionFlags = Endian::readUInt32(m_device, KeePass1::BYTEORDER, &ok);
|
||||
if (!ok || !(m_encryptionFlags & KeePass1::Rijndael || m_encryptionFlags & KeePass1::Twofish)) {
|
||||
raiseError(tr("Unsupported encryption algorithm."));
|
||||
return Q_NULLPTR;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
quint32 version = Endian::readUInt32(m_device, KeePass1::BYTEORDER, &ok);
|
||||
if (!ok || (version & KeePass1::FILE_VERSION_CRITICAL_MASK)
|
||||
!= (KeePass1::FILE_VERSION & KeePass1::FILE_VERSION_CRITICAL_MASK)) {
|
||||
raiseError(tr("Unsupported KeePass database version."));
|
||||
return Q_NULLPTR;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
m_masterSeed = m_device->read(16);
|
||||
if (m_masterSeed.size() != 16) {
|
||||
raiseError("Unable to read master seed");
|
||||
return Q_NULLPTR;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
m_encryptionIV = m_device->read(16);
|
||||
if (m_encryptionIV.size() != 16) {
|
||||
raiseError("Unable to read encryption IV");
|
||||
return Q_NULLPTR;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
quint32 numGroups = Endian::readUInt32(m_device, KeePass1::BYTEORDER, &ok);
|
||||
if (!ok) {
|
||||
raiseError("Invalid number of groups");
|
||||
return Q_NULLPTR;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
quint32 numEntries = Endian::readUInt32(m_device, KeePass1::BYTEORDER, &ok);
|
||||
if (!ok) {
|
||||
raiseError("Invalid number of entries");
|
||||
return Q_NULLPTR;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
m_contentHashHeader = m_device->read(32);
|
||||
if (m_contentHashHeader.size() != 32) {
|
||||
raiseError("Invalid content hash size");
|
||||
return Q_NULLPTR;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
m_transformSeed = m_device->read(32);
|
||||
if (m_transformSeed.size() != 32) {
|
||||
raiseError("Invalid transform seed size");
|
||||
return Q_NULLPTR;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
m_transformRounds = Endian::readUInt32(m_device, KeePass1::BYTEORDER, &ok);
|
||||
if (!ok) {
|
||||
raiseError("Invalid number of transform rounds");
|
||||
return Q_NULLPTR;
|
||||
return nullptr;
|
||||
}
|
||||
if (!m_db->setTransformRounds(m_transformRounds)) {
|
||||
raiseError(tr("Unable to calculate master key"));
|
||||
return Q_NULLPTR;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
qint64 contentPos = m_device->pos();
|
||||
|
@ -169,14 +169,14 @@ Database* KeePass1Reader::readDatabase(QIODevice* device, const QString& passwor
|
|||
QScopedPointer<SymmetricCipherStream> cipherStream(testKeys(password, keyfileData, contentPos));
|
||||
|
||||
if (!cipherStream) {
|
||||
return Q_NULLPTR;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
QList<Group*> groups;
|
||||
for (quint32 i = 0; i < numGroups; i++) {
|
||||
Group* group = readGroup(cipherStream.data());
|
||||
if (!group) {
|
||||
return Q_NULLPTR;
|
||||
return nullptr;
|
||||
}
|
||||
groups.append(group);
|
||||
}
|
||||
|
@ -185,14 +185,14 @@ Database* KeePass1Reader::readDatabase(QIODevice* device, const QString& passwor
|
|||
for (quint32 i = 0; i < numEntries; i++) {
|
||||
Entry* entry = readEntry(cipherStream.data());
|
||||
if (!entry) {
|
||||
return Q_NULLPTR;
|
||||
return nullptr;
|
||||
}
|
||||
entries.append(entry);
|
||||
}
|
||||
|
||||
if (!constructGroupTree(groups)) {
|
||||
raiseError("Unable to construct group tree");
|
||||
return Q_NULLPTR;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Q_FOREACH (Entry* entry, entries) {
|
||||
|
@ -243,7 +243,7 @@ Database* KeePass1Reader::readDatabase(QIODevice* device, const QString& passwor
|
|||
|
||||
if (!db->setKey(key)) {
|
||||
raiseError(tr("Unable to calculate master key"));
|
||||
return Q_NULLPTR;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return db.take();
|
||||
|
@ -257,7 +257,7 @@ Database* KeePass1Reader::readDatabase(QIODevice* device, const QString& passwor
|
|||
keyFile.reset(new QFile(keyfileName));
|
||||
if (!keyFile->open(QFile::ReadOnly)) {
|
||||
raiseError(keyFile->errorString());
|
||||
return Q_NULLPTR;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -272,14 +272,14 @@ Database* KeePass1Reader::readDatabase(const QString& filename, const QString& p
|
|||
QFile dbFile(filename);
|
||||
if (!dbFile.open(QFile::ReadOnly)) {
|
||||
raiseError(dbFile.errorString());
|
||||
return Q_NULLPTR;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Database* db = readDatabase(&dbFile, password, keyfileName);
|
||||
|
||||
if (dbFile.error() != QFile::NoError) {
|
||||
raiseError(dbFile.errorString());
|
||||
return Q_NULLPTR;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return db;
|
||||
|
@ -337,7 +337,7 @@ SymmetricCipherStream* KeePass1Reader::testKeys(const QString& password, const Q
|
|||
|
||||
QByteArray finalKey = key(passwordData, keyfileData);
|
||||
if (finalKey.isEmpty()) {
|
||||
return Q_NULLPTR;
|
||||
return nullptr;
|
||||
}
|
||||
if (m_encryptionFlags & KeePass1::Rijndael) {
|
||||
cipherStream.reset(new SymmetricCipherStream(m_device, SymmetricCipher::Aes256,
|
||||
|
@ -350,11 +350,11 @@ SymmetricCipherStream* KeePass1Reader::testKeys(const QString& password, const Q
|
|||
|
||||
if (!cipherStream->init(finalKey, m_encryptionIV)) {
|
||||
raiseError(cipherStream->errorString());
|
||||
return Q_NULLPTR;
|
||||
return nullptr;
|
||||
}
|
||||
if (!cipherStream->open(QIODevice::ReadOnly)) {
|
||||
raiseError(cipherStream->errorString());
|
||||
return Q_NULLPTR;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool success = verifyKey(cipherStream.data());
|
||||
|
@ -368,7 +368,7 @@ SymmetricCipherStream* KeePass1Reader::testKeys(const QString& password, const Q
|
|||
}
|
||||
raiseError(msg);
|
||||
|
||||
return Q_NULLPTR;
|
||||
return nullptr;
|
||||
}
|
||||
cipherStream->open(QIODevice::ReadOnly);
|
||||
|
||||
|
@ -442,19 +442,19 @@ Group* KeePass1Reader::readGroup(QIODevice* cipherStream)
|
|||
quint16 fieldType = Endian::readUInt16(cipherStream, KeePass1::BYTEORDER, &ok);
|
||||
if (!ok) {
|
||||
raiseError("Invalid group field type number");
|
||||
return Q_NULLPTR;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int fieldSize = static_cast<int>(Endian::readUInt32(cipherStream, KeePass1::BYTEORDER, &ok));
|
||||
if (!ok) {
|
||||
raiseError("Invalid group field size");
|
||||
return Q_NULLPTR;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
QByteArray fieldData = cipherStream->read(fieldSize);
|
||||
if (fieldData.size() != fieldSize) {
|
||||
raiseError("Read group field data doesn't match size");
|
||||
return Q_NULLPTR;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
switch (fieldType) {
|
||||
|
@ -464,7 +464,7 @@ Group* KeePass1Reader::readGroup(QIODevice* cipherStream)
|
|||
case 0x0001:
|
||||
if (fieldSize != 4) {
|
||||
raiseError("Incorrect group id field size");
|
||||
return Q_NULLPTR;
|
||||
return nullptr;
|
||||
}
|
||||
groupId = Endian::bytesToUInt32(fieldData, KeePass1::BYTEORDER);
|
||||
groupIdSet = true;
|
||||
|
@ -476,7 +476,7 @@ Group* KeePass1Reader::readGroup(QIODevice* cipherStream)
|
|||
{
|
||||
if (fieldSize != 5) {
|
||||
raiseError("Incorrect group creation time field size");
|
||||
return Q_NULLPTR;
|
||||
return nullptr;
|
||||
}
|
||||
QDateTime dateTime = dateFromPackedStruct(fieldData);
|
||||
if (dateTime.isValid()) {
|
||||
|
@ -488,7 +488,7 @@ Group* KeePass1Reader::readGroup(QIODevice* cipherStream)
|
|||
{
|
||||
if (fieldSize != 5) {
|
||||
raiseError("Incorrect group modification time field size");
|
||||
return Q_NULLPTR;
|
||||
return nullptr;
|
||||
}
|
||||
QDateTime dateTime = dateFromPackedStruct(fieldData);
|
||||
if (dateTime.isValid()) {
|
||||
|
@ -523,7 +523,7 @@ Group* KeePass1Reader::readGroup(QIODevice* cipherStream)
|
|||
{
|
||||
if (fieldSize != 4) {
|
||||
raiseError("Incorrect group icon field size");
|
||||
return Q_NULLPTR;
|
||||
return nullptr;
|
||||
}
|
||||
quint32 iconNumber = Endian::bytesToUInt32(fieldData, KeePass1::BYTEORDER);
|
||||
group->setIcon(iconNumber);
|
||||
|
@ -533,7 +533,7 @@ Group* KeePass1Reader::readGroup(QIODevice* cipherStream)
|
|||
{
|
||||
if (fieldSize != 2) {
|
||||
raiseError("Incorrect group level field size");
|
||||
return Q_NULLPTR;
|
||||
return nullptr;
|
||||
}
|
||||
groupLevel = Endian::bytesToUInt16(fieldData, KeePass1::BYTEORDER);
|
||||
groupLevelSet = true;
|
||||
|
@ -548,13 +548,13 @@ Group* KeePass1Reader::readGroup(QIODevice* cipherStream)
|
|||
default:
|
||||
// invalid field
|
||||
raiseError("Invalid group field type");
|
||||
return Q_NULLPTR;
|
||||
return nullptr;
|
||||
}
|
||||
} while (!reachedEnd);
|
||||
|
||||
if (!groupIdSet || !groupLevelSet) {
|
||||
raiseError("Missing group id or level");
|
||||
return Q_NULLPTR;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
group->setUuid(Uuid::random());
|
||||
|
@ -580,19 +580,19 @@ Entry* KeePass1Reader::readEntry(QIODevice* cipherStream)
|
|||
quint16 fieldType = Endian::readUInt16(cipherStream, KeePass1::BYTEORDER, &ok);
|
||||
if (!ok) {
|
||||
raiseError("Missing entry field type number");
|
||||
return Q_NULLPTR;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int fieldSize = static_cast<int>(Endian::readUInt32(cipherStream, KeePass1::BYTEORDER, &ok));
|
||||
if (!ok) {
|
||||
raiseError("Invalid entry field size");
|
||||
return Q_NULLPTR;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
QByteArray fieldData = cipherStream->read(fieldSize);
|
||||
if (fieldData.size() != fieldSize) {
|
||||
raiseError("Read entry field data doesn't match size");
|
||||
return Q_NULLPTR;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
switch (fieldType) {
|
||||
|
@ -602,7 +602,7 @@ Entry* KeePass1Reader::readEntry(QIODevice* cipherStream)
|
|||
case 0x0001:
|
||||
if (fieldSize != 16) {
|
||||
raiseError("Invalid entry uuid field size");
|
||||
return Q_NULLPTR;
|
||||
return nullptr;
|
||||
}
|
||||
m_entryUuids.insert(fieldData, entry.data());
|
||||
break;
|
||||
|
@ -610,7 +610,7 @@ Entry* KeePass1Reader::readEntry(QIODevice* cipherStream)
|
|||
{
|
||||
if (fieldSize != 4) {
|
||||
raiseError("Invalid entry group id field size");
|
||||
return Q_NULLPTR;
|
||||
return nullptr;
|
||||
}
|
||||
quint32 groupId = Endian::bytesToUInt32(fieldData, KeePass1::BYTEORDER);
|
||||
m_entryGroupIds.insert(entry.data(), groupId);
|
||||
|
@ -620,7 +620,7 @@ Entry* KeePass1Reader::readEntry(QIODevice* cipherStream)
|
|||
{
|
||||
if (fieldSize != 4) {
|
||||
raiseError("Invalid entry icon field size");
|
||||
return Q_NULLPTR;
|
||||
return nullptr;
|
||||
}
|
||||
quint32 iconNumber = Endian::bytesToUInt32(fieldData, KeePass1::BYTEORDER);
|
||||
entry->setIcon(iconNumber);
|
||||
|
@ -645,7 +645,7 @@ Entry* KeePass1Reader::readEntry(QIODevice* cipherStream)
|
|||
{
|
||||
if (fieldSize != 5) {
|
||||
raiseError("Invalid entry creation time field size");
|
||||
return Q_NULLPTR;
|
||||
return nullptr;
|
||||
}
|
||||
QDateTime dateTime = dateFromPackedStruct(fieldData);
|
||||
if (dateTime.isValid()) {
|
||||
|
@ -657,7 +657,7 @@ Entry* KeePass1Reader::readEntry(QIODevice* cipherStream)
|
|||
{
|
||||
if (fieldSize != 5) {
|
||||
raiseError("Invalid entry modification time field size");
|
||||
return Q_NULLPTR;
|
||||
return nullptr;
|
||||
}
|
||||
QDateTime dateTime = dateFromPackedStruct(fieldData);
|
||||
if (dateTime.isValid()) {
|
||||
|
@ -669,7 +669,7 @@ Entry* KeePass1Reader::readEntry(QIODevice* cipherStream)
|
|||
{
|
||||
if (fieldSize != 5) {
|
||||
raiseError("Invalid entry creation time field size");
|
||||
return Q_NULLPTR;
|
||||
return nullptr;
|
||||
}
|
||||
QDateTime dateTime = dateFromPackedStruct(fieldData);
|
||||
if (dateTime.isValid()) {
|
||||
|
@ -681,7 +681,7 @@ Entry* KeePass1Reader::readEntry(QIODevice* cipherStream)
|
|||
{
|
||||
if (fieldSize != 5) {
|
||||
raiseError("Invalid entry expiry time field size");
|
||||
return Q_NULLPTR;
|
||||
return nullptr;
|
||||
}
|
||||
QDateTime dateTime = dateFromPackedStruct(fieldData);
|
||||
if (dateTime.isValid()) {
|
||||
|
@ -704,7 +704,7 @@ Entry* KeePass1Reader::readEntry(QIODevice* cipherStream)
|
|||
default:
|
||||
// invalid field
|
||||
raiseError("Invalid entry field type");
|
||||
return Q_NULLPTR;
|
||||
return nullptr;
|
||||
}
|
||||
} while (!reachedEnd);
|
||||
|
||||
|
|
|
@ -33,12 +33,12 @@
|
|||
#include "streams/SymmetricCipherStream.h"
|
||||
|
||||
KeePass2Reader::KeePass2Reader()
|
||||
: m_device(Q_NULLPTR)
|
||||
, m_headerStream(Q_NULLPTR)
|
||||
: m_device(nullptr)
|
||||
, m_headerStream(nullptr)
|
||||
, m_error(false)
|
||||
, m_headerEnd(false)
|
||||
, m_saveXml(false)
|
||||
, m_db(Q_NULLPTR)
|
||||
, m_db(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -66,13 +66,13 @@ Database* KeePass2Reader::readDatabase(QIODevice* device, const CompositeKey& ke
|
|||
quint32 signature1 = Endian::readUInt32(m_headerStream, KeePass2::BYTEORDER, &ok);
|
||||
if (!ok || signature1 != KeePass2::SIGNATURE_1) {
|
||||
raiseError(tr("Not a KeePass database."));
|
||||
return Q_NULLPTR;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
quint32 signature2 = Endian::readUInt32(m_headerStream, KeePass2::BYTEORDER, &ok);
|
||||
if (!ok || signature2 != KeePass2::SIGNATURE_2) {
|
||||
raiseError(tr("Not a KeePass database."));
|
||||
return Q_NULLPTR;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
quint32 version = Endian::readUInt32(m_headerStream, KeePass2::BYTEORDER, &ok)
|
||||
|
@ -80,7 +80,7 @@ Database* KeePass2Reader::readDatabase(QIODevice* device, const CompositeKey& ke
|
|||
quint32 maxVersion = KeePass2::FILE_VERSION & KeePass2::FILE_VERSION_CRITICAL_MASK;
|
||||
if (!ok || (version < KeePass2::FILE_VERSION_MIN) || (version > maxVersion)) {
|
||||
raiseError(tr("Unsupported KeePass database version."));
|
||||
return Q_NULLPTR;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
while (readHeaderField() && !hasError()) {
|
||||
|
@ -89,7 +89,7 @@ Database* KeePass2Reader::readDatabase(QIODevice* device, const CompositeKey& ke
|
|||
headerStream.close();
|
||||
|
||||
if (hasError()) {
|
||||
return Q_NULLPTR;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// check if all required headers were present
|
||||
|
@ -97,12 +97,12 @@ Database* KeePass2Reader::readDatabase(QIODevice* device, const CompositeKey& ke
|
|||
|| m_streamStartBytes.isEmpty() || m_protectedStreamKey.isEmpty()
|
||||
|| m_db->cipher().isNull()) {
|
||||
raiseError("missing database headers");
|
||||
return Q_NULLPTR;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!m_db->setKey(key, m_transformSeed, false)) {
|
||||
raiseError(tr("Unable to calculate master key"));
|
||||
return Q_NULLPTR;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
CryptoHash hash(CryptoHash::Sha256);
|
||||
|
@ -114,24 +114,24 @@ Database* KeePass2Reader::readDatabase(QIODevice* device, const CompositeKey& ke
|
|||
SymmetricCipher::Cbc, SymmetricCipher::Decrypt);
|
||||
if (!cipherStream.init(finalKey, m_encryptionIV)) {
|
||||
raiseError(cipherStream.errorString());
|
||||
return Q_NULLPTR;
|
||||
return nullptr;
|
||||
}
|
||||
if (!cipherStream.open(QIODevice::ReadOnly)) {
|
||||
raiseError(cipherStream.errorString());
|
||||
return Q_NULLPTR;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
QByteArray realStart = cipherStream.read(32);
|
||||
|
||||
if (realStart != m_streamStartBytes) {
|
||||
raiseError(tr("Wrong key or database file is corrupt."));
|
||||
return Q_NULLPTR;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
HashedBlockStream hashedStream(&cipherStream);
|
||||
if (!hashedStream.open(QIODevice::ReadOnly)) {
|
||||
raiseError(hashedStream.errorString());
|
||||
return Q_NULLPTR;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
QIODevice* xmlDevice;
|
||||
|
@ -145,7 +145,7 @@ Database* KeePass2Reader::readDatabase(QIODevice* device, const CompositeKey& ke
|
|||
ioCompressor->setStreamFormat(QtIOCompressor::GzipFormat);
|
||||
if (!ioCompressor->open(QIODevice::ReadOnly)) {
|
||||
raiseError(ioCompressor->errorString());
|
||||
return Q_NULLPTR;
|
||||
return nullptr;
|
||||
}
|
||||
xmlDevice = ioCompressor.data();
|
||||
}
|
||||
|
@ -153,7 +153,7 @@ Database* KeePass2Reader::readDatabase(QIODevice* device, const CompositeKey& ke
|
|||
KeePass2RandomStream randomStream;
|
||||
if (!randomStream.init(m_protectedStreamKey)) {
|
||||
raiseError(randomStream.errorString());
|
||||
return Q_NULLPTR;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
QScopedPointer<QBuffer> buffer;
|
||||
|
@ -170,7 +170,7 @@ Database* KeePass2Reader::readDatabase(QIODevice* device, const CompositeKey& ke
|
|||
|
||||
if (xmlReader.hasError()) {
|
||||
raiseError(xmlReader.errorString());
|
||||
return Q_NULLPTR;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Q_ASSERT(version < 0x00030001 || !xmlReader.headerHash().isEmpty());
|
||||
|
@ -179,7 +179,7 @@ Database* KeePass2Reader::readDatabase(QIODevice* device, const CompositeKey& ke
|
|||
QByteArray headerHash = CryptoHash::hash(headerStream.storedData(), CryptoHash::Sha256);
|
||||
if (headerHash != xmlReader.headerHash()) {
|
||||
raiseError("Head doesn't match hash");
|
||||
return Q_NULLPTR;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -191,14 +191,14 @@ Database* KeePass2Reader::readDatabase(const QString& filename, const CompositeK
|
|||
QFile file(filename);
|
||||
if (!file.open(QFile::ReadOnly)) {
|
||||
raiseError(file.errorString());
|
||||
return Q_NULLPTR;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
QScopedPointer<Database> db(readDatabase(&file, key));
|
||||
|
||||
if (file.error() != QFile::NoError) {
|
||||
raiseError(file.errorString());
|
||||
return Q_NULLPTR;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return db.take();
|
||||
|
|
|
@ -31,10 +31,10 @@
|
|||
typedef QPair<QString, QString> StringPair;
|
||||
|
||||
KeePass2XmlReader::KeePass2XmlReader()
|
||||
: m_randomStream(Q_NULLPTR)
|
||||
, m_db(Q_NULLPTR)
|
||||
, m_meta(Q_NULLPTR)
|
||||
, m_tmpParent(Q_NULLPTR)
|
||||
: m_randomStream(nullptr)
|
||||
, m_db(nullptr)
|
||||
, m_meta(nullptr)
|
||||
, m_tmpParent(nullptr)
|
||||
, m_error(false)
|
||||
, m_strictMode(false)
|
||||
{
|
||||
|
@ -1144,7 +1144,7 @@ QByteArray KeePass2XmlReader::readCompressedBinary()
|
|||
Group* KeePass2XmlReader::getGroup(const Uuid& uuid)
|
||||
{
|
||||
if (uuid.isNull()) {
|
||||
return Q_NULLPTR;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (m_groups.contains(uuid)) {
|
||||
|
@ -1163,7 +1163,7 @@ Group* KeePass2XmlReader::getGroup(const Uuid& uuid)
|
|||
Entry* KeePass2XmlReader::getEntry(const Uuid& uuid)
|
||||
{
|
||||
if (uuid.isNull()) {
|
||||
return Q_NULLPTR;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (m_entries.contains(uuid)) {
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
#include <QPair>
|
||||
#include <QXmlStreamReader>
|
||||
|
||||
#include "core/Global.h"
|
||||
#include "core/TimeInfo.h"
|
||||
#include "core/Uuid.h"
|
||||
|
||||
|
@ -42,7 +41,7 @@ class KeePass2XmlReader
|
|||
public:
|
||||
KeePass2XmlReader();
|
||||
Database* readDatabase(QIODevice* device);
|
||||
void readDatabase(QIODevice* device, Database* db, KeePass2RandomStream* randomStream = Q_NULLPTR);
|
||||
void readDatabase(QIODevice* device, Database* db, KeePass2RandomStream* randomStream = nullptr);
|
||||
Database* readDatabase(const QString& filename);
|
||||
bool hasError();
|
||||
QString errorString();
|
||||
|
|
|
@ -25,9 +25,9 @@
|
|||
#include "streams/QtIOCompressor"
|
||||
|
||||
KeePass2XmlWriter::KeePass2XmlWriter()
|
||||
: m_db(Q_NULLPTR)
|
||||
, m_meta(Q_NULLPTR)
|
||||
, m_randomStream(Q_NULLPTR)
|
||||
: m_db(nullptr)
|
||||
, m_meta(nullptr)
|
||||
, m_randomStream(nullptr)
|
||||
, m_error(false)
|
||||
{
|
||||
m_xml.setAutoFormatting(true);
|
||||
|
|
|
@ -36,7 +36,7 @@ class KeePass2XmlWriter
|
|||
{
|
||||
public:
|
||||
KeePass2XmlWriter();
|
||||
void writeDatabase(QIODevice* device, Database* db, KeePass2RandomStream* randomStream = Q_NULLPTR,
|
||||
void writeDatabase(QIODevice* device, Database* db, KeePass2RandomStream* randomStream = nullptr,
|
||||
const QByteArray& headerHash = QByteArray());
|
||||
void writeDatabase(const QString& filename, Database* db);
|
||||
bool hasError();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue