mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-15 14:18:37 +00:00
Added simple IFF type verification to the parser.
svn-id: r39609
This commit is contained in:
parent
631e0aaed5
commit
2b8140d765
@ -39,6 +39,22 @@ void IFFParser::setInputStream(Common::SeekableReadStream *stream) {
|
||||
_stream = stream;
|
||||
_startOffset = 0;
|
||||
_endOffset = _stream->size();
|
||||
|
||||
_formType = 0;
|
||||
_formSize = (uint32)-1;
|
||||
|
||||
if (_stream->size() < 12) {
|
||||
// this file is too small to be a valid IFF container
|
||||
return;
|
||||
}
|
||||
|
||||
if (_stream->readUint32BE() != ID_FORM) {
|
||||
// no FORM header was found
|
||||
return;
|
||||
}
|
||||
|
||||
_formSize = _stream->readUint32BE();
|
||||
_formType = _stream->readUint32BE();
|
||||
}
|
||||
|
||||
void IFFParser::destroy() {
|
||||
@ -46,18 +62,12 @@ void IFFParser::destroy() {
|
||||
_startOffset = _endOffset = 0;
|
||||
}
|
||||
|
||||
uint32 IFFParser::getFORMBlockSize() {
|
||||
uint32 oldOffset = _stream->pos();
|
||||
uint32 IFFParser::getFORMSize() const {
|
||||
return _formSize;
|
||||
}
|
||||
|
||||
uint32 data = _stream->readUint32BE();
|
||||
|
||||
if (data != ID_FORM) {
|
||||
_stream->seek(oldOffset);
|
||||
return (uint32)-1;
|
||||
}
|
||||
|
||||
data = _stream->readUint32BE();
|
||||
return data;
|
||||
Common::IFF_ID IFFParser::getFORMType() const {
|
||||
return _formType;
|
||||
}
|
||||
|
||||
uint32 IFFParser::moveToIFFBlock(Common::IFF_ID chunkName) {
|
||||
@ -117,6 +127,10 @@ ILBMDecoder::ILBMDecoder(Common::SeekableReadStream *in, bool disposeStream) : _
|
||||
assert(in);
|
||||
_parser.setInputStream(in);
|
||||
|
||||
if (_parser.getFORMType() != ID_ILBM) {
|
||||
return;
|
||||
}
|
||||
|
||||
_hasHeader = _parser.loadIFFBlock(ID_BMHD, &_header, sizeof(_header));
|
||||
if (!_hasHeader) {
|
||||
return;
|
||||
|
@ -46,7 +46,9 @@ public:
|
||||
|
||||
operator bool() const { return (_startOffset != _endOffset) && _stream; }
|
||||
|
||||
uint32 getFORMBlockSize();
|
||||
uint32 getFORMSize() const;
|
||||
Common::IFF_ID getFORMType() const;
|
||||
|
||||
uint32 getIFFBlockSize(Common::IFF_ID chunk);
|
||||
bool loadIFFBlock(Common::IFF_ID chunk, void *loadTo, uint32 ptrSize);
|
||||
Common::SeekableReadStream *getIFFBlockStream(Common::IFF_ID chunkName);
|
||||
@ -57,6 +59,9 @@ private:
|
||||
Common::SeekableReadStream *_stream;
|
||||
uint32 _startOffset;
|
||||
uint32 _endOffset;
|
||||
|
||||
uint32 _formSize;
|
||||
Common::IFF_ID _formType;
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user