GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Merge pull request #6745 from andersfugmann/handle_overflow_for_upper… · CodingLi/codeql@06b36f7

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • cpp/ql
    • lib/semmle/code/cpp/rangeanalysis
      • SimpleRangeAnalysis.qll
    • test/library-tests/rangeanalysis/SimpleRangeAnalysis
      • lowerBound.expected
      • test.c
      • upperBound.expected
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎cpp/ql/lib/semmle/code/cpp/rangeanalysis/SimpleRangeAnalysis.qll‎

Copy file name to clipboardExpand all lines: cpp/ql/lib/semmle/code/cpp/rangeanalysis/SimpleRangeAnalysis.qll
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1549,7 +1549,8 @@ private float getGuardedUpperBound(VariableAccess guardedAccess) {
15491549
// that there is one predecessor, albeit somewhat conservative.
15501550
exists(unique(BasicBlock b | b = def.(BasicBlock).getAPredecessor())) and
15511551
guardedAccess = def.getAUse(v) and
1552-
result = max(float ub | upperBoundFromGuard(guard, guardVa, ub, branch))
1552+
result = max(float ub | upperBoundFromGuard(guard, guardVa, ub, branch)) and
1553+
not convertedExprMightOverflow(guard.getAChild+())
15531554
)
15541555
}
15551556

Collapse file

‎cpp/ql/test/library-tests/rangeanalysis/SimpleRangeAnalysis/lowerBound.expected‎

Copy file name to clipboardExpand all lines: cpp/ql/test/library-tests/rangeanalysis/SimpleRangeAnalysis/lowerBound.expected
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,10 @@
599599
| test.c:675:7:675:7 | y | -2147483648 |
600600
| test.c:684:7:684:7 | x | -2147483648 |
601601
| test.c:689:7:689:7 | x | -2147483648 |
602+
| test.c:696:8:696:8 | x | 2147483647 |
603+
| test.c:696:12:696:12 | y | 256 |
604+
| test.c:697:9:697:9 | x | 2147483647 |
605+
| test.c:698:9:698:9 | y | 256 |
602606
| test.cpp:10:7:10:7 | b | -2147483648 |
603607
| test.cpp:11:5:11:5 | x | -2147483648 |
604608
| test.cpp:13:10:13:10 | x | -2147483648 |
Collapse file

‎cpp/ql/test/library-tests/rangeanalysis/SimpleRangeAnalysis/test.c‎

Copy file name to clipboardExpand all lines: cpp/ql/test/library-tests/rangeanalysis/SimpleRangeAnalysis/test.c
+9Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -689,3 +689,12 @@ void test(int x) {
689689
out(x);
690690
goto label;
691691
}
692+
693+
void test_overflow() {
694+
const int x = 2147483647; // 2^31-1
695+
const int y = 256;
696+
if ((x + y) <= 512) {
697+
out(x);
698+
out(y);
699+
}
700+
}
Collapse file

‎cpp/ql/test/library-tests/rangeanalysis/SimpleRangeAnalysis/upperBound.expected‎

Copy file name to clipboardExpand all lines: cpp/ql/test/library-tests/rangeanalysis/SimpleRangeAnalysis/upperBound.expected
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,10 @@
599599
| test.c:675:7:675:7 | y | 2147483647 |
600600
| test.c:684:7:684:7 | x | 2147483647 |
601601
| test.c:689:7:689:7 | x | 15 |
602+
| test.c:696:8:696:8 | x | 2147483647 |
603+
| test.c:696:12:696:12 | y | 256 |
604+
| test.c:697:9:697:9 | x | 2147483647 |
605+
| test.c:698:9:698:9 | y | 256 |
602606
| test.cpp:10:7:10:7 | b | 2147483647 |
603607
| test.cpp:11:5:11:5 | x | 2147483647 |
604608
| test.cpp:13:10:13:10 | x | 2147483647 |

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.