Skip to content

fix: Reject unsigned integer overflow before conversion - #20

Open
bensynapse wants to merge 1 commit into
dunglas:mainfrom
bensynapse:fix-unsigned-integer-range
Open

bensynapse wants to merge 1 commit into
dunglas:mainfrom
bensynapse:fix-unsigned-integer-range

Conversation

@bensynapse

Copy link
Copy Markdown

I run Live Tennis API.

An unsigned value can wrap into a valid negative integer before marshalInteger checks its range. For example, Marshal(NewItem(^uint64(0))) currently succeeds with "-1".

Check the unsigned value against the structured field integer limit before converting it to int64. Values outside that range now return ErrNumberOutOfRange.

The regression tests cover unsigned widths, valid boundary values, overflow boundaries, and nested items. They also check that an error returns an empty string.

Verified with go test -race -covermode atomic -coverprofile=profile.cov on Go 1.27.2 and 1.26.9, with 95.3% coverage. golangci-lint run passes with zero issues using v2.14.0.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant