Skip to content

Commit

Permalink
Bump version to 6. Remain compat with version 5.
Browse files Browse the repository at this point in the history
Version 6 marks that the blobs are not hashed against application info.
Otherwise, they are fully compatible.
  • Loading branch information
HansKristian-Work committed May 7, 2019
1 parent d80ff70 commit 661ec80
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
3 changes: 2 additions & 1 deletion fossilize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2203,7 +2203,8 @@ void StateReplayer::Impl::parse(StateCreatorInterface &iface, DatabaseInterface
FOSSILIZE_THROW("JSON parse error.");
}

if (doc["version"].GetInt() != FOSSILIZE_FORMAT_VERSION)
int version = doc["version"].GetInt();
if (version > FOSSILIZE_FORMAT_VERSION || version < FOSSILIZE_FORMAT_MIN_COMPAT_VERSION)
FOSSILIZE_THROW("JSON version mismatches.");

if (doc.HasMember("applicationInfo") && doc.HasMember("physicalDeviceFeatures"))
Expand Down
3 changes: 2 additions & 1 deletion fossilize.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ enum ResourceTag

enum
{
FOSSILIZE_FORMAT_VERSION = 5
FOSSILIZE_FORMAT_VERSION = 6,
FOSSILIZE_FORMAT_MIN_COMPAT_VERSION = 5
};

class DatabaseInterface;
Expand Down
5 changes: 4 additions & 1 deletion fossilize_db.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,10 @@ struct StreamArchive : DatabaseInterface
if (fread(magic, 1, MagicSize, file) != MagicSize)
return false;

if (memcmp(magic, stream_reference_magic_and_version, MagicSize))
if (memcmp(magic, stream_reference_magic_and_version, MagicSize - 1))
return false;
int version = magic[MagicSize - 1];
if (version > FOSSILIZE_FORMAT_VERSION || version < FOSSILIZE_FORMAT_MIN_COMPAT_VERSION)
return false;

size_t offset = MagicSize;
Expand Down

0 comments on commit 661ec80

Please sign in to comment.