File tree Expand file tree Collapse file tree
cpp/ql/test/experimental/query-tests/Security/CWE/CWE-190/IfStatementAdditionOverflow Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -8,12 +8,12 @@ void test()
88 int a = getAnInt ();
99 int b = getAnInt ();
1010 int c = getAnInt ();
11- int x = getAnInt ();
11+ int x = getAnInt ();
1212 int y = getAnInt ();
13- int d = getADouble ();
14- int a1 = getAnUnsignedShort ();
15- int b1 = getAnUnsignedShort ();
16- int c1 = getAnUnsignedShort ();
13+ double d = getADouble ();
14+ unsigned short a1 = getAnUnsignedShort ();
15+ unsigned short b1 = getAnUnsignedShort ();
16+ unsigned short c1 = getAnUnsignedShort ();
1717
1818 if (a+b>c) a = c-b; // BAD
1919 if (a+b>c) { a = c-b; } // BAD
@@ -51,7 +51,7 @@ void test()
5151 if (c<=b+a) a = c-b; // BAD
5252 if (c<=b+a) { a = c-b; } // BAD
5353
54- if (a+b>d) a = d-b; // GOOD
54+ if (a+b>d) a = d-b; // BAD
5555 if (a+(-x)>c) a = c-(-y); // GOOD
5656 if (a+b>c) { b++; a = c-b; } // GOOD
5757 if (a+d>c) a = c-d; // GOOD
You can’t perform that action at this time.
0 commit comments