Skip to content

fix: reject deepObject integers that overflow the destination - #185

Merged
mromaszewicz merged 1 commit into
oapi-codegen:mainfrom
youdie006:deepobject-int-overflow
Nov 16, 2026
Merged

mromaszewicz merged 1 commit into
oapi-codegen:mainfrom
youdie006:deepobject-int-overflow

Conversation

@youdie006

Copy link
Copy Markdown
Contributor

UnmarshalDeepObject parses integer fields with strconv.ParseInt(v, 10, 64) and calls SetInt without checking that the value fits, so an out-of-range value wraps silently:

?filter[count]=4294967297&filter[small]=200   (Count int32, Small int8)
before: {Count:1 Small:-56} err=<nil>
after:  err=error assigning value to destination: error assigning field [count]: value '4294967297' overflows destination of type: int32

The form style already rejects the same value with this message (bindstring.go), and the JSON binders check OverflowInt as well. This adds the same check to the deepObject int case.

The new test binds values at the int8 and int32 bounds and one past them; the overflow rows fail without the change. go test -race ./..., go vet and golangci-lint run pass.

Written with AI assistance (Claude); I have reviewed the change.

assignPathValues parsed integers as int64 and called SetInt without an
OverflowInt check, so 200 bound to an int8 field as -56. The form style
and the JSON binders already return an overflow error.
@youdie006
youdie006 requested a review from a team as a code owner November 16, 2026 01:25
@mromaszewicz

Copy link
Copy Markdown
Member

Thank you!

@mromaszewicz
mromaszewicz merged commit 44fd220 into oapi-codegen:main Nov 16, 2026
10 checks passed
@mromaszewicz mromaszewicz added the bug Something isn't working label Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants