aboutsummaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorLaytan <laytanlaats@hotmail.com>2025-11-03 20:33:17 +0100
committerLaytan <laytanlaats@hotmail.com>2025-11-03 20:33:17 +0100
commit9893a0eaea81e1411a04534fab8134716a4f59e5 (patch)
treed8c26e610b1e82ce2afb551423ed5cf93ff59d70 /core
parent8a417e75b7c6968bf0507ea5615abab4919566ea (diff)
encoding/cbor: fix epoch tag with small values
Diffstat (limited to 'core')
-rw-r--r--core/encoding/cbor/tags.odin32
1 files changed, 18 insertions, 14 deletions
diff --git a/core/encoding/cbor/tags.odin b/core/encoding/cbor/tags.odin
index be07b926a..fa456673d 100644
--- a/core/encoding/cbor/tags.odin
+++ b/core/encoding/cbor/tags.odin
@@ -130,9 +130,9 @@ tag_time_unmarshal :: proc(_: ^Tag_Implementation, d: Decoder, _: Tag_Number, v:
case .U8, .U16, .U32, .U64, .Neg_U8, .Neg_U16, .Neg_U32, .Neg_U64:
switch &dst in v {
case time.Time:
- i: i64
- _unmarshal_any_ptr(d, &i, hdr) or_return
- dst = time.unix(i64(i), 0)
+ secs: i64
+ _unmarshal_any_ptr(d, &secs, hdr) or_return
+ dst = time.unix(i64(secs), 0)
return
case:
return _unmarshal_value(d, v, hdr)
@@ -152,19 +152,23 @@ tag_time_unmarshal :: proc(_: ^Tag_Implementation, d: Decoder, _: Tag_Number, v:
case:
maj, add := _header_split(hdr)
- if maj == .Other {
- i := _decode_tiny_u8(add) or_return
-
- switch &dst in v {
- case time.Time:
- dst = time.unix(i64(i), 0)
- case:
- if _assign_int(v, i) { return }
- }
+ secs: u8
+ #partial switch maj {
+ case .Unsigned:
+ secs = _decode_tiny_u8(add) or_return
+ case .Other:
+ secs = u8(_decode_tiny_simple(add) or_return)
+ case:
+ return .Bad_Tag_Value
}
- // Only numbers and floats are allowed in this tag.
- return .Bad_Tag_Value
+ switch &dst in v {
+ case time.Time:
+ dst = time.unix(i64(secs), 0)
+ return
+ case:
+ if _assign_int(v, secs) { return }
+ }
}
return _unsupported(v, hdr)