Skip to content

Commit b118817

Browse files
authored
Add files via upload
1 parent f5008d3 commit b118817

File tree

3 files changed

+50
-0
lines changed

3 files changed

+50
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
| test.cpp:7:6:7:15 | ... \|\| ... | Logical and has a higher priority. |
2+
| test.cpp:14:6:14:14 | ... \|\| ... | Binary operations has higher priority. |
3+
| test.cpp:18:6:18:14 | ... \|\| ... | Binary operations has higher priority. |
4+
| test.cpp:23:6:23:13 | ... \| ... | Expression ranges do not match operation precedence. |
5+
| test.cpp:27:6:27:13 | ... ^ ... | Expression ranges do not match operation precedence. |
6+
| test.cpp:32:6:32:13 | ... \| ... | Expression ranges do not match operation precedence. |
7+
| test.cpp:37:6:37:13 | ... \| ... | specify the priority with parentheses. |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
experimental/Security/CWE/CWE-783/OperatorPrecedenceLogicErrorWhenUseBitwiseOrLogicalOperations.ql
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
void testFunction()
2+
{
3+
int i1,i2,i3;
4+
bool b1,b2,b3;
5+
char c1;
6+
7+
if(b1||b2&&b3) //BAD
8+
return;
9+
if((b1||b2)&&b3) //GOOD
10+
return;
11+
if(b1||(b2&&b3)) //GOOD
12+
return;
13+
14+
if(b1||b2&i1) //BAD
15+
return;
16+
if((b1||b2)&i1) //GOOD
17+
return;
18+
if(b1||b2|i1) //BAD
19+
return;
20+
if((b1||b2)|i1) //GOOD
21+
return;
22+
23+
if(i1|i2&c1) //BAD
24+
return;
25+
if((i1|i2)&i3) //GOOD
26+
return;
27+
if(i1^i2&c1) //BAD
28+
return;
29+
if((i1^i2)&i3) //GOOD
30+
return;
31+
32+
if(i1|i2^c1) //BAD
33+
return;
34+
if((i1|i2)^i3) //GOOD
35+
return;
36+
37+
if(b1|b2^b3) //BAD
38+
return;
39+
if((b1|b2)^b3) //GOOD
40+
return;
41+
42+
}

0 commit comments

Comments
 (0)