-
Notifications
You must be signed in to change notification settings - Fork 322
cbor: don't allow infinite nesting by default #373
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,9 +38,10 @@ pub enum DecoderError { | |
| } | ||
|
|
||
| /// Deserialize CBOR binary data to produce a single [`Value`], expecting that there is no additional data. | ||
| /// Supports arbitrarily nested CBOR (so the [`DecoderError::TooMuchNesting`] error is never emitted). | ||
| /// Maximum level of nesting supported is 127; more deeply nested structures will fail with | ||
| /// [`DecoderError::TooMuchNesting`]. | ||
| pub fn read(encoded_cbor: &[u8]) -> Result<Value, DecoderError> { | ||
| read_nested(encoded_cbor, None) | ||
| read_nested(encoded_cbor, Some(i8::MAX)) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, now I'm wondering why we even need to support infinite nesting. Shouldn't we just have
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, IIRC the
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Intention was to keep the simple interface from before. Means we have to decide between the current state of this PR (default 127, I start to see the appeal of the simpler interface that @ia0 is proposing. It does require most users to write a wrapper function for their preferred nesting level, but that is already true for everyone who doesn't like the 127 default. Also, if we don't think anyone should ever call with So this PR good to merge, but feel free to change to the simple API too if you'd like. |
||
| } | ||
|
|
||
| /// Deserialize CBOR binary data to produce a single [`Value`], expecting that there is no additional data. If | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.