mirror of
https://github.com/github/codeql.git
synced 2026-04-30 19:26:02 +02:00
Merge pull request #5600 from ihsinme/ihsinme-patch-258
CPP: Add query for CWE-691 Insufficient Control Flow Management When Using Bit Operations
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
| test.c:8:6:8:51 | ... & ... | This bitwise operation appears in a context where a Boolean operation is expected. |
|
||||
| test.c:10:6:10:30 | ... & ... | This bitwise operation appears in a context where a Boolean operation is expected. |
|
||||
@@ -0,0 +1 @@
|
||||
experimental/Security/CWE/CWE-691/InsufficientControlFlowManagementWhenUsingBitOperations.ql
|
||||
@@ -0,0 +1,28 @@
|
||||
int tmpFunction(){
|
||||
return 5;
|
||||
}
|
||||
void workFunction_0(char *s) {
|
||||
int intSize;
|
||||
char buf[80];
|
||||
if(intSize>0 && intSize<80 && memset(buf,0,intSize)) return; // GOOD
|
||||
if(intSize>0 & intSize<80 & memset(buf,0,intSize)) return; // BAD
|
||||
if(intSize>0 && tmpFunction()) return;
|
||||
if(intSize<0 & tmpFunction()) return; // BAD
|
||||
}
|
||||
void workFunction_1(char *s) {
|
||||
int intA,intB;
|
||||
|
||||
if(intA + intB) return; // BAD [NOT DETECTED]
|
||||
if(intA + intB>4) return; // GOOD
|
||||
if(intA>0 && (intA + intB)) return; // BAD [NOT DETECTED]
|
||||
while(intA>0)
|
||||
{
|
||||
if(intB - intA<10) break;
|
||||
intA--;
|
||||
}while(intA>0); // BAD [NOT DETECTED]
|
||||
while(intA>0)
|
||||
{
|
||||
if(intB - intA<10) break;
|
||||
intA--;
|
||||
} // GOOD
|
||||
}
|
||||
Reference in New Issue
Block a user