Skip to content

Commit cb722a3

Browse files
committed
descriptor: check whitespace in ParsePubkeyInner
Due to Base58, keys with whitespace at the beginning or at the end are successfully parsed. This commit adds a check into `ParsePubkeyInner` to verify whether if the first or last char of the key is a space.
1 parent 5085669 commit cb722a3

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/script/descriptor.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1509,6 +1509,10 @@ std::vector<std::unique_ptr<PubkeyProvider>> ParsePubkeyInner(uint32_t key_exp_i
15091509
error = "No key provided";
15101510
return {};
15111511
}
1512+
if (IsSpace(str.front()) || IsSpace(str.back())) {
1513+
error = strprintf("Key '%s' is invalid due to whitespace", str);
1514+
return {};
1515+
}
15121516
if (split.size() == 1) {
15131517
if (IsHex(str)) {
15141518
std::vector<unsigned char> data = ParseHex(str);

0 commit comments

Comments
 (0)