-
Notifications
You must be signed in to change notification settings - Fork 38.7k
[Qt] Ensure an item exists on the rpcconsole stack before adding #10060
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
[Qt] Ensure an item exists on the rpcconsole stack before adding #10060
Conversation
|
Confirmed that Core does segfault when using the above command in the rpcconsole, and that it no longer happens with the PR'd fix. |
src/qt/rpcconsole.cpp
Outdated
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.
space after if please and left brace on the same line (or maybe one line if without braces - see https://github.com/bitcoin/bitcoin/blob/master/doc/developer-notes.md).
|
Concept ACK |
f9c9ef7 to
f3fa05a
Compare
|
Thanks for pointing this out. diff --git a/src/qt/rpcconsole.cpp b/src/qt/rpcconsole.cpp
index 7a0d0b3..c2f6434 100644
--- a/src/qt/rpcconsole.cpp
+++ b/src/qt/rpcconsole.cpp
@@ -190,6 +190,7 @@ bool RPCConsole::RPCParseCommandLine(std::string &strResult, const std::string &
};
std::string strCommandTerminated = strCommand;
+ std::replace(strCommandTerminated.begin(),strCommandTerminated.end(),'\n',' ');
if (strCommandTerminated.back() != '\n')
strCommandTerminated += "\n";
for (chpos = 0; chpos < strCommandTerminated.size(); ++chpos) |
|
@jonasschnelli The segfault bug happens with more than just a newline in the command. It also happens if an end parenthesis |
src/qt/rpcconsole.cpp
Outdated
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.
Nit: space after if please.
|
utACK, with nit. |
Ensures that there is an item on the rpcconsole stack before adding something to the current stack so that a segmentation fault does not occur.
f3fa05a to
4df76e2
Compare
|
Needs backport. |
…re adding 4df76e2 Ensure an item exists on the rpcconsole stack before adding (Andrew Chow) Tree-SHA512: f3fd5e70da186949aff794f6e2ba122da2145331212dcc5e0595285bee9dc3aa6b400b15e8eeec4476099965b74f46c4ef80f8ed1e05d490580167b002b9a5e7
Ensures that there is an item on the rpcconsole stack before adding something to the current stack so that a segmentation fault does not occur. Github-Pull: bitcoin#10060 Rebased-From: 4df76e2
…ck before adding 4df76e2 Ensure an item exists on the rpcconsole stack before adding (Andrew Chow) Tree-SHA512: f3fd5e70da186949aff794f6e2ba122da2145331212dcc5e0595285bee9dc3aa6b400b15e8eeec4476099965b74f46c4ef80f8ed1e05d490580167b002b9a5e7
…ck before adding 4df76e2 Ensure an item exists on the rpcconsole stack before adding (Andrew Chow) Tree-SHA512: f3fd5e70da186949aff794f6e2ba122da2145331212dcc5e0595285bee9dc3aa6b400b15e8eeec4476099965b74f46c4ef80f8ed1e05d490580167b002b9a5e7
…ck before adding 4df76e2 Ensure an item exists on the rpcconsole stack before adding (Andrew Chow) Tree-SHA512: f3fd5e70da186949aff794f6e2ba122da2145331212dcc5e0595285bee9dc3aa6b400b15e8eeec4476099965b74f46c4ef80f8ed1e05d490580167b002b9a5e7
Ensures that there is an item on the rpcconsole stack before adding something to the current stack so that a segmentation fault does not occur.
Currently Bitcoin Core will just crash if there happens to be a newline somewhere in the command followed by some non-whitespace characters which are followed by a space. This causes a segfault by attempting to get the current stack from the empty stack vector. This fix ensures that that current stack always exists so that the segfault does not happen.
The crashing behavior can be tested by using this command in the rpcconsole:
(copy and paste it as one line)