Added minInvalidProtocolVersion

This commit is contained in:
sfc-gh-tclinkenbeard 2020-07-09 14:39:35 -07:00
parent 949a17359a
commit e69f299a5c
2 changed files with 9 additions and 1 deletions

View File

@ -135,3 +135,6 @@ constexpr ProtocolVersion currentProtocolVersion(0x0FDB00B063010001LL);
// This assert is intended to help prevent incrementing the leftmost digits accidentally. It will probably need to
// change when we reach version 10.
static_assert(currentProtocolVersion.version() < 0x0FDB00B100000000LL, "Unexpected protocol version");
// Downgrades are only supported for one minor version
constexpr ProtocolVersion minInvalidProtocolVersion(0x0FDB00B071000000LL);

View File

@ -286,7 +286,12 @@ struct _IncludeVersion {
TraceEvent(SevWarnAlways, "InvalidSerializationVersion").error(err).detailf("Version", "%llx", v.versionWithFlags());
throw err;
}
// TODO: Add the add maximum readable version.
if (v >= minInvalidProtocolVersion) {
// Downgrades are only supported for one minor version
auto err = incompatible_protocol_version();
TraceEvent(SevError, "FutureProtocolVersion").error(err).detailf("Version", "%llx", v.versionWithFlags());
throw err;
}
ar.setProtocolVersion(v);
}
};