-
Notifications
You must be signed in to change notification settings - Fork 504
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
txnbuild: Fix bug in parsing MangeData xdr operations #2573
Conversation
For future releases of txnbuild we can add a smoke test where we call |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the quick turnaround on this!
txnbuild/CHANGELOG.md
Outdated
@@ -3,6 +3,10 @@ | |||
All notable changes to this project will be documented in this | |||
file. This project adheres to [Semantic Versioning](http://semver.org/). | |||
|
|||
## Unreleased |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I support releasing this immediately as a patch release.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Solid fix.
if result.DataValue != nil { | ||
md.Value = *result.DataValue | ||
} else { | ||
md.Value = nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love that you set this to nil explicitly even though we don't need to. It makes the intention really clear.
|
||
tx, _ = parsed.Transaction() | ||
assert.Equal(t, []Operation{&manageData}, tx.Operations()) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It wouldn't hurt to add tests for the cases when the data value has a valid value non-empty and when it is valid empty (not nil). I don't see any tests for these situations either.
PR Checklist
PR Structure
otherwise).
services/friendbot
, orall
ordoc
if the changes are broad or impact manypackages.
Thoroughness
.md
files, etc... affected by this change). Take a look in the
docs
folder for a given service,like this one.
Release planning
needed with deprecations, added features, breaking changes, and DB schema changes.
semver, or if it's mainly a patch change. The PR is targeted at the next
release branch if it's not a patch change.
What
Close #2572
Fix bug which occurs when parsing transactions with manage data operations containing nil values.
It seems like this bug has been present in older versions of txnbuild. I ran the following test case on versions 2.2.0, 2.1.0, 2.0.0, 1.50, and 1.4.0 and they all produced a panic similar to what's described in #2572:
I checked if there were other potential nil dereferences in the txnbuild package by running this search:
Afterwards, I looked at all the cases in txnbuild/set_options.go. They seemed fine because the pointer derefrences were guarded by nil checks.