Files
Michal Klos 4b99dd8c8f chore: consolidated bumps and security updates (#12325)
* chore(deps): bump filippo.io/edwards25519 from 1.1.0 to 1.1.1

* chore(deps): bump github.com/cloudflare/circl from 1.6.1 to 1.6.3

* chore(deps): bump github.com/russellhaering/goxmldsig from 1.5.0 to 1.6.0

* build(deps): bump fpicalausa/remove-stale-branches from 2.4.0 to 2.6.1

* build(deps): bump actions/upload-artifact from 4.6.2 to 7.0.1

* build(deps): bump actions/download-artifact from 4.3.0 to 8.0.1

* build(deps): bump pnpm/action-setup from 5.0.0 to 6.0.8

* chore(deps): bump github.com/shamaton/msgpack/v2 to v2.4.1 and reva to v2.0.0-20260519092700-9da01c6fb954

* chore: regenerate lock fil s and vendor

* chore: changelog

* fix: bump golang.org/x/image to v0.39.0 (GO-2026-4815, GO-2026-4961, GO-2026-4962)
2026-05-19 12:52:58 +00:00

106 lines
2.0 KiB
Go

package decoding
import (
"encoding/binary"
"reflect"
"github.com/shamaton/msgpack/v2/def"
)
func (d *decoder) asUint(offset int, k reflect.Kind) (uint64, int, error) {
code, _, err := d.readSize1(offset)
if err != nil {
return 0, 0, err
}
switch {
case d.isPositiveFixNum(code):
b, offset, err := d.readSize1(offset)
if err != nil {
return 0, 0, err
}
return uint64(b), offset, nil
case d.isNegativeFixNum(code):
b, offset, err := d.readSize1(offset)
if err != nil {
return 0, 0, err
}
return uint64(int8(b)), offset, nil
case code == def.Uint8:
offset++
b, offset, err := d.readSize1(offset)
if err != nil {
return 0, 0, err
}
return uint64(uint8(b)), offset, nil
case code == def.Int8:
offset++
b, offset, err := d.readSize1(offset)
if err != nil {
return 0, 0, err
}
return uint64(int8(b)), offset, nil
case code == def.Uint16:
offset++
bs, offset, err := d.readSize2(offset)
if err != nil {
return 0, 0, err
}
v := binary.BigEndian.Uint16(bs)
return uint64(v), offset, nil
case code == def.Int16:
offset++
bs, offset, err := d.readSize2(offset)
if err != nil {
return 0, 0, err
}
v := int16(binary.BigEndian.Uint16(bs))
return uint64(v), offset, nil
case code == def.Uint32:
offset++
bs, offset, err := d.readSize4(offset)
if err != nil {
return 0, 0, err
}
v := binary.BigEndian.Uint32(bs)
return uint64(v), offset, nil
case code == def.Int32:
offset++
bs, offset, err := d.readSize4(offset)
if err != nil {
return 0, 0, err
}
v := int32(binary.BigEndian.Uint32(bs))
return uint64(v), offset, nil
case code == def.Uint64:
offset++
bs, offset, err := d.readSize8(offset)
if err != nil {
return 0, 0, err
}
return binary.BigEndian.Uint64(bs), offset, nil
case code == def.Int64:
offset++
bs, offset, err := d.readSize8(offset)
if err != nil {
return 0, 0, err
}
return binary.BigEndian.Uint64(bs), offset, nil
case code == def.Nil:
offset++
return 0, offset, nil
}
return 0, 0, d.errorTemplate(code, k)
}