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.
ken2812221 referenced this in commit ef86f2631e on Aug 13, 2018
MarcoFalke referenced this in commit 7027c67cac on Jul 2, 2020
PastaPastaPasta referenced this in commit 1971ccfef5 on Jul 29, 2020
PastaPastaPasta referenced this in commit a69003bc61 on Jul 29, 2020
PastaPastaPasta referenced this in commit 036125c9a5 on Jul 29, 2020
practicalswift deleted the branch on Apr 10, 2021
PastaPastaPasta referenced this in commit c62243ccf5 on Jun 27, 2021
PastaPastaPasta referenced this in commit 4165dbc12a on Jun 28, 2021
PastaPastaPasta referenced this in commit 1131377a0f on Jun 29, 2021
PastaPastaPasta referenced this in commit 90e674cd15 on Jun 29, 2021
PastaPastaPasta referenced this in commit 38cd8acf93 on Jun 29, 2021
PastaPastaPasta referenced this in commit 674c68d39c on Jun 29, 2021
PastaPastaPasta referenced this in commit 69c601c2c3 on Jun 29, 2021
vijaydasmp referenced this in commit dfa262c93f on Oct 4, 2021
gades referenced this in commit 7ca45d6e6a on Mar 11, 2022
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-02 12:15 UTC
This site is hosted by @0xB10C More mirrored repositories can be found on mirror.b10c.me