[Scummvm-cvs-logs] SF.net SVN: scummvm:[39609] scummvm/trunk/engines/parallaction
peres001 at users.sourceforge.net
peres001 at users.sourceforge.net
Sun Mar 22 16:30:42 CET 2009
Revision: 39609
http://scummvm.svn.sourceforge.net/scummvm/?rev=39609&view=rev
Author: peres001
Date: 2009-03-22 15:30:42 +0000 (Sun, 22 Mar 2009)
Log Message:
-----------
Added simple IFF type verification to the parser.
Modified Paths:
--------------
scummvm/trunk/engines/parallaction/iff.cpp
scummvm/trunk/engines/parallaction/iff.h
Modified: scummvm/trunk/engines/parallaction/iff.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/iff.cpp 2009-03-22 15:25:55 UTC (rev 39608)
+++ scummvm/trunk/engines/parallaction/iff.cpp 2009-03-22 15:30:42 UTC (rev 39609)
@@ -39,6 +39,22 @@
_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 @@
_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 @@
assert(in);
_parser.setInputStream(in);
+ if (_parser.getFORMType() != ID_ILBM) {
+ return;
+ }
+
_hasHeader = _parser.loadIFFBlock(ID_BMHD, &_header, sizeof(_header));
if (!_hasHeader) {
return;
Modified: scummvm/trunk/engines/parallaction/iff.h
===================================================================
--- scummvm/trunk/engines/parallaction/iff.h 2009-03-22 15:25:55 UTC (rev 39608)
+++ scummvm/trunk/engines/parallaction/iff.h 2009-03-22 15:30:42 UTC (rev 39609)
@@ -46,7 +46,9 @@
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 @@
Common::SeekableReadStream *_stream;
uint32 _startOffset;
uint32 _endOffset;
+
+ uint32 _formSize;
+ Common::IFF_ID _formType;
};
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list