Missing default case in switch statement
ID |
c.miscellaneous.missing_default_in_switch |
Severity |
low |
Resource |
Miscellaneous |
Language |
C / C++ |
Description
The code does not have a default case in an expression with multiple conditions, such as a switch statement.
Rationale
The code does not have a default case in an expression with multiple conditions, such as a switch statement.
The following code illustrates a vulnerable pattern detected by this rule:
int result = security_check(data);
// VULNERABLE: Missing default case in switch statement
switch (result)
{
case FAIL:
printf("Security check failed!\n");
exit(1);
break;
case PASS:
printf("Security check passed.\n");
break;
}