Fix 14934: detect out-of-bounds access to global new arrays - #8828
Fix 14934: detect out-of-bounds access to global new arrays#8828JeewoongKim wants to merge 1 commit into
Conversation
bc87761 to
d7d165a
Compare
|
Thanks for working on this. I'm not sure this approach is feasible though. |
Yes I agree, thanks for looking at Cppcheck.
I assume that is what the last test case with the I fear that the upside of this PR seems pretty small because it only targets main(). it could find problems in some small and simple synthetic test case more or less. more generic heuristics would be appreciated that could find simple bugs in all code. |
Global pointers initialized with
new[]did not get aBUFFER_SIZEvalue becausevalueFlowDynamicBufferSize()only handled allocations found inside function scopes.This change propagates the initial buffer size into
main(). The existing value-flow analysisinvalidate it after assignments or calls that may modify the global pointer.
Added regression tests for the reported out-of-bounds false negative, reassignment of the
global pointer, and an unknown function call that may modify it.