Change read_string
to fail when not the entire input has been consumed. This avoids unexpected, even dangerous behavior (fixes #6223).
The new JSON parser adapted in #6121 also solves this problem so in master this is a temporary fix, but should be backported to older releases.
Also adds tests for the new behavior.
This now errors as expected:
0$ src/bitcoin-cli -testnet sendtoaddress msj42CCGruhRsFrGATiUuh25dtxYtnpbTx 1.0dsfs
1error: Error parsing JSON:1.0dsfs
Needs backport to 0.10 and 0.11. I don’t think older versions are affected, as they did manual parsing of bitcoin-cli arguments.
Note: normally I wouldn’t change json_spirit directly as it is an upstream library, but it is going to be dropped anyway, so doing the straightforward fix makes sense