libebml/libebml2: only Master elements can have an infinite/unknown size

git-svn-id: https://matroska.svn.sourceforge.net/svnroot/matroska/trunk/libebml@270 a6f86f6d-0131-4f8e-9e7b-e335508773d5
This commit is contained in:
Steve Lhomme 2010-05-25 12:02:30 +00:00
parent ece95ac6b7
commit 8f6b7a6fd9
8 changed files with 488 additions and 487 deletions

View File

@ -30,7 +30,7 @@
/*!
\file
\version \$Id: EbmlBinary.h 1298 2008-02-21 22:14:18Z mosu $
\version \$Id$
\author Steve Lhomme <robux4 @ users.sf.net>
\author Julien Coloos <suiryc @ users.sf.net>
*/
@ -62,7 +62,7 @@ class EBML_DLL_API EbmlBinary : public EbmlElement {
EbmlBinary(const EbmlBinary & ElementToClone);
virtual ~EbmlBinary(void);
virtual bool ValidateSize() const {return true;} // we don't mind about what's inside
virtual bool ValidateSize() const {return IsFiniteSize() && GetSize() < INT_MAX;} // we don't mind about what's inside
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bWithDefault = false);
filepos_t ReadData(IOCallback & input, ScopeMode ReadFully = SCOPE_ALL_DATA);

View File

@ -30,7 +30,7 @@
/*!
\file
\version \$Id: EbmlCrc32.h 1326 2009-08-23 00:47:52Z robux4 $
\version \$Id$
\author Steve Lhomme <robux4 @ users.sf.net>
\author Jory Stone <jcsston @ toughguy.net>
*/
@ -57,7 +57,7 @@ const uint32 CRC32_NEGL = 0xffffffffL;
DECLARE_EBML_BINARY(EbmlCrc32)
public:
EbmlCrc32(const EbmlCrc32 & ElementToClone);
virtual bool ValidateSize() const {return (GetSize() == 4);}
virtual bool ValidateSize() const {return IsFiniteSize() && (GetSize() == 4);}
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bWithDefault = false);
filepos_t ReadData(IOCallback & input, ScopeMode ReadFully = SCOPE_ALL_DATA);
// filepos_t UpdateSize(bool bWithDefault = false);

View File

@ -28,7 +28,7 @@
/*!
\file
\version \$Id: EbmlDate.h 1079 2005-03-03 13:18:14Z robux4 $
\version \$Id$
\author Steve Lhomme <robux4 @ users.sf.net>
*/
#ifndef LIBEBML_DATE_H
@ -60,7 +60,7 @@ class EBML_DLL_API EbmlDate : public EbmlElement {
*/
int32 GetEpochDate() const {return int32(myDate/1000000000 + UnixEpochDelay);}
virtual bool ValidateSize() const {return ((GetSize() == 8) || (GetSize() == 0));}
virtual bool ValidateSize() const {return IsFiniteSize() && ((GetSize() == 8) || (GetSize() == 0));}
/*!
\note no Default date handled

View File

@ -456,6 +456,7 @@ class EBML_DLL_API EbmlElement {
bool ValueIsSet() const {return bValueIsSet;}
inline uint64 GetEndPosition() const {
assert(bSizeIsFinite); // we don't know where the end is
return SizePosition + CodedSizeLength(Size, SizeLength, bSizeIsFinite) + Size;
}

View File

@ -30,7 +30,7 @@
/*!
\file
\version \$Id: EbmlSInteger.h 1079 2005-03-03 13:18:14Z robux4 $
\version \$Id$
\author Steve Lhomme <robux4 @ users.sf.net>
\author Julien Coloos <suiryc @ users.sf.net>
\author Moritz Bunkus <moritz @ bunkus.org>
@ -64,7 +64,7 @@ class EBML_DLL_API EbmlSInteger : public EbmlElement {
*/
virtual void SetDefaultSize(uint64 nDefaultSize = DEFAULT_INT_SIZE) {EbmlElement::SetDefaultSize(nDefaultSize); SetSize_(nDefaultSize);}
virtual bool ValidateSize() const {return (GetSize() <= 8);}
virtual bool ValidateSize() const {return IsFiniteSize() && (GetSize() <= 8);}
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bWithDefault = false);
filepos_t ReadData(IOCallback & input, ScopeMode ReadFully = SCOPE_ALL_DATA);
filepos_t UpdateSize(bool bWithDefault = false, bool bForceRender = false);

View File

@ -30,7 +30,7 @@
/*!
\file
\version \$Id: EbmlString.h 1079 2005-03-03 13:18:14Z robux4 $
\version \$Id$
\author Steve Lhomme <robux4 @ users.sf.net>
*/
#ifndef LIBEBML_STRING_H
@ -55,7 +55,7 @@ class EBML_DLL_API EbmlString : public EbmlElement {
virtual ~EbmlString() {}
virtual bool ValidateSize() const {return true;} // any size is possible
virtual bool ValidateSize() const {return IsFiniteSize();} // any size is possible
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bWithDefault = false);
filepos_t ReadData(IOCallback & input, ScopeMode ReadFully = SCOPE_ALL_DATA);
filepos_t UpdateSize(bool bWithDefault = false, bool bForceRender = false);

View File

@ -30,7 +30,7 @@
/*!
\file
\version \$Id: EbmlUInteger.h 1079 2005-03-03 13:18:14Z robux4 $
\version \$Id$
\author Steve Lhomme <robux4 @ users.sf.net>
\author Julien Coloos <suiryc @ users.sf.net>
\author Moritz Bunkus <moritz @ bunkus.org>
@ -62,7 +62,7 @@ class EBML_DLL_API EbmlUInteger : public EbmlElement {
*/
virtual void SetDefaultSize(uint64 nDefaultSize = DEFAULT_UINT_SIZE) {EbmlElement::SetDefaultSize(nDefaultSize); SetSize_(nDefaultSize);}
virtual bool ValidateSize() const {return (GetSize() <= 8);}
virtual bool ValidateSize() const {return IsFiniteSize() && (GetSize() <= 8);}
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bWithDefault = false);
filepos_t ReadData(IOCallback & input, ScopeMode ReadFully = SCOPE_ALL_DATA);
filepos_t UpdateSize(bool bWithDefault = false, bool bForceRender = false);

View File

@ -30,7 +30,7 @@
/*!
\file
\version \$Id: EbmlUnicodeString.h 1079 2005-03-03 13:18:14Z robux4 $
\version \$Id$
\author Steve Lhomme <robux4 @ users.sf.net>
\author Moritz Bunkus <moritz @ bunkus.org>
\author Jory Stone <jcsston @ toughguy.net>
@ -104,7 +104,7 @@ class EBML_DLL_API EbmlUnicodeString : public EbmlElement {
virtual ~EbmlUnicodeString() {}
virtual bool ValidateSize() const {return true;} // any size is possible
virtual bool ValidateSize() const {return IsFiniteSize();} // any size is possible
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bWithDefault = false);
filepos_t ReadData(IOCallback & input, ScopeMode ReadFully = SCOPE_ALL_DATA);
filepos_t UpdateSize(bool bWithDefault = false, bool bForceRender = false);