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

golang: Enforce maximum decoding depth #169

Merged
merged 3 commits into from
Sep 19, 2023
Merged

Conversation

2opremio
Copy link
Contributor

@2opremio 2opremio commented Sep 19, 2023

See stellar/go#5057 for an example of the generated output

Depends on stellar/go-xdr#18

Copy link

@tsachiherman tsachiherman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. One thing I'd consider improving is the error objects -
Instead of dynamically creating the error object, i.e.

= errors.New(\"decoding #{name}: maximum decoding depth reached\")"

we could pre-created global error objects containing this object. then, we would return these objects. Creating an error of a specific struct would also allow us to further identify the error if that being triggered.
i.e.

type ErrorMaxDepthReached struct {
    objName string
}
func (o *ErrorMaxDepthReached) Error() string { ... }

@2opremio 2opremio force-pushed the go-max-decoding-depth branch from c3a62ee to 09c9a09 Compare September 19, 2023 15:02
@2opremio 2opremio force-pushed the go-max-decoding-depth branch from 09c9a09 to 5aaecf3 Compare September 19, 2023 15:42
@2opremio 2opremio merged commit a231a92 into master Sep 19, 2023
3 checks passed
@2opremio 2opremio deleted the go-max-decoding-depth branch September 19, 2023 16:09
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