Skip to content

Commit 4f2703e

Browse files
authored
Add files via upload
1 parent bdab785 commit 4f2703e

File tree

3 files changed

+60
-0
lines changed

3 files changed

+60
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
| test.c:14:3:22:3 | switch (...) ... | Possibly erroneous label name. |
2+
| test.c:24:3:32:3 | switch (...) ... | Code before case will not be executed. |
3+
| test.c:36:3:45:3 | switch (...) ... | The range of condition values is less than the selection. |
4+
| test.c:48:3:53:3 | switch (...) ... | The range of condition values is wider than the choices. |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
experimental/Security/CWE/CWE-561/FindIncorrectlyUsedSwitch.ql
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
void testFunction()
2+
{
3+
char c1;
4+
5+
switch(c1){ // GOOD
6+
case 12:
7+
break;
8+
case 10:
9+
break;
10+
case 9:
11+
break;
12+
}
13+
14+
switch(c1){ // BAD
15+
case 12:
16+
break;
17+
case 10:
18+
break;
19+
case 9:
20+
break;
21+
dafault:
22+
}
23+
24+
switch(c1){ // BAD
25+
c1=c1*2;
26+
case 12:
27+
break;
28+
case 10:
29+
break;
30+
case 9:
31+
break;
32+
}
33+
34+
35+
if((c1<6)&&(c1>0))
36+
switch(c1){ // BAD
37+
case 7:
38+
break;
39+
case 5:
40+
break;
41+
case 3:
42+
break;
43+
case 1:
44+
break;
45+
}
46+
47+
if((c1<6)&&(c1>0))
48+
switch(c1){ // BAD
49+
case 3:
50+
break;
51+
case 1:
52+
break;
53+
}
54+
55+
}

0 commit comments

Comments
 (0)