Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,29 +23,29 @@ jobs:
timeout-minutes: 15
strategy:
matrix:
go-version: [1.25.x]
go-version: [1.26.x, 1.27.x]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v6
- uses: actions/checkout@v7.0.1
with:
persist-credentials: false

- uses: actions/setup-go@v6
- uses: actions/setup-go@v7.0.0
with:
go-version: ${{ matrix.go-version }}
cache: true

- name: golangci-lint
uses: golangci/golangci-lint-action@v9
uses: golangci/golangci-lint-action@v9.3.0
with:
version: v2.7.2
version: v2.13.2

- name: Build
run: go build -v ./...

- name: Run govulncheck
uses: golang/govulncheck-action@v1
uses: golang/govulncheck-action@v1.1.0
with:
go-version-input: ${{ matrix.go-version }}

Expand Down
5 changes: 5 additions & 0 deletions decode.go
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,10 @@ func (m *msgpackDecoder) decode(s decodeStack) (err error) {
}

mask := func(b byte, m int) int64 {
// Validate m is within byte range to prevent overflow
if m < 0 || m > 255 {
return 0
}
return int64(b & byte(m))
}
makeFixedUint := func(b byte, m int) msgpackInt {
Expand Down Expand Up @@ -654,6 +658,7 @@ func (m *msgpackDecoder) decode(s decodeStack) (err error) {
if err != nil {
return err
}
//nolint:gosec // G115: Intentional byte to int8 conversion per msgpack spec
return m.produceInt(s, msgpackInt{typ: intTypeInt8, val: int64(int8(i))})

// int16
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
module github.com/keybase/msgpackzip

go 1.23
go 1.26.0

toolchain go1.25.5
toolchain go1.27.1

require github.com/stretchr/testify v1.11.1

Expand Down
8 changes: 8 additions & 0 deletions output.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,20 @@ func (o *outputter) outputPrefixAndBinaryInt(b byte, i any) error {
func (o *outputter) outputContainerPrefix(i msgpackInt, fixed byte, numFixed byte, u8 byte, u16 byte, u32 byte) (err error) {
switch i.typ {
case intTypeFixedUint:
// Validate value fits in byte range
if i.val < 0 || i.val > 255 {
return errors.New("integer overflow: value out of range for fixed uint")
}
if fixed != 0x0 && byte(i.val) <= numFixed {
return o.outputByte(fixed | byte(i.val))
}
fallthrough
case intTypeUint8:
if u8 != 0x0 {
// Validate value fits in byte range
if i.val < 0 || i.val > 255 {
return errors.New("integer overflow: value out of range for uint8")
}
var b [2]byte
b[0] = u8
b[1] = byte(i.val)
Expand Down