mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-08-19 03:28:25 -04:00
SymmetricCipherStream: Add error handling when reading from the device.
This commit is contained in:
parent
fcb5deff0a
commit
61503a8047
1 changed files with 16 additions and 2 deletions
|
@ -115,11 +115,25 @@ qint64 SymmetricCipherStream::readData(char* data, qint64 maxSize)
|
|||
|
||||
bool SymmetricCipherStream::readBlock()
|
||||
{
|
||||
QByteArray newData;
|
||||
|
||||
if (m_bufferFilling) {
|
||||
m_buffer.append(m_baseDevice->read(m_cipher->blockSize() - m_buffer.size()));
|
||||
newData.resize(m_cipher->blockSize() - m_buffer.size());
|
||||
}
|
||||
else {
|
||||
m_buffer = m_baseDevice->read(m_cipher->blockSize());
|
||||
m_buffer.clear();
|
||||
newData.resize(m_cipher->blockSize());
|
||||
}
|
||||
|
||||
int readResult = m_baseDevice->read(newData.data(), newData.size());
|
||||
|
||||
if (readResult == -1) {
|
||||
m_error = true;
|
||||
setErrorString(m_baseDevice->errorString());
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
m_buffer.append(newData.left(readResult));
|
||||
}
|
||||
|
||||
if (m_buffer.size() != m_cipher->blockSize()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue