-
Notifications
You must be signed in to change notification settings - Fork 36.5k
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
bitcoin-tx: Avoid treating integer overflow as OP_0 #23227
Conversation
Concept ACK Nice to see |
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
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.
utACK fa0c2f9
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.
Concept and code-review ACK fa0c2f9
fa0c2f9
to
fa43e7c
Compare
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.
re-ACK fa43e7c
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.
ACK fa43e7c
This PR’s primary focus is to avoid treating an overflow integer value as output 0.
This is done by using the ToIntegral function that returns the integer value of the number if it is in the int_64 range; otherwise, it produces a nullopt. Followed by this, a check is applied to a returned value which checks if it has a valid value. And return an error in case if its not.
This PR also deals with further minors changes, which are:
- Appropriate additions to the comments in strencodings.h and lint-locale-dependence.sh files.
- Using C++11 range based indicator in ParseScript function.
- Fixing whitespaces in ParseScript function.
I agree with the above changes, and I think they are necessary and valuable.
I would like to suggest one addition, though. In case you have to update the PR for some major reason, how about also adding the test for negative -999….999 (i.e., huge number)
{ "exec": "./bitcoin-tx",
"args": ["-create", "outscript=0:-999999999999999999999999999999"],
"return_code": 1,
"error_txt": "error: script parse error: decimal numeric value only allowed in the range -0xFFFFFFFF...0xFFFFFFFF",
“description”: “Try to parse an output script with a decimal number below the allowed range.”
},
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.
re-utACK fa43e7c
Seems odd to treat integer overflow as
OP_0
, so fix that.