Title: Add check: invalidPointerOverlapTest for unsafe pointer overflow comparison by tmleman · Pull Request #8620 · cppcheck-opensource/cppcheck · GitHub
Open Graph Title: Add check: invalidPointerOverlapTest for unsafe pointer overflow comparison by tmleman · Pull Request #8620 · cppcheck-opensource/cppcheck
X Title: Add check: invalidPointerOverlapTest for unsafe pointer overflow comparison by tmleman · Pull Request #8620 · cppcheck-opensource/cppcheck
Description: Add a new inconclusive warning that detects the pointer overlap idiom p1 >= p2 && p1 < p2 + n (or its mirror / cast variants) where p1 and p2 are distinct pointers and n is an unsigned offset, e.g. the memcpy_s overlap check '(dest >= src && dest < src + count) || ...'. The 'p1 < p2 + n' clause assumes 'p2 + n' does not overflow past the end of the object. If n is large enough that 'p2 + n' wraps (UB), some mainstream compilers assume the wrap cannot happen and fold the comparison, silently dropping the check. The remedy in user code is to cast the pointers to uintptr_t and compare in integer space, with an explicit overflow guard. To avoid false positives, the warning only fires when the comparison is paired (via &&) with another comparison of the same two pointers, which identifies the overlap idiom; plain bounds checks like 'p < buf + len' and room checks like 'cur + need <= limit' are not flagged. The check is gated behind --enable=inconclusive. The same-pointer case 'p < p + n' is left to the existing invalidTestForOverflow check. This pattern was found in a real memcpy_s overlap check via fuzzing with UndefinedBehaviorSanitizer; the check is added so similar issues can be caught statically in the future.
Open Graph Description: Add a new inconclusive warning that detects the pointer overlap idiom p1 >= p2 && p1 < p2 + n (or its mirror / cast variants) where p1 and p2 are distinct pointers and n is an...
X Description: Add a new inconclusive warning that detects the pointer overlap idiom p1 >= p2 && p1 < p2 + n (or its mirror / cast variants) where p1 and p2 are distinct poin...
Opengraph URL: https://github.com/cppcheck-opensource/cppcheck/pull/8620
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:efb8e481-7112-de0c-dbc3-ef7cec6cc324 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | A3A0:6D260:65B30F:8A1754:6A4D42A0 |
| html-safe-nonce | 21857af81fdda9653aac8fbbca5580464795f9f095a38402d710193e44db7fec |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBM0EwOjZEMjYwOjY1QjMwRjo4QTE3NTQ6NkE0RDQyQTAiLCJ2aXNpdG9yX2lkIjoiNjE1NDk5NzI2NzIyMjU3NzgyNCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 81556f641a71fc023037a42a1ce32309db51e76e6fdec71ff0e31636f6548443 |
| hovercard-subject-tag | pull_request:3790301878 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/cppcheck-opensource/cppcheck/pull/8620/files |
| twitter:image | https://avatars.githubusercontent.com/u/93920284?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/93920284?s=400&v=4 |
| og:image:alt | Add a new inconclusive warning that detects the pointer overlap idiom p1 >= p2 && p1 < p2 + n (or its mirror / cast variants) where p1 and p2 are distinct pointers and n is an... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 92571a8944142227b7e19cd10918b1ddd06e5066c1ad5bc7e4769cf6140a87e6 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/cppcheck-opensource/cppcheck git https://github.com/cppcheck-opensource/cppcheck.git |
| octolytics-dimension-user_id | 278097703 |
| octolytics-dimension-user_login | cppcheck-opensource |
| octolytics-dimension-repository_id | 143131 |
| octolytics-dimension-repository_nwo | cppcheck-opensource/cppcheck |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 143131 |
| octolytics-dimension-repository_network_root_nwo | cppcheck-opensource/cppcheck |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 56fc8347865a14e2ec811533d68f929cf4e0ec19 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width