build: Add format string linter #13705

pull practicalswift wants to merge 2 commits into bitcoin:master from practicalswift:lint-format-strings changing 2 files +295 −0
  1. 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:

    0$ test/lint/lint-format-strings.sh
    1src/init.cpp: Expected 2 argument(s) after format string but found 1 argument(s): 
    2  LogPrintf("We have a mismatch here: foo=%s bar=%d\n", foo)
    3src/init.cpp: Expected 1 argument(s) after format string but found 2 argument(s):
    4  LogPrint(BCLog::RPC, "RPC stopped. This is a mismatch: %s\n", s1, s2)
    5$ echo $?
    61
    
  2. practicalswift force-pushed on Jul 18, 2018
  3. practicalswift force-pushed on Jul 18, 2018
  4. fanquake added the label Scripts and tools on Jul 18, 2018
  5. fanquake commented at 1:51 am on July 19, 2018: member
    @practicalswift Is this for a specific bug/issue you’ve seen previously?
  6. 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).
  7. 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.

  8. laanwj assigned laanwj on Jul 25, 2018
  9. laanwj commented at 12:03 pm on August 7, 2018: member
    Needs rebase for some reason
  10. 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
  11. practicalswift force-pushed on Aug 7, 2018
  12. practicalswift commented at 12:07 pm on August 7, 2018: contributor
    @laanwj Weird! Now rebased!
  13. 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…)

  14. Add linting of WalletLogPrintf(...) format strings bcd4b0f5cd
  15. 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 :-)
  16. laanwj commented at 1:27 pm on August 7, 2018: member
    ACK bcd4b0f5cdde2a1b562a612c78ec1ef1fe47d3dd
  17. laanwj merged this on Aug 7, 2018
  18. laanwj closed this on Aug 7, 2018

  19. laanwj referenced this in commit b413ba0273 on Aug 7, 2018
  20. ken2812221 commented at 10:39 am on August 10, 2018: contributor
    This won’t allow have template inside: https://travis-ci.org/bitcoin/bitcoin/jobs/414449333
  21. 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.
  22. ken2812221 referenced this in commit ef86f2631e on Aug 13, 2018
  23. MarcoFalke referenced this in commit 7027c67cac on Jul 2, 2020
  24. PastaPastaPasta referenced this in commit 1971ccfef5 on Jul 29, 2020
  25. PastaPastaPasta referenced this in commit a69003bc61 on Jul 29, 2020
  26. PastaPastaPasta referenced this in commit 036125c9a5 on Jul 29, 2020
  27. practicalswift deleted the branch on Apr 10, 2021
  28. PastaPastaPasta referenced this in commit c62243ccf5 on Jun 27, 2021
  29. PastaPastaPasta referenced this in commit 4165dbc12a on Jun 28, 2021
  30. PastaPastaPasta referenced this in commit 1131377a0f on Jun 29, 2021
  31. PastaPastaPasta referenced this in commit 90e674cd15 on Jun 29, 2021
  32. PastaPastaPasta referenced this in commit 38cd8acf93 on Jun 29, 2021
  33. PastaPastaPasta referenced this in commit 674c68d39c on Jun 29, 2021
  34. PastaPastaPasta referenced this in commit 69c601c2c3 on Jun 29, 2021
  35. vijaydasmp referenced this in commit dfa262c93f on Oct 4, 2021
  36. gades referenced this in commit 7ca45d6e6a on Mar 11, 2022
  37. DrahtBot locked this on Aug 16, 2022

github-metadata-mirror

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: 2024-12-18 21:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me