Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bufferoverrun Analysis - small fixes and improvements #1736

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions infer/src/bufferoverrun/bufferOverrunProofObligations.ml
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,10 @@ module ArrayAccessCondition = struct
Bound.is_not_infty (ItvPure.ub real_idx) && Bound.le (ItvPure.ub size) (ItvPure.ub real_idx)
then {report_issue_type= Issue IssueType.buffer_overrun_l2; propagate= false}
(* symbolic il >= sl, probably an error *)
else if
Bound.is_infty (ItvPure.ub real_idx) && Bound.is_not_infty (ItvPure.ub size)
then {report_issue_type= Issue IssueType.buffer_overrun_l3; propagate= false}
(* su < iu = +oo, probably an error *)
Comment on lines +350 to +353
Copy link
Contributor

@skcho skcho Feb 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

However, this error was missed by buffer overrun checker.

a.c:4: error: Buffer Overrun L4
  Offset: [0, +oo] Size: 2.
  2. void foo() {
  3. int a[2];
  4. for(int i=0; a[i]; i++) {}
                  ^
  5. }

For the example case, it reports L4 issue as above. The reason you did not see the issue is that it suppresses the issue types that are likely to be false positive, e.g. offset or size interval includes an infinity bound like above.

let buffer_overrun_l4 =
register ~enabled:false ~id:"BUFFER_OVERRUN_L4" Error BufferOverrunChecker
~user_documentation:"See [BUFFER_OVERRUN_L1](#buffer_overrun_l1)"

Note that ~enabled:false is given when defining the L4 issue type.

To enable all issue types, you can pass --no-filtering option, or --enable-issue-type to enable each of them.

else if
Bound.is_symbolic (ItvPure.lb real_idx) && Bound.le (ItvPure.lb size) (ItvPure.lb real_idx)
then {report_issue_type= Issue IssueType.buffer_overrun_s2; propagate= true}
Expand Down