Merge pull request #118 from saturday06/unity2018-msgpack-time-before-unix-epoch

Throw exception on serialize 32bit time older than unix epoch
This commit is contained in:
ousttrue
2019-01-09 23:40:05 +09:00
committed by GitHub

View File

@@ -418,6 +418,11 @@ namespace UniJSON
public void TimeStamp32(DateTimeOffset time)
{
// https://github.com/ousttrue/UniJSON/blob/1.2/Scripts/Extensions/DateTimeOffsetExtensions.cs#L13-L16
if (time < DateTimeOffsetExtensions.EpochTime)
{
throw new ArgumentOutOfRangeException();
}
m_store.Write((Byte)MsgPackType.FIX_EXT_4);
m_store.Write((SByte)(-1));
m_store.WriteBigEndian((uint)time.ToUnixTimeSeconds());