diff options
| author | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2019-05-06 19:28:35 +0000 |
|---|---|---|
| committer | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2019-05-06 19:28:35 +0000 |
| commit | 8f97d76080b9617fc67d01f2bc8de36a5b0a1175 (patch) | |
| tree | b0b9287109dd54a3b3dc709c72c0dc6a69d03d29 /src | |
| parent | 23585bba435a25c59433f084e9ba2f5a212d2c21 (diff) | |
| download | qmmp-8f97d76080b9617fc67d01f2bc8de36a5b0a1175.tar.gz qmmp-8f97d76080b9617fc67d01f2bc8de36a5b0a1175.tar.bz2 qmmp-8f97d76080b9617fc67d01f2bc8de36a5b0a1175.zip | |
archive: fixed crash on some corrupted archives (#998)
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@8861 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src')
| -rw-r--r-- | src/plugins/Input/archive/archiveinputdevice.cpp | 14 | ||||
| -rw-r--r-- | src/plugins/Input/archive/decoderarchivefactory.cpp | 8 |
2 files changed, 21 insertions, 1 deletions
diff --git a/src/plugins/Input/archive/archiveinputdevice.cpp b/src/plugins/Input/archive/archiveinputdevice.cpp index 22cfa2372..5b11a2938 100644 --- a/src/plugins/Input/archive/archiveinputdevice.cpp +++ b/src/plugins/Input/archive/archiveinputdevice.cpp @@ -80,6 +80,9 @@ ArchiveInputDevice::~ArchiveInputDevice() bool ArchiveInputDevice::seek(qint64 pos) { + if(!isOpen()) + return false; + QIODevice::seek(pos); if(pos > m_buffer.size()) @@ -99,10 +102,11 @@ bool ArchiveInputDevice::seek(qint64 pos) else if(r < 0) { qWarning("ArchiveInputDevice: seeking failed; libarchive error: %s", archive_error_string(m_archive)); + setErrorString(QString::fromLocal8Bit(archive_error_string(m_archive))); + close(); } return false; } - } return m_buffer.seek(pos); @@ -115,6 +119,9 @@ qint64 ArchiveInputDevice::size() const qint64 ArchiveInputDevice::readData(char *data, qint64 maxSize) { + if(!isOpen()) + return -1; + if(m_buffer.pos() + maxSize > m_buffer.size()) { qint64 l = m_buffer.pos() + maxSize - m_buffer.size(); @@ -123,7 +130,12 @@ qint64 ArchiveInputDevice::readData(char *data, qint64 maxSize) if(r > 0) m_buffer.buffer().append(tmp, r); else if(r < 0) + { qWarning("ArchiveInputDevice: reading failed; libarchive error: %s", archive_error_string(m_archive)); + setErrorString(QString::fromLocal8Bit(archive_error_string(m_archive))); + close(); + return -1; + } } return m_buffer.read(data, maxSize); } diff --git a/src/plugins/Input/archive/decoderarchivefactory.cpp b/src/plugins/Input/archive/decoderarchivefactory.cpp index 3b83616c2..119e30d83 100644 --- a/src/plugins/Input/archive/decoderarchivefactory.cpp +++ b/src/plugins/Input/archive/decoderarchivefactory.cpp @@ -112,6 +112,14 @@ QList<TrackInfo *> DecoderArchiveFactory::createPlayList(const QString &path, Tr ArchiveInputDevice dev(a, entry, nullptr); ArchiveTagReader reader(&dev, list.last()->path()); + if(!dev.isOpen()) + { + qDeleteAll(list); + list.clear(); + archive_read_free(a); + return list; + } + if(parts & TrackInfo::MetaData) list.last()->setValues(reader.metaData()); |
