From cbb6f2752501bdccbf143ceda135519b902dd1a2112f1a3c0fb791004be423d2 Mon Sep 17 00:00:00 2001 From: Sergey Matveev Date: Thu, 21 Nov 2024 00:25:26 +0300 Subject: [PATCH] Assure that minimally encoded TAI64s are used --- pyac/pyac.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pyac/pyac.py b/pyac/pyac.py index 43dcf8b..92f0ec4 100755 --- a/pyac/pyac.py +++ b/pyac/pyac.py @@ -298,11 +298,15 @@ def loads(v, sets=False, leapsecUTCAllow=False): nsecs = 0 if l > 8: nsecs = int.from_bytes(v[1+8:1+8+4], "big") + if nsecs == 0: + raise DecodeError("non-minimal encoding") if nsecs > 999999999: raise DecodeError("too many nanoseconds") asecs = 0 if l > 12: asecs = int.from_bytes(v[1+8+4:1+8+4+4], "big") + if asecs == 0: + raise DecodeError("non-minimal encoding") if asecs > 999999999: raise DecodeError("too many attoseconds") secs = tai2utc(secs - TAI64Base, leapsecUTCAllow) -- 2.50.0