mirror of
https://github.com/github/codeql.git
synced 2026-05-04 21:25:44 +02:00
Add files via upload
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
| test.c:14:3:22:3 | switch (...) ... | Possibly erroneous label name. |
|
||||
| test.c:24:3:32:3 | switch (...) ... | Code before case will not be executed. |
|
||||
| test.c:36:3:45:3 | switch (...) ... | The range of condition values is less than the selection. |
|
||||
| test.c:48:3:53:3 | switch (...) ... | The range of condition values is wider than the choices. |
|
||||
@@ -0,0 +1 @@
|
||||
experimental/Security/CWE/CWE-561/FindIncorrectlyUsedSwitch.ql
|
||||
@@ -0,0 +1,55 @@
|
||||
void testFunction()
|
||||
{
|
||||
char c1;
|
||||
|
||||
switch(c1){ // GOOD
|
||||
case 12:
|
||||
break;
|
||||
case 10:
|
||||
break;
|
||||
case 9:
|
||||
break;
|
||||
}
|
||||
|
||||
switch(c1){ // BAD
|
||||
case 12:
|
||||
break;
|
||||
case 10:
|
||||
break;
|
||||
case 9:
|
||||
break;
|
||||
dafault:
|
||||
}
|
||||
|
||||
switch(c1){ // BAD
|
||||
c1=c1*2;
|
||||
case 12:
|
||||
break;
|
||||
case 10:
|
||||
break;
|
||||
case 9:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if((c1<6)&&(c1>0))
|
||||
switch(c1){ // BAD
|
||||
case 7:
|
||||
break;
|
||||
case 5:
|
||||
break;
|
||||
case 3:
|
||||
break;
|
||||
case 1:
|
||||
break;
|
||||
}
|
||||
|
||||
if((c1<6)&&(c1>0))
|
||||
switch(c1){ // BAD
|
||||
case 3:
|
||||
break;
|
||||
case 1:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user