mirror of
https://github.com/github/codeql.git
synced 2026-04-30 03:05:15 +02:00
CPP: Add a test of AV Rule 164.
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
| test.c:3:2:3:9 | ... >> ... | AV Rule 164: The right-hand operand (here a value is -1) of this shift shall lie between 0 and 7. |
|
||||
| test.c:6:2:6:8 | ... >> ... | AV Rule 164: The right-hand operand (here a value is 8) of this shift shall lie between 0 and 7. |
|
||||
| test.c:8:2:8:9 | ... << ... | AV Rule 164: The right-hand operand (here a value is -1) of this shift shall lie between 0 and 7. |
|
||||
| test.c:11:2:11:8 | ... << ... | AV Rule 164: The right-hand operand (here a value is 8) of this shift shall lie between 0 and 7. |
|
||||
| test.c:18:2:18:9 | ... >> ... | AV Rule 164: The right-hand operand (here a value is -1) of this shift shall lie between 0 and 7. |
|
||||
| test.c:21:2:21:8 | ... >> ... | AV Rule 164: The right-hand operand (here a value is 8) of this shift shall lie between 0 and 7. |
|
||||
| test.c:23:2:23:25 | ... >> ... | AV Rule 164: The right-hand operand (here a value is -1) of this shift shall lie between 0 and 31. |
|
||||
@@ -0,0 +1 @@
|
||||
jsf/4.21 Operators/AV Rule 164.ql
|
||||
@@ -0,0 +1,28 @@
|
||||
|
||||
void f(unsigned char uc, signed char sc, int i) {
|
||||
uc >> -1; // BAD
|
||||
uc >> 0;
|
||||
uc >> 7;
|
||||
uc >> 8; // BAD
|
||||
|
||||
uc << -1; // BAD
|
||||
uc << 0;
|
||||
uc << 7;
|
||||
uc << 8; // BAD
|
||||
|
||||
uc >>= -1; // BAD [NOT DETECTED]
|
||||
uc >>= 0; // BAD [NOT DETECTED]
|
||||
uc >>= 7;
|
||||
uc >>= 8; // BAD [NOT DETECTED]
|
||||
|
||||
sc >> -1; // BAD
|
||||
sc >> 0;
|
||||
sc >> 7;
|
||||
sc >> 8; // BAD
|
||||
|
||||
((unsigned char)i) >> -1; // BAD
|
||||
((unsigned char)i) >> 0;
|
||||
((unsigned char)i) >> 7;
|
||||
((unsigned char)i) >> 8; // BAD [NOT DETECTED]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user