practicalswift
commented at 9:40 PM on July 18, 2018:
contributor
Add format string linter.
This linter checks that the number of arguments passed to each variadic format string function matches the number of format specifiers in the format string.
Example output:
$ test/lint/lint-format-strings.sh
src/init.cpp: Expected 2 argument(s) after format string but found 1 argument(s):
LogPrintf("We have a mismatch here: foo=%s bar=%d\n", foo)
src/init.cpp: Expected 1 argument(s) after format string but found 2 argument(s):
LogPrint(BCLog::RPC, "RPC stopped. This is a mismatch: %s\n", s1, s2)
$ echo $?
1
practicalswift force-pushed on Jul 18, 2018
practicalswift force-pushed on Jul 18, 2018
fanquake added the label Scripts and tools on Jul 18, 2018
fanquake
commented at 1:51 AM on July 19, 2018:
member
@practicalswift Is this for a specific bug/issue you've seen previously?
practicalswift
commented at 1:47 PM on July 19, 2018:
contributor
@fanquake In the past there has been at least one incident where a mistake in the log message formatting resulted in a near DoS vulnerability. It was an under-tested error path in the network code with an invalid LogPrintf() spec. @laanwj has more details.
@laanwj suggested writing a format string linter in #9423 (comment).
laanwj
commented at 1:45 PM on July 25, 2018:
member
Yes, I think this is very useful! we've had some issues with this in the past.
Better to find these issues before they cause runtime problems.
Thank for writing it in Python instead of making a long shell mess, this means I can usefully review it.
laanwj assigned laanwj on Jul 25, 2018
laanwj
commented at 12:03 PM on August 7, 2018:
member
Needs rebase for some reason
build: Add format string linter
This linter checks that the number of arguments passed to each variadic format
string function matches the number of format specifiers in the format string.
a3e4556949
practicalswift force-pushed on Aug 7, 2018
practicalswift
commented at 12:07 PM on August 7, 2018:
contributor
laanwj
commented at 12:36 PM on August 7, 2018:
member
Thanks, new error:
src/wallet/wallet.h: Expected 1 argument(s) after format string but found 2 argument(s): LogPrintf(("%s " + fmt).c_str(), GetDisplayName(), parameters...)
Add linting of WalletLogPrintf(...) format stringsbcd4b0f5cd
practicalswift
commented at 12:58 PM on August 7, 2018:
contributor
@laanwj Oh, a good chance to add linting also of WalletLogPrintf format strings. Fixed. Please re-review :-)
laanwj
commented at 1:27 PM on August 7, 2018:
member
ACKbcd4b0f5cdde2a1b562a612c78ec1ef1fe47d3dd
laanwj merged this on Aug 7, 2018
laanwj closed this on Aug 7, 2018
laanwj referenced this in commit b413ba0273 on Aug 7, 2018
ken2812221
commented at 10:39 AM on August 10, 2018:
contributor
practicalswift
commented at 11:15 AM on August 10, 2018:
contributor
@ken2812221 Oh, interesting! I’ll fix that. Thanks for reporting. In the meantime you can just add an exception (FALSE_POSITIVES) in the script to get around it.
This is a metadata mirror of the GitHub repository
bitcoin/bitcoin.
This site is not affiliated with GitHub.
Content is generated from a GitHub metadata backup.
generated: 2026-05-20 06:55 UTC