Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: Options to disable bignum support #528

Closed
benluddy opened this issue Apr 26, 2024 · 1 comment
Closed

feature: Options to disable bignum support #528

benluddy opened this issue Apr 26, 2024 · 1 comment

Comments

@benluddy
Copy link
Contributor

Is your feature request related to a problem? Please describe.

For an application whose CBOR-based protocol does not include arbitrary-precision integers (https://www.rfc-editor.org/rfc/rfc8949.html#section-5-3), it should be possible to reject the bignum tags 2 and 3 on decode and math/big.Int on encode.

Describe the solution you'd like

  1. A new decode option specifying the decode behavior for the bignum tags, regardless of the Go type of the unmarshal destination object. Its default value would be backwards-compatible and would permit the bignum tag, but its second mode will cause Wellformed and Unmarshal to return an UnacceptableDataItemError if a bignum tag is encountered.
  2. A new mode for the encode option BigIntConvert, analogous to the InfConvert and NaNConvert options introduced by Allow rejection of NaN and Inf float values on encode and decode. #513, that will return an UnsupportedTypeError if a math/big.Int is passed to Marshal.

Describe alternatives you've considered

The existing BigIntDec option is scoped to unmarshaling bignums into interface{}, which would not be suitable on its own for the purpose of rejecting all bignums. Bignums can also be decoded into uint, int, float, slice, array, and math/big.Int. I ended up adding the new option because I did not see a use case where the type of the destination Go value would affect whether or not a CBOR-based protocol accepts a particular input.

Additional context

@fxamacker
Copy link
Owner

Thanks Ben! 🎉 Closed by #527.

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

No branches or pull requests

2 participants