Infer effective length for single-blob arrays#2018
Conversation
|
This seems a bit roundabout to try to recover the length after the fact if it's 1. Currently it's being set as 1 at Line 2785 in 729eb71 I don't really know why it's 1 there though, instead of the actual length given by the argument to |
|
I think this should be fixed together with #1766, if we are already touching this part. |
|
After spending time investigating the related issues and trying a few alternative approaches, I agree that this PR proposal is only a hacky remedy for one part of a broader problem rather than the right direction. A proper fix would require rethinking how |
This PR fixes array out-of-bounds handling for dynamically allocated arrays whose abstract array length is initially represented as a single blob. This was found using the dashboard comparison between Goblint and Mopsa and was exposed by the SV-COMP task
memsafety-cve/libredwg.i.Goblint output spurious error messages for the program:
With the offending code being:
where
sizewas a constant of 50 during the function call, but Goblint'sarray_oob_checkconsidered the array size as 1.The change computes an effective array length from the blob size divided by the element size, then uses that length before indexed reads and writes. This prevents valid accesses into calloc-allocated arrays from being treated imprecisely.
calloc-allocatedunsigned chararray.effective_array_lengthto derive array length from blob size when possible.