forked from bitcoin/bitcoin
-
Notifications
You must be signed in to change notification settings - Fork 6
Re enable OP_CAT
#39
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
Merged
ajtowns
merged 4 commits into
bitcoin-inquisition:25.x
from
0xBEEFCAF3:armin/re-enable-op-cat
Apr 26, 2024
Merged
Re enable OP_CAT
#39
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -467,10 +467,16 @@ bool EvalScript(std::vector<std::vector<unsigned char> >& stack, const CScript& | |
if (opcode > OP_16 && ++nOpCount > MAX_OPS_PER_SCRIPT) { | ||
return set_error(serror, SCRIPT_ERR_OP_COUNT); | ||
} | ||
|
||
// When OP_SUCCESS disabled opcodes (CVE-2010-5137) are | ||
// redefined in tapscript, remove them from the if below | ||
// and put them here | ||
if (opcode == OP_CAT) { | ||
return set_error(serror, SCRIPT_ERR_DISABLED_OPCODE); // Disabled opcodes (CVE-2010-5137). | ||
ajtowns marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
} | ||
|
||
if (opcode == OP_CAT || | ||
opcode == OP_SUBSTR || | ||
if (opcode == OP_SUBSTR || | ||
opcode == OP_LEFT || | ||
opcode == OP_RIGHT || | ||
opcode == OP_INVERT || | ||
|
@@ -534,6 +540,19 @@ bool EvalScript(std::vector<std::vector<unsigned char> >& stack, const CScript& | |
case OP_NOP: | ||
break; | ||
|
||
case OP_CAT: | ||
{ | ||
if (stack.size() < 2) | ||
return set_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION); | ||
valtype& vch1 = stacktop(-2); | ||
valtype& vch2 = stacktop(-1); | ||
if (vch1.size() + vch2.size() > MAX_SCRIPT_ELEMENT_SIZE) | ||
return set_error(serror, SCRIPT_ERR_PUSH_SIZE); | ||
vch1.insert(vch1.end(), vch2.begin(), vch2.end()); | ||
stack.pop_back(); | ||
} | ||
0xBEEFCAF3 marked this conversation as resolved.
Show resolved
Hide resolved
0xBEEFCAF3 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
break; | ||
|
||
case OP_CHECKLOCKTIMEVERIFY: | ||
{ | ||
if (!(flags & SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY)) { | ||
|
@@ -1963,12 +1982,21 @@ static bool ExecuteWitnessScript(const Span<const valtype>& stack_span, const CS | |
// Note how this condition would not be reached if an unknown OP_SUCCESSx was found | ||
return set_error(serror, SCRIPT_ERR_BAD_OPCODE); | ||
} | ||
// New opcodes will be listed here. May use a different sigversion to modify existing opcodes. | ||
|
||
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. Should maybe keep an altered comment? |
||
if (IsOpSuccess(opcode)) { | ||
if (flags & SCRIPT_VERIFY_DISCOURAGE_OP_SUCCESS) { | ||
return set_error(serror, SCRIPT_ERR_DISCOURAGE_OP_SUCCESS); | ||
if (opcode == OP_CAT) { | ||
if (flags & SCRIPT_VERIFY_DISCOURAGE_OP_CAT) { | ||
return set_error(serror, SCRIPT_ERR_DISCOURAGE_OP_CAT); | ||
} else if (!(flags & SCRIPT_VERIFY_OP_CAT)) { | ||
return set_success(serror); | ||
} | ||
} else { | ||
// OP_SUCCESS behaviour | ||
if (flags & SCRIPT_VERIFY_DISCOURAGE_OP_SUCCESS) { | ||
return set_error(serror, SCRIPT_ERR_DISCOURAGE_OP_SUCCESS); | ||
} | ||
return set_success(serror); | ||
} | ||
return set_success(serror); | ||
} | ||
} | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.