The error message has several issues:
- It may crash instead of cleanly shutting down, when
-noincludeconf=0is passed - It doesn't quote the value
- It includes an erroneous trailing
\n - It is redundantly mentioning
"-includeconf cannot be used from commandline;"several times, when once should be more than sufficient
Fix all issues by:
- Replacing
get_str()withwrite()to fix the crash and quoting issue - Remove the
\nand only print the first value to fix the other issues
Before:
$ ./src/bitcoind -noincludeconf=0
terminate called after throwing an instance of 'std::runtime_error'
what(): JSON value is not a string as expected
Aborted (core dumped)
$ ./src/bitcoind -includeconf='a b' -includeconf=c
Error: Error parsing command line arguments: -includeconf cannot be used from commandline; -includeconf=a b
-includeconf cannot be used from commandline; -includeconf=c
After:
$ ./src/bitcoind -noincludeconf=0
Error: Error parsing command line arguments: -includeconf cannot be used from commandline; -includeconf=true
$ ./src/bitcoind -includeconf='a b' -includeconf=c
Error: Error parsing command line arguments: -includeconf cannot be used from commandline; -includeconf="a b"
Hopefully fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=34493
FUZZ=system ./src/test/fuzz/fuzz ./clusterfuzz-testcase-minimized-system-6328535926046720.log
See https://github.com/bitcoin/bitcoin/blob/master/doc/fuzzing.md