mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-08 13:43:43 +00:00
tvg_loader: make sure the pointer does not exceed the size
This commit is contained in:
parent
d599f744c8
commit
fe474856b9
2 changed files with 5 additions and 1 deletions
|
@ -35,6 +35,7 @@ using TvgBinFlag = TvgBinByte;
|
|||
|
||||
|
||||
//Header
|
||||
#define TVG_HEADER_SIZE 33 //TVG_HEADER_SIGNATURE_LENGTH + TVG_HEADER_VERSION_LENGTH + 2*SIZE(float) + TVG_HEADER_RESERVED_LENGTH + TVG_HEADER_COMPRESS_SIZE
|
||||
#define TVG_HEADER_SIGNATURE "ThorVG"
|
||||
#define TVG_HEADER_SIGNATURE_LENGTH 6
|
||||
#define TVG_HEADER_VERSION "000400" //Major 00, Minor 04, Micro 00
|
||||
|
|
|
@ -50,6 +50,9 @@ bool TvgLoader::readHeader()
|
|||
{
|
||||
if (!ptr) return false;
|
||||
|
||||
//Make sure the size is large enough to hold the header
|
||||
if (size < TVG_HEADER_SIZE) return false;
|
||||
|
||||
//1. Signature
|
||||
if (memcmp(ptr, TVG_HEADER_SIGNATURE, TVG_HEADER_SIGNATURE_LENGTH)) return false;
|
||||
ptr += TVG_HEADER_SIGNATURE_LENGTH;
|
||||
|
@ -225,4 +228,4 @@ unique_ptr<Paint> TvgLoader::paint()
|
|||
this->done();
|
||||
if (root) return move(root);
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue