mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-05 15:18:49 +00:00
Merge pull request #5878 from laytan/fix-cbor-epoch-small-value
encoding/cbor: fix epoch tag with small values
This commit is contained in:
@@ -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:
|
case .U8, .U16, .U32, .U64, .Neg_U8, .Neg_U16, .Neg_U32, .Neg_U64:
|
||||||
switch &dst in v {
|
switch &dst in v {
|
||||||
case time.Time:
|
case time.Time:
|
||||||
i: i64
|
secs: i64
|
||||||
_unmarshal_any_ptr(d, &i, hdr) or_return
|
_unmarshal_any_ptr(d, &secs, hdr) or_return
|
||||||
dst = time.unix(i64(i), 0)
|
dst = time.unix(i64(secs), 0)
|
||||||
return
|
return
|
||||||
case:
|
case:
|
||||||
return _unmarshal_value(d, v, hdr)
|
return _unmarshal_value(d, v, hdr)
|
||||||
@@ -152,19 +152,23 @@ tag_time_unmarshal :: proc(_: ^Tag_Implementation, d: Decoder, _: Tag_Number, v:
|
|||||||
|
|
||||||
case:
|
case:
|
||||||
maj, add := _header_split(hdr)
|
maj, add := _header_split(hdr)
|
||||||
if maj == .Other {
|
secs: u8
|
||||||
i := _decode_tiny_u8(add) or_return
|
#partial switch maj {
|
||||||
|
case .Unsigned:
|
||||||
switch &dst in v {
|
secs = _decode_tiny_u8(add) or_return
|
||||||
case time.Time:
|
case .Other:
|
||||||
dst = time.unix(i64(i), 0)
|
secs = u8(_decode_tiny_simple(add) or_return)
|
||||||
case:
|
case:
|
||||||
if _assign_int(v, i) { return }
|
return .Bad_Tag_Value
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only numbers and floats are allowed in this tag.
|
switch &dst in v {
|
||||||
return .Bad_Tag_Value
|
case time.Time:
|
||||||
|
dst = time.unix(i64(secs), 0)
|
||||||
|
return
|
||||||
|
case:
|
||||||
|
if _assign_int(v, secs) { return }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return _unsupported(v, hdr)
|
return _unsupported(v, hdr)
|
||||||
|
|||||||
Reference in New Issue
Block a user