Skip to content

fix polyspace +N range overflow in inline suppressions - #8956

Open
Nussu06 wants to merge 1 commit into
cppcheck-opensource:mainfrom
Nussu06:polyspace-range-overflow
Open

Nussu06 wants to merge 1 commit into
cppcheck-opensource:mainfrom
Nussu06:polyspace-range-overflow

Conversation

@Nussu06

@Nussu06 Nussu06 commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

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 overflows line + rangeValue in 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant