mirror of
https://github.com/github/codeql.git
synced 2026-04-26 09:15:12 +02:00
Merge pull request #17678 from MathiasVP/modernize-unclear-array-index-validation
C++: Modernize `cpp/unclear-array-index-validation`
This commit is contained in:
@@ -2,29 +2,36 @@ edges
|
||||
| test1.c:7:26:7:29 | **argv | test1.c:8:11:8:14 | call to atoi | provenance | TaintFunction |
|
||||
| test1.c:8:11:8:14 | call to atoi | test1.c:9:9:9:9 | i | provenance | |
|
||||
| test1.c:8:11:8:14 | call to atoi | test1.c:11:9:11:9 | i | provenance | |
|
||||
| test1.c:8:11:8:14 | call to atoi | test1.c:12:9:12:9 | i | provenance | |
|
||||
| test1.c:8:11:8:14 | call to atoi | test1.c:13:9:13:9 | i | provenance | |
|
||||
| test1.c:9:9:9:9 | i | test1.c:16:16:16:16 | i | provenance | |
|
||||
| test1.c:11:9:11:9 | i | test1.c:32:16:32:16 | i | provenance | |
|
||||
| test1.c:13:9:13:9 | i | test1.c:48:16:48:16 | i | provenance | |
|
||||
| test1.c:16:16:16:16 | i | test1.c:18:16:18:16 | i | provenance | |
|
||||
| test1.c:32:16:32:16 | i | test1.c:33:11:33:11 | i | provenance | |
|
||||
| test1.c:48:16:48:16 | i | test1.c:51:3:51:7 | ... = ... | provenance | |
|
||||
| test1.c:51:3:51:7 | ... = ... | test1.c:53:15:53:15 | j | provenance | |
|
||||
| test1.c:9:9:9:9 | i | test1.c:18:16:18:16 | i | provenance | |
|
||||
| test1.c:11:9:11:9 | i | test1.c:34:16:34:16 | i | provenance | |
|
||||
| test1.c:12:9:12:9 | i | test1.c:42:16:42:16 | i | provenance | |
|
||||
| test1.c:13:9:13:9 | i | test1.c:50:16:50:16 | i | provenance | |
|
||||
| test1.c:18:16:18:16 | i | test1.c:20:16:20:16 | i | provenance | |
|
||||
| test1.c:34:16:34:16 | i | test1.c:35:11:35:11 | i | provenance | |
|
||||
| test1.c:42:16:42:16 | i | test1.c:43:11:43:11 | i | provenance | |
|
||||
| test1.c:50:16:50:16 | i | test1.c:53:3:53:7 | ... = ... | provenance | |
|
||||
| test1.c:53:3:53:7 | ... = ... | test1.c:55:15:55:15 | j | provenance | |
|
||||
nodes
|
||||
| test1.c:7:26:7:29 | **argv | semmle.label | **argv |
|
||||
| test1.c:8:11:8:14 | call to atoi | semmle.label | call to atoi |
|
||||
| test1.c:9:9:9:9 | i | semmle.label | i |
|
||||
| test1.c:11:9:11:9 | i | semmle.label | i |
|
||||
| test1.c:12:9:12:9 | i | semmle.label | i |
|
||||
| test1.c:13:9:13:9 | i | semmle.label | i |
|
||||
| test1.c:16:16:16:16 | i | semmle.label | i |
|
||||
| test1.c:18:16:18:16 | i | semmle.label | i |
|
||||
| test1.c:32:16:32:16 | i | semmle.label | i |
|
||||
| test1.c:33:11:33:11 | i | semmle.label | i |
|
||||
| test1.c:48:16:48:16 | i | semmle.label | i |
|
||||
| test1.c:51:3:51:7 | ... = ... | semmle.label | ... = ... |
|
||||
| test1.c:53:15:53:15 | j | semmle.label | j |
|
||||
| test1.c:20:16:20:16 | i | semmle.label | i |
|
||||
| test1.c:34:16:34:16 | i | semmle.label | i |
|
||||
| test1.c:35:11:35:11 | i | semmle.label | i |
|
||||
| test1.c:42:16:42:16 | i | semmle.label | i |
|
||||
| test1.c:43:11:43:11 | i | semmle.label | i |
|
||||
| test1.c:50:16:50:16 | i | semmle.label | i |
|
||||
| test1.c:53:3:53:7 | ... = ... | semmle.label | ... = ... |
|
||||
| test1.c:55:15:55:15 | j | semmle.label | j |
|
||||
subpaths
|
||||
#select
|
||||
| test1.c:18:16:18:16 | i | test1.c:7:26:7:29 | **argv | test1.c:18:16:18:16 | i | An array indexing expression depends on $@ that might be outside the bounds of the array. | test1.c:7:26:7:29 | **argv | a command-line argument |
|
||||
| test1.c:33:11:33:11 | i | test1.c:7:26:7:29 | **argv | test1.c:33:11:33:11 | i | An array indexing expression depends on $@ that might be outside the bounds of the array. | test1.c:7:26:7:29 | **argv | a command-line argument |
|
||||
| test1.c:53:15:53:15 | j | test1.c:7:26:7:29 | **argv | test1.c:53:15:53:15 | j | An array indexing expression depends on $@ that might be outside the bounds of the array. | test1.c:7:26:7:29 | **argv | a command-line argument |
|
||||
| test1.c:20:16:20:16 | i | test1.c:7:26:7:29 | **argv | test1.c:20:16:20:16 | i | An array indexing expression depends on $@ that might be outside the bounds of the array. | test1.c:7:26:7:29 | **argv | a command-line argument |
|
||||
| test1.c:35:11:35:11 | i | test1.c:7:26:7:29 | **argv | test1.c:35:11:35:11 | i | An array indexing expression depends on $@ that might be outside the bounds of the array. | test1.c:7:26:7:29 | **argv | a command-line argument |
|
||||
| test1.c:43:11:43:11 | i | test1.c:7:26:7:29 | **argv | test1.c:43:11:43:11 | i | An array indexing expression depends on $@ that might be outside the bounds of the array. | test1.c:7:26:7:29 | **argv | a command-line argument |
|
||||
| test1.c:55:15:55:15 | j | test1.c:7:26:7:29 | **argv | test1.c:55:15:55:15 | j | An array indexing expression depends on $@ that might be outside the bounds of the array. | test1.c:7:26:7:29 | **argv | a command-line argument |
|
||||
|
||||
@@ -11,6 +11,8 @@ int main(int argc, char *argv[]) {
|
||||
test3(i);
|
||||
test4(i);
|
||||
test5(i);
|
||||
test6(i);
|
||||
test7(argv[1]);
|
||||
}
|
||||
|
||||
void test1(int i) {
|
||||
@@ -38,7 +40,7 @@ void test3(int i) {
|
||||
}
|
||||
|
||||
void test4(int i) {
|
||||
myArray[i] = 0; // BAD: i has not been validated [NOT REPORTED]
|
||||
myArray[i] = 0; // BAD: i has not been validated
|
||||
|
||||
if ((i < 0) || (i >= 10)) return;
|
||||
|
||||
@@ -52,3 +54,26 @@ void test5(int i) {
|
||||
|
||||
j = myArray[j]; // BAD: j has not been validated
|
||||
}
|
||||
|
||||
extern int myTable[256];
|
||||
|
||||
void test6(int i) {
|
||||
unsigned char s = i;
|
||||
|
||||
myTable[s] = 0; // GOOD: Input is small [FALSE POSITIVE]
|
||||
}
|
||||
|
||||
typedef void FILE;
|
||||
#define EOF (-1)
|
||||
|
||||
int getc(FILE*);
|
||||
|
||||
extern int myMaxCharTable[256];
|
||||
|
||||
void test7(FILE* fp) {
|
||||
int ch;
|
||||
while ((ch = getc(fp)) != EOF) {
|
||||
myMaxCharTable[ch] = 0; // GOOD
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user