From 2c175b9f7e50f95f5eeb9aa91ac364eac18d3748 Mon Sep 17 00:00:00 2001 From: Isamu Mogi Date: Tue, 8 Jan 2019 00:33:39 +0900 Subject: [PATCH] Throw exception on serialize 32bit time older than unix epoch --- Assets/VRM/UniJSON/Scripts/MsgPack/MsgPackFormatter.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Assets/VRM/UniJSON/Scripts/MsgPack/MsgPackFormatter.cs b/Assets/VRM/UniJSON/Scripts/MsgPack/MsgPackFormatter.cs index 1a713cb5f..eea676d69 100644 --- a/Assets/VRM/UniJSON/Scripts/MsgPack/MsgPackFormatter.cs +++ b/Assets/VRM/UniJSON/Scripts/MsgPack/MsgPackFormatter.cs @@ -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());