IFF: Fix possible stack overflow

This commit is contained in:
Mirco Miranda
2025-07-05 11:59:06 +02:00
committed by Albert Astals Cid
parent 775b53f1f6
commit ea1983a7d1
2 changed files with 40 additions and 8 deletions

View File

@ -256,6 +256,14 @@ protected:
*/
void setChunks(const ChunkList &chunks);
/*!
* \brief recursionCounter
* Protection against stack overflow due to broken data.
* \return The current recursion counter.
*/
qint32 recursionCounter() const;
void setRecursionCounter(qint32 cnt);
inline quint16 ui16(quint8 c1, quint8 c2) const {
return (quint16(c2) << 8) | quint16(c1);
}
@ -272,7 +280,7 @@ protected:
return qint32(ui32(c1, c2, c3, c4));
}
static ChunkList innerFromDevice(QIODevice *d, bool *ok, qint32 alignBytes);
static ChunkList innerFromDevice(QIODevice *d, bool *ok, qint32 alignBytes, qint32 recursionCnt);
private:
char _chunkId[4];
@ -287,6 +295,8 @@ private:
ChunkList _chunks;
qint32 _recursionCnt;
};