Repository navigation
Conversation
|
There should probably be a trac ticket for this PR. Please create it, or ask us to create it. Then the PR title should be updated. |
|
I don't have Trac access, so could you create the ticket for this one? Once there's a number I'll update the title to "Fix #NNNN (...)" like the others. For the ticket: with A range that does fit, e.g. |
|
I have created https://trac.cppcheck.net/ticket/15181 |
|
ping? there is a small formatting thing. and resolve the merge conflict.. |
60ba520 to
5256aa3
Compare
|
Sorry for the delay. Rebased onto main (the conflict was just the include list, since main dropped |
dmcppcheck
left a comment
There was a problem hiding this comment.
AI review
I found no new problems. When the +N range is too large for an int, parseRange now catches std::out_of_range and returns 0, so the comment is treated like any other invalid range. When the range fits in an int but line + N would overflow, lineEnd is capped at INT_MAX before the addition happens. Block matching only compares line numbers against lineEnd (lib/suppressions.cpp:482 and :732), so capping it at INT_MAX does no harm. The new tests cover both cases.
Earlier comments
| # | Comment | By | Where | Status |
|---|---|---|---|---|
| 1 | PR should have a trac ticket and the title should reference it | @dmcppcheck | general | ✅ Fixed |
| 2 | Small formatting fix needed and merge conflict to resolve | @danmar | general | ✅ Fixed |
Testing
- Built
cppcheckandtestrunnerin/work/pr; the build succeeded. ./testrunner TestSuppressionspassed with 0 failures.- I ran two inputs through the PR's cppcheck with
--inline-suppr --addon=misra. Both exited with code 0 and printed nothing, so there was no crash or abort:printf 'int x;\n/* polyspace +99999999999 MISRA2012:8.4 */\nint y;\n' > b.c, the case from the description.- The same file with
+2147483647.
- I couldn't run the premium options: this build rejects
--premium=misra-c-2012with "unrecognized command line option". - I didn't build
base/and didn't run a sanitizer build, so I haven't seen the crash or the UBSan overflow on main for myself.
Automated review of 5256aa3 by Claude. The pull request was built and tested locally.
polyspace::Parser::parseRange reads the +N range of a Polyspace comment with std::stoi and only catches std::invalid_argument, so a source file containing
/* polyspace +99999999999 MISRA2012:8.4 */throws std::out_of_range past CppCheck::checkFile and aborts cppcheck when it runs with --inline-suppr and the misra addon or a premium MISRA/CERT option. A range that does fit, such as +2147483647 on line 2, instead overflowsline + rangeValuein Parser::parse (UBSan: signed integer overflow) and leaves a negative lineEnd. An out-of-range number is now treated like any other invalid range, and lineEnd is clamped to INT_MAX instead of wrapping, so valid ranges are unchanged. The new asserts in polyspaceParseRange and polyspaceRange fail on main, and the full testrunner passes in an ASan/UBSan build. There is no Trac ticket for this yet; I can update the title once one exists.