Skip to content

reject non-integer JSON numbers for integer leaves - #1107

Open
nabhan06 wants to merge 1 commit into
openconfig:masterfrom
nabhan06:int-leaf-fractional
Open

nabhan06 wants to merge 1 commit into
openconfig:masterfrom
nabhan06:int-leaf-fractional

Conversation

@nabhan06

Copy link
Copy Markdown
Contributor

checkJSONFloat64Range only validates the numeric range of an RFC7951 JSON number bound for an int8/16/32 or uint8/16/32 leaf and never checks that it is a whole number, so yangFloatIntToGoType then narrows it with int8(v)/uint8(v) and Unmarshal silently accepts 3.9 for a uint8 leaf and stores 3. The same conversion is reached for leaves, leaf-lists, and integer union members, so a fractional value is quietly truncated in each. Reject a float64 that carries a fractional part before the range check so these inputs error out instead of being silently rounded.

@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 88.76% (+0.002%) from 88.758% — nabhan06:int-leaf-fractional into openconfig:master

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.

2 participants