mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-12-28 08:49:42 -05:00
Return Q_NULLPTR instead of 0 when the return type is a pointer.
This commit is contained in:
parent
fcc936ceff
commit
ecea101962
@ -104,7 +104,7 @@ Entry* Database::recFindEntry(const Uuid& uuid, Group* group)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return Q_NULLPTR;
|
||||||
}
|
}
|
||||||
|
|
||||||
Group* Database::resolveGroup(const Uuid& uuid)
|
Group* Database::resolveGroup(const Uuid& uuid)
|
||||||
@ -125,7 +125,7 @@ Group* Database::recFindGroup(const Uuid& uuid, Group* group)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return Q_NULLPTR;
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<DeletedObject> Database::deletedObjects()
|
QList<DeletedObject> Database::deletedObjects()
|
||||||
|
@ -589,7 +589,7 @@ const Database* Entry::database() const
|
|||||||
return m_group->database();
|
return m_group->database();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return 0;
|
return Q_NULLPTR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ SymmetricCipherBackend* SymmetricCipher::createBackend(SymmetricCipher::Algorith
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
Q_ASSERT(false);
|
Q_ASSERT(false);
|
||||||
return 0;
|
return Q_NULLPTR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#include <QtCore/QByteArray>
|
#include <QtCore/QByteArray>
|
||||||
#include <QtCore/QScopedPointer>
|
#include <QtCore/QScopedPointer>
|
||||||
|
|
||||||
|
#include "core/Global.h"
|
||||||
#include "crypto/SymmetricCipherBackend.h"
|
#include "crypto/SymmetricCipherBackend.h"
|
||||||
|
|
||||||
class SymmetricCipher
|
class SymmetricCipher
|
||||||
|
@ -63,14 +63,14 @@ Database* KeePass1Reader::readDatabase(QIODevice* device, const QString& passwor
|
|||||||
keyfileData = readKeyfile(keyfileDevice);
|
keyfileData = readKeyfile(keyfileDevice);
|
||||||
|
|
||||||
if (keyfileData.isEmpty()) {
|
if (keyfileData.isEmpty()) {
|
||||||
return 0;
|
return Q_NULLPTR;
|
||||||
}
|
}
|
||||||
if (!keyfileDevice->seek(0)) {
|
if (!keyfileDevice->seek(0)) {
|
||||||
return 0;
|
return Q_NULLPTR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!newFileKey.load(keyfileDevice)) {
|
if (!newFileKey.load(keyfileDevice)) {
|
||||||
return 0;
|
return Q_NULLPTR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,68 +87,68 @@ Database* KeePass1Reader::readDatabase(QIODevice* device, const QString& passwor
|
|||||||
quint32 signature1 = Endian::readUInt32(m_device, KeePass1::BYTEORDER, &ok);
|
quint32 signature1 = Endian::readUInt32(m_device, KeePass1::BYTEORDER, &ok);
|
||||||
if (!ok || signature1 != 0x9AA2D903) {
|
if (!ok || signature1 != 0x9AA2D903) {
|
||||||
raiseError(tr("Not a KeePass database."));
|
raiseError(tr("Not a KeePass database."));
|
||||||
return 0;
|
return Q_NULLPTR;
|
||||||
}
|
}
|
||||||
|
|
||||||
quint32 signature2 = Endian::readUInt32(m_device, KeePass1::BYTEORDER, &ok);
|
quint32 signature2 = Endian::readUInt32(m_device, KeePass1::BYTEORDER, &ok);
|
||||||
if (!ok || signature2 != 0xB54BFB65) {
|
if (!ok || signature2 != 0xB54BFB65) {
|
||||||
raiseError(tr("Not a KeePass database."));
|
raiseError(tr("Not a KeePass database."));
|
||||||
return 0;
|
return Q_NULLPTR;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_encryptionFlags = Endian::readUInt32(m_device, KeePass1::BYTEORDER, &ok);
|
m_encryptionFlags = Endian::readUInt32(m_device, KeePass1::BYTEORDER, &ok);
|
||||||
if (!ok || !(m_encryptionFlags & KeePass1::Rijndael || m_encryptionFlags & KeePass1::Twofish)) {
|
if (!ok || !(m_encryptionFlags & KeePass1::Rijndael || m_encryptionFlags & KeePass1::Twofish)) {
|
||||||
raiseError(tr("Unsupported encryption algorithm."));
|
raiseError(tr("Unsupported encryption algorithm."));
|
||||||
return 0;
|
return Q_NULLPTR;
|
||||||
}
|
}
|
||||||
|
|
||||||
quint32 version = Endian::readUInt32(m_device, KeePass1::BYTEORDER, &ok);
|
quint32 version = Endian::readUInt32(m_device, KeePass1::BYTEORDER, &ok);
|
||||||
if (!ok || (version & KeePass1::FILE_VERSION_CRITICAL_MASK)
|
if (!ok || (version & KeePass1::FILE_VERSION_CRITICAL_MASK)
|
||||||
!= (KeePass1::FILE_VERSION & KeePass1::FILE_VERSION_CRITICAL_MASK)) {
|
!= (KeePass1::FILE_VERSION & KeePass1::FILE_VERSION_CRITICAL_MASK)) {
|
||||||
raiseError(tr("Unsupported KeePass database version."));
|
raiseError(tr("Unsupported KeePass database version."));
|
||||||
return 0;
|
return Q_NULLPTR;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_masterSeed = m_device->read(16);
|
m_masterSeed = m_device->read(16);
|
||||||
if (m_masterSeed.size() != 16) {
|
if (m_masterSeed.size() != 16) {
|
||||||
// TODO: error
|
// TODO: error
|
||||||
return 0;
|
return Q_NULLPTR;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_encryptionIV = m_device->read(16);
|
m_encryptionIV = m_device->read(16);
|
||||||
if (m_encryptionIV.size() != 16) {
|
if (m_encryptionIV.size() != 16) {
|
||||||
// TODO: error
|
// TODO: error
|
||||||
return 0;
|
return Q_NULLPTR;
|
||||||
}
|
}
|
||||||
|
|
||||||
quint32 numGroups = Endian::readUInt32(m_device, KeePass1::BYTEORDER, &ok);
|
quint32 numGroups = Endian::readUInt32(m_device, KeePass1::BYTEORDER, &ok);
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
// TODO: error
|
// TODO: error
|
||||||
return 0;
|
return Q_NULLPTR;
|
||||||
}
|
}
|
||||||
|
|
||||||
quint32 numEntries = Endian::readUInt32(m_device, KeePass1::BYTEORDER, &ok);
|
quint32 numEntries = Endian::readUInt32(m_device, KeePass1::BYTEORDER, &ok);
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
// TODO: error
|
// TODO: error
|
||||||
return 0;
|
return Q_NULLPTR;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_contentHashHeader = m_device->read(32);
|
m_contentHashHeader = m_device->read(32);
|
||||||
if (m_contentHashHeader.size() != 32) {
|
if (m_contentHashHeader.size() != 32) {
|
||||||
// TODO: error
|
// TODO: error
|
||||||
return 0;
|
return Q_NULLPTR;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_transformSeed = m_device->read(32);
|
m_transformSeed = m_device->read(32);
|
||||||
if (m_transformSeed.size() != 32) {
|
if (m_transformSeed.size() != 32) {
|
||||||
// TODO: error
|
// TODO: error
|
||||||
return 0;
|
return Q_NULLPTR;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_transformRounds = Endian::readUInt32(m_device, KeePass1::BYTEORDER, &ok);
|
m_transformRounds = Endian::readUInt32(m_device, KeePass1::BYTEORDER, &ok);
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
// TODO: error
|
// TODO: error
|
||||||
return 0;
|
return Q_NULLPTR;
|
||||||
}
|
}
|
||||||
m_db->setTransformRounds(m_transformRounds);
|
m_db->setTransformRounds(m_transformRounds);
|
||||||
|
|
||||||
@ -158,14 +158,14 @@ Database* KeePass1Reader::readDatabase(QIODevice* device, const QString& passwor
|
|||||||
|
|
||||||
if (!cipherStream) {
|
if (!cipherStream) {
|
||||||
// TODO: error
|
// TODO: error
|
||||||
return 0;
|
return Q_NULLPTR;
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<Group*> groups;
|
QList<Group*> groups;
|
||||||
for (quint32 i = 0; i < numGroups; i++) {
|
for (quint32 i = 0; i < numGroups; i++) {
|
||||||
Group* group = readGroup(cipherStream.data());
|
Group* group = readGroup(cipherStream.data());
|
||||||
if (!group) {
|
if (!group) {
|
||||||
return 0;
|
return Q_NULLPTR;
|
||||||
}
|
}
|
||||||
groups.append(group);
|
groups.append(group);
|
||||||
}
|
}
|
||||||
@ -174,13 +174,13 @@ Database* KeePass1Reader::readDatabase(QIODevice* device, const QString& passwor
|
|||||||
for (quint32 i = 0; i < numEntries; i++) {
|
for (quint32 i = 0; i < numEntries; i++) {
|
||||||
Entry* entry = readEntry(cipherStream.data());
|
Entry* entry = readEntry(cipherStream.data());
|
||||||
if (!entry) {
|
if (!entry) {
|
||||||
return 0;
|
return Q_NULLPTR;
|
||||||
}
|
}
|
||||||
entries.append(entry);
|
entries.append(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!constructGroupTree(groups)) {
|
if (!constructGroupTree(groups)) {
|
||||||
return 0;
|
return Q_NULLPTR;
|
||||||
}
|
}
|
||||||
|
|
||||||
Q_FOREACH (Entry* entry, entries) {
|
Q_FOREACH (Entry* entry, entries) {
|
||||||
@ -192,7 +192,7 @@ Database* KeePass1Reader::readDatabase(QIODevice* device, const QString& passwor
|
|||||||
else {
|
else {
|
||||||
quint32 groupId = m_entryGroupIds.value(entry);
|
quint32 groupId = m_entryGroupIds.value(entry);
|
||||||
if (!m_groupIds.contains(groupId)) {
|
if (!m_groupIds.contains(groupId)) {
|
||||||
return 0;
|
return Q_NULLPTR;
|
||||||
}
|
}
|
||||||
entry->setGroup(m_groupIds.value(groupId));
|
entry->setGroup(m_groupIds.value(groupId));
|
||||||
entry->setUuid(Uuid::random());
|
entry->setUuid(Uuid::random());
|
||||||
@ -244,7 +244,7 @@ Database* KeePass1Reader::readDatabase(QIODevice* device, const QString& passwor
|
|||||||
keyFile.reset(new QFile(keyfileName));
|
keyFile.reset(new QFile(keyfileName));
|
||||||
if (!keyFile->open(QFile::ReadOnly)) {
|
if (!keyFile->open(QFile::ReadOnly)) {
|
||||||
raiseError(keyFile->errorString());
|
raiseError(keyFile->errorString());
|
||||||
return 0;
|
return Q_NULLPTR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -259,14 +259,14 @@ Database* KeePass1Reader::readDatabase(const QString& filename, const QString& p
|
|||||||
QFile dbFile(filename);
|
QFile dbFile(filename);
|
||||||
if (!dbFile.open(QFile::ReadOnly)) {
|
if (!dbFile.open(QFile::ReadOnly)) {
|
||||||
raiseError(dbFile.errorString());
|
raiseError(dbFile.errorString());
|
||||||
return 0;
|
return Q_NULLPTR;
|
||||||
}
|
}
|
||||||
|
|
||||||
Database* db = readDatabase(&dbFile, password, keyfileName);
|
Database* db = readDatabase(&dbFile, password, keyfileName);
|
||||||
|
|
||||||
if (dbFile.error() != QFile::NoError) {
|
if (dbFile.error() != QFile::NoError) {
|
||||||
raiseError(dbFile.errorString());
|
raiseError(dbFile.errorString());
|
||||||
return 0;
|
return Q_NULLPTR;
|
||||||
}
|
}
|
||||||
|
|
||||||
return db;
|
return db;
|
||||||
@ -340,7 +340,7 @@ SymmetricCipherStream* KeePass1Reader::testKeys(const QString& password, const Q
|
|||||||
cipherStream->close();
|
cipherStream->close();
|
||||||
if (!m_device->seek(contentPos)) {
|
if (!m_device->seek(contentPos)) {
|
||||||
// TODO: error
|
// TODO: error
|
||||||
return 0;
|
return Q_NULLPTR;
|
||||||
}
|
}
|
||||||
cipherStream->open(QIODevice::ReadOnly);
|
cipherStream->open(QIODevice::ReadOnly);
|
||||||
|
|
||||||
@ -398,18 +398,18 @@ Group* KeePass1Reader::readGroup(QIODevice* cipherStream)
|
|||||||
do {
|
do {
|
||||||
quint16 fieldType = Endian::readUInt16(cipherStream, KeePass1::BYTEORDER, &ok);
|
quint16 fieldType = Endian::readUInt16(cipherStream, KeePass1::BYTEORDER, &ok);
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
return 0;
|
return Q_NULLPTR;
|
||||||
}
|
}
|
||||||
|
|
||||||
int fieldSize = static_cast<int>(Endian::readUInt32(cipherStream, KeePass1::BYTEORDER, &ok));
|
int fieldSize = static_cast<int>(Endian::readUInt32(cipherStream, KeePass1::BYTEORDER, &ok));
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
return 0;
|
return Q_NULLPTR;
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray fieldData = cipherStream->read(fieldSize);
|
QByteArray fieldData = cipherStream->read(fieldSize);
|
||||||
if (fieldData.size() != fieldSize) {
|
if (fieldData.size() != fieldSize) {
|
||||||
// TODO: error
|
// TODO: error
|
||||||
return 0;
|
return Q_NULLPTR;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (fieldType) {
|
switch (fieldType) {
|
||||||
@ -418,7 +418,7 @@ Group* KeePass1Reader::readGroup(QIODevice* cipherStream)
|
|||||||
break;
|
break;
|
||||||
case 0x0001:
|
case 0x0001:
|
||||||
if (fieldSize != 4) {
|
if (fieldSize != 4) {
|
||||||
return 0;
|
return Q_NULLPTR;
|
||||||
}
|
}
|
||||||
groupId = Endian::bytesToUInt32(fieldData, KeePass1::BYTEORDER);
|
groupId = Endian::bytesToUInt32(fieldData, KeePass1::BYTEORDER);
|
||||||
break;
|
break;
|
||||||
@ -428,7 +428,7 @@ Group* KeePass1Reader::readGroup(QIODevice* cipherStream)
|
|||||||
case 0x0003:
|
case 0x0003:
|
||||||
{
|
{
|
||||||
if (fieldSize != 5) {
|
if (fieldSize != 5) {
|
||||||
return 0;
|
return Q_NULLPTR;
|
||||||
}
|
}
|
||||||
QDateTime dateTime = dateFromPackedStruct(fieldData);
|
QDateTime dateTime = dateFromPackedStruct(fieldData);
|
||||||
if (dateTime.isValid()) {
|
if (dateTime.isValid()) {
|
||||||
@ -439,7 +439,7 @@ Group* KeePass1Reader::readGroup(QIODevice* cipherStream)
|
|||||||
case 0x0004:
|
case 0x0004:
|
||||||
{
|
{
|
||||||
if (fieldSize != 5) {
|
if (fieldSize != 5) {
|
||||||
return 0;
|
return Q_NULLPTR;
|
||||||
}
|
}
|
||||||
QDateTime dateTime = dateFromPackedStruct(fieldData);
|
QDateTime dateTime = dateFromPackedStruct(fieldData);
|
||||||
if (dateTime.isValid()) {
|
if (dateTime.isValid()) {
|
||||||
@ -450,7 +450,7 @@ Group* KeePass1Reader::readGroup(QIODevice* cipherStream)
|
|||||||
case 0x0005:
|
case 0x0005:
|
||||||
{
|
{
|
||||||
if (fieldSize != 5) {
|
if (fieldSize != 5) {
|
||||||
return 0;
|
return Q_NULLPTR;
|
||||||
}
|
}
|
||||||
QDateTime dateTime = dateFromPackedStruct(fieldData);
|
QDateTime dateTime = dateFromPackedStruct(fieldData);
|
||||||
if (dateTime.isValid()) {
|
if (dateTime.isValid()) {
|
||||||
@ -461,7 +461,7 @@ Group* KeePass1Reader::readGroup(QIODevice* cipherStream)
|
|||||||
case 0x0006:
|
case 0x0006:
|
||||||
{
|
{
|
||||||
if (fieldSize != 5) {
|
if (fieldSize != 5) {
|
||||||
return 0;
|
return Q_NULLPTR;
|
||||||
}
|
}
|
||||||
QDateTime dateTime = dateFromPackedStruct(fieldData);
|
QDateTime dateTime = dateFromPackedStruct(fieldData);
|
||||||
if (dateTime.isValid()) {
|
if (dateTime.isValid()) {
|
||||||
@ -473,7 +473,7 @@ Group* KeePass1Reader::readGroup(QIODevice* cipherStream)
|
|||||||
case 0x0007:
|
case 0x0007:
|
||||||
{
|
{
|
||||||
if (fieldSize != 4) {
|
if (fieldSize != 4) {
|
||||||
return 0;
|
return Q_NULLPTR;
|
||||||
}
|
}
|
||||||
quint32 iconNumber = Endian::bytesToUInt32(fieldData, KeePass1::BYTEORDER);
|
quint32 iconNumber = Endian::bytesToUInt32(fieldData, KeePass1::BYTEORDER);
|
||||||
group->setIcon(iconNumber);
|
group->setIcon(iconNumber);
|
||||||
@ -482,7 +482,7 @@ Group* KeePass1Reader::readGroup(QIODevice* cipherStream)
|
|||||||
case 0x0008:
|
case 0x0008:
|
||||||
{
|
{
|
||||||
if (fieldSize != 2) {
|
if (fieldSize != 2) {
|
||||||
return 0;
|
return Q_NULLPTR;
|
||||||
}
|
}
|
||||||
groupLevel = Endian::bytesToUInt16(fieldData, KeePass1::BYTEORDER);
|
groupLevel = Endian::bytesToUInt16(fieldData, KeePass1::BYTEORDER);
|
||||||
break;
|
break;
|
||||||
@ -495,7 +495,7 @@ Group* KeePass1Reader::readGroup(QIODevice* cipherStream)
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// invalid field
|
// invalid field
|
||||||
return 0;
|
return Q_NULLPTR;
|
||||||
}
|
}
|
||||||
} while (!reachedEnd);
|
} while (!reachedEnd);
|
||||||
|
|
||||||
@ -521,18 +521,18 @@ Entry* KeePass1Reader::readEntry(QIODevice* cipherStream)
|
|||||||
do {
|
do {
|
||||||
quint16 fieldType = Endian::readUInt16(cipherStream, KeePass1::BYTEORDER, &ok);
|
quint16 fieldType = Endian::readUInt16(cipherStream, KeePass1::BYTEORDER, &ok);
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
return 0;
|
return Q_NULLPTR;
|
||||||
}
|
}
|
||||||
|
|
||||||
int fieldSize = static_cast<int>(Endian::readUInt32(cipherStream, KeePass1::BYTEORDER, &ok));
|
int fieldSize = static_cast<int>(Endian::readUInt32(cipherStream, KeePass1::BYTEORDER, &ok));
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
return 0;
|
return Q_NULLPTR;
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray fieldData = cipherStream->read(fieldSize);
|
QByteArray fieldData = cipherStream->read(fieldSize);
|
||||||
if (fieldData.size() != fieldSize) {
|
if (fieldData.size() != fieldSize) {
|
||||||
// TODO: error
|
// TODO: error
|
||||||
return 0;
|
return Q_NULLPTR;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (fieldType) {
|
switch (fieldType) {
|
||||||
@ -541,14 +541,14 @@ Entry* KeePass1Reader::readEntry(QIODevice* cipherStream)
|
|||||||
break;
|
break;
|
||||||
case 0x0001:
|
case 0x0001:
|
||||||
if (fieldSize != 16) {
|
if (fieldSize != 16) {
|
||||||
return 0;
|
return Q_NULLPTR;
|
||||||
}
|
}
|
||||||
m_entryUuids.insert(fieldData, entry.data());
|
m_entryUuids.insert(fieldData, entry.data());
|
||||||
break;
|
break;
|
||||||
case 0x0002:
|
case 0x0002:
|
||||||
{
|
{
|
||||||
if (fieldSize != 4) {
|
if (fieldSize != 4) {
|
||||||
return 0;
|
return Q_NULLPTR;
|
||||||
}
|
}
|
||||||
quint32 groupId = Endian::bytesToUInt32(fieldData, KeePass1::BYTEORDER);
|
quint32 groupId = Endian::bytesToUInt32(fieldData, KeePass1::BYTEORDER);
|
||||||
m_entryGroupIds.insert(entry.data(), groupId);
|
m_entryGroupIds.insert(entry.data(), groupId);
|
||||||
@ -557,7 +557,7 @@ Entry* KeePass1Reader::readEntry(QIODevice* cipherStream)
|
|||||||
case 0x0003:
|
case 0x0003:
|
||||||
{
|
{
|
||||||
if (fieldSize != 4) {
|
if (fieldSize != 4) {
|
||||||
return 0;
|
return Q_NULLPTR;
|
||||||
}
|
}
|
||||||
quint32 iconNumber = Endian::bytesToUInt32(fieldData, KeePass1::BYTEORDER);
|
quint32 iconNumber = Endian::bytesToUInt32(fieldData, KeePass1::BYTEORDER);
|
||||||
entry->setIcon(iconNumber);
|
entry->setIcon(iconNumber);
|
||||||
@ -581,7 +581,7 @@ Entry* KeePass1Reader::readEntry(QIODevice* cipherStream)
|
|||||||
case 0x0009:
|
case 0x0009:
|
||||||
{
|
{
|
||||||
if (fieldSize != 5) {
|
if (fieldSize != 5) {
|
||||||
return 0;
|
return Q_NULLPTR;
|
||||||
}
|
}
|
||||||
QDateTime dateTime = dateFromPackedStruct(fieldData);
|
QDateTime dateTime = dateFromPackedStruct(fieldData);
|
||||||
if (dateTime.isValid()) {
|
if (dateTime.isValid()) {
|
||||||
@ -592,7 +592,7 @@ Entry* KeePass1Reader::readEntry(QIODevice* cipherStream)
|
|||||||
case 0x000A:
|
case 0x000A:
|
||||||
{
|
{
|
||||||
if (fieldSize != 5) {
|
if (fieldSize != 5) {
|
||||||
return 0;
|
return Q_NULLPTR;
|
||||||
}
|
}
|
||||||
QDateTime dateTime = dateFromPackedStruct(fieldData);
|
QDateTime dateTime = dateFromPackedStruct(fieldData);
|
||||||
if (dateTime.isValid()) {
|
if (dateTime.isValid()) {
|
||||||
@ -603,7 +603,7 @@ Entry* KeePass1Reader::readEntry(QIODevice* cipherStream)
|
|||||||
case 0x000B:
|
case 0x000B:
|
||||||
{
|
{
|
||||||
if (fieldSize != 5) {
|
if (fieldSize != 5) {
|
||||||
return 0;
|
return Q_NULLPTR;
|
||||||
}
|
}
|
||||||
QDateTime dateTime = dateFromPackedStruct(fieldData);
|
QDateTime dateTime = dateFromPackedStruct(fieldData);
|
||||||
if (dateTime.isValid()) {
|
if (dateTime.isValid()) {
|
||||||
@ -614,7 +614,7 @@ Entry* KeePass1Reader::readEntry(QIODevice* cipherStream)
|
|||||||
case 0x000C:
|
case 0x000C:
|
||||||
{
|
{
|
||||||
if (fieldSize != 5) {
|
if (fieldSize != 5) {
|
||||||
return 0;
|
return Q_NULLPTR;
|
||||||
}
|
}
|
||||||
QDateTime dateTime = dateFromPackedStruct(fieldData);
|
QDateTime dateTime = dateFromPackedStruct(fieldData);
|
||||||
if (dateTime.isValid()) {
|
if (dateTime.isValid()) {
|
||||||
@ -636,7 +636,7 @@ Entry* KeePass1Reader::readEntry(QIODevice* cipherStream)
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// invalid field
|
// invalid field
|
||||||
return 0;
|
return Q_NULLPTR;
|
||||||
}
|
}
|
||||||
} while (!reachedEnd);
|
} while (!reachedEnd);
|
||||||
|
|
||||||
|
@ -50,20 +50,20 @@ Database* KeePass2Reader::readDatabase(QIODevice* device, const CompositeKey& ke
|
|||||||
quint32 signature1 = Endian::readUInt32(m_device, KeePass2::BYTEORDER, &ok);
|
quint32 signature1 = Endian::readUInt32(m_device, KeePass2::BYTEORDER, &ok);
|
||||||
if (!ok || signature1 != KeePass2::SIGNATURE_1) {
|
if (!ok || signature1 != KeePass2::SIGNATURE_1) {
|
||||||
raiseError(tr("Not a KeePass database."));
|
raiseError(tr("Not a KeePass database."));
|
||||||
return 0;
|
return Q_NULLPTR;
|
||||||
}
|
}
|
||||||
|
|
||||||
quint32 signature2 = Endian::readUInt32(m_device, KeePass2::BYTEORDER, &ok);
|
quint32 signature2 = Endian::readUInt32(m_device, KeePass2::BYTEORDER, &ok);
|
||||||
if (!ok || signature2 != KeePass2::SIGNATURE_2) {
|
if (!ok || signature2 != KeePass2::SIGNATURE_2) {
|
||||||
raiseError(tr("Not a KeePass database."));
|
raiseError(tr("Not a KeePass database."));
|
||||||
return 0;
|
return Q_NULLPTR;
|
||||||
}
|
}
|
||||||
|
|
||||||
quint32 version = Endian::readUInt32(m_device, KeePass2::BYTEORDER, &ok) & KeePass2::FILE_VERSION_CRITICAL_MASK;
|
quint32 version = Endian::readUInt32(m_device, KeePass2::BYTEORDER, &ok) & KeePass2::FILE_VERSION_CRITICAL_MASK;
|
||||||
quint32 maxVersion = KeePass2::FILE_VERSION & KeePass2::FILE_VERSION_CRITICAL_MASK;
|
quint32 maxVersion = KeePass2::FILE_VERSION & KeePass2::FILE_VERSION_CRITICAL_MASK;
|
||||||
if (!ok || (version < KeePass2::FILE_VERSION_MIN) || (version > maxVersion)) {
|
if (!ok || (version < KeePass2::FILE_VERSION_MIN) || (version > maxVersion)) {
|
||||||
raiseError(tr("Unsupported KeePass database version."));
|
raiseError(tr("Unsupported KeePass database version."));
|
||||||
return 0;
|
return Q_NULLPTR;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (readHeaderField() && !hasError()) {
|
while (readHeaderField() && !hasError()) {
|
||||||
@ -86,7 +86,7 @@ Database* KeePass2Reader::readDatabase(QIODevice* device, const CompositeKey& ke
|
|||||||
|
|
||||||
if (realStart != m_streamStartBytes) {
|
if (realStart != m_streamStartBytes) {
|
||||||
raiseError(tr("Wrong key or database file is corrupt."));
|
raiseError(tr("Wrong key or database file is corrupt."));
|
||||||
return 0;
|
return Q_NULLPTR;
|
||||||
}
|
}
|
||||||
|
|
||||||
HashedBlockStream hashedStream(&cipherStream);
|
HashedBlockStream hashedStream(&cipherStream);
|
||||||
@ -121,7 +121,7 @@ Database* KeePass2Reader::readDatabase(QIODevice* device, const CompositeKey& ke
|
|||||||
|
|
||||||
if (xmlReader.hasError()) {
|
if (xmlReader.hasError()) {
|
||||||
raiseError(xmlReader.errorString());
|
raiseError(xmlReader.errorString());
|
||||||
return 0;
|
return Q_NULLPTR;
|
||||||
}
|
}
|
||||||
|
|
||||||
return db.take();
|
return db.take();
|
||||||
@ -132,14 +132,14 @@ Database* KeePass2Reader::readDatabase(const QString& filename, const CompositeK
|
|||||||
QFile file(filename);
|
QFile file(filename);
|
||||||
if (!file.open(QFile::ReadOnly)) {
|
if (!file.open(QFile::ReadOnly)) {
|
||||||
raiseError(file.errorString());
|
raiseError(file.errorString());
|
||||||
return 0;
|
return Q_NULLPTR;
|
||||||
}
|
}
|
||||||
|
|
||||||
QScopedPointer<Database> db(readDatabase(&file, key));
|
QScopedPointer<Database> db(readDatabase(&file, key));
|
||||||
|
|
||||||
if (file.error() != QFile::NoError) {
|
if (file.error() != QFile::NoError) {
|
||||||
raiseError(file.errorString());
|
raiseError(file.errorString());
|
||||||
return 0;
|
return Q_NULLPTR;
|
||||||
}
|
}
|
||||||
|
|
||||||
return db.take();
|
return db.take();
|
||||||
|
@ -895,7 +895,7 @@ QByteArray KeePass2XmlReader::readCompressedBinary()
|
|||||||
Group* KeePass2XmlReader::getGroup(const Uuid& uuid)
|
Group* KeePass2XmlReader::getGroup(const Uuid& uuid)
|
||||||
{
|
{
|
||||||
if (uuid.isNull()) {
|
if (uuid.isNull()) {
|
||||||
return 0;
|
return Q_NULLPTR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_groups.contains(uuid)) {
|
if (m_groups.contains(uuid)) {
|
||||||
@ -914,7 +914,7 @@ Group* KeePass2XmlReader::getGroup(const Uuid& uuid)
|
|||||||
Entry* KeePass2XmlReader::getEntry(const Uuid& uuid)
|
Entry* KeePass2XmlReader::getEntry(const Uuid& uuid)
|
||||||
{
|
{
|
||||||
if (uuid.isNull()) {
|
if (uuid.isNull()) {
|
||||||
return 0;
|
return Q_NULLPTR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_entries.contains(uuid)) {
|
if (m_entries.contains(uuid)) {
|
||||||
|
@ -486,7 +486,7 @@ Database* DatabaseTabWidget::indexDatabase(int index)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return Q_NULLPTR;
|
||||||
}
|
}
|
||||||
|
|
||||||
DatabaseManagerStruct DatabaseTabWidget::indexDatabaseManagerStruct(int index)
|
DatabaseManagerStruct DatabaseTabWidget::indexDatabaseManagerStruct(int index)
|
||||||
@ -514,7 +514,7 @@ Database* DatabaseTabWidget::databaseFromDatabaseWidget(DatabaseWidget* dbWidget
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return Q_NULLPTR;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DatabaseTabWidget::insertDatabase(Database* db, const DatabaseManagerStruct& dbStruct)
|
void DatabaseTabWidget::insertDatabase(Database* db, const DatabaseManagerStruct& dbStruct)
|
||||||
@ -542,7 +542,7 @@ DatabaseWidget* DatabaseTabWidget::currentDatabaseWidget()
|
|||||||
return m_dbList[db].dbWidget;
|
return m_dbList[db].dbWidget;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return 0;
|
return Q_NULLPTR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -204,7 +204,7 @@ QStringList EntryModel::mimeTypes() const
|
|||||||
QMimeData* EntryModel::mimeData(const QModelIndexList& indexes) const
|
QMimeData* EntryModel::mimeData(const QModelIndexList& indexes) const
|
||||||
{
|
{
|
||||||
if (indexes.isEmpty()) {
|
if (indexes.isEmpty()) {
|
||||||
return 0;
|
return Q_NULLPTR;
|
||||||
}
|
}
|
||||||
|
|
||||||
QMimeData* data = new QMimeData();
|
QMimeData* data = new QMimeData();
|
||||||
|
@ -81,7 +81,7 @@ Entry* EntryView::currentEntry()
|
|||||||
return m_model->entryFromIndex(m_sortModel->mapToSource(list.first()));
|
return m_model->entryFromIndex(m_sortModel->mapToSource(list.first()));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return 0;
|
return Q_NULLPTR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -101,7 +101,7 @@ Entry* EntryView::entryFromIndex(const QModelIndex& index)
|
|||||||
return m_model->entryFromIndex(m_sortModel->mapToSource(index));
|
return m_model->entryFromIndex(m_sortModel->mapToSource(index));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return 0;
|
return Q_NULLPTR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -273,7 +273,7 @@ QStringList GroupModel::mimeTypes() const
|
|||||||
QMimeData* GroupModel::mimeData(const QModelIndexList& indexes) const
|
QMimeData* GroupModel::mimeData(const QModelIndexList& indexes) const
|
||||||
{
|
{
|
||||||
if (indexes.isEmpty()) {
|
if (indexes.isEmpty()) {
|
||||||
return 0;
|
return Q_NULLPTR;
|
||||||
}
|
}
|
||||||
|
|
||||||
QMimeData* data = new QMimeData();
|
QMimeData* data = new QMimeData();
|
||||||
|
@ -66,7 +66,7 @@ void GroupView::dragMoveEvent(QDragMoveEvent* event)
|
|||||||
Group* GroupView::currentGroup()
|
Group* GroupView::currentGroup()
|
||||||
{
|
{
|
||||||
if (currentIndex() == QModelIndex()) {
|
if (currentIndex() == QModelIndex()) {
|
||||||
return 0;
|
return Q_NULLPTR;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return m_model->groupFromIndex(currentIndex());
|
return m_model->groupFromIndex(currentIndex());
|
||||||
|
Loading…
Reference in New Issue
Block a user