Skip to content

Commit c3d9ea1

Browse files
committed
C++: Add FP.
1 parent afb5e4f commit c3d9ea1

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

cpp/ql/test/query-tests/Security/CWE/CWE-129/semmle/ImproperArrayIndexValidation/ImproperArrayIndexValidation.expected

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,27 @@ edges
44
| test1.c:8:11:8:14 | call to atoi | test1.c:11:9:11:9 | i | provenance | |
55
| test1.c:8:11:8:14 | call to atoi | test1.c:12:9:12:9 | i | provenance | |
66
| test1.c:8:11:8:14 | call to atoi | test1.c:13:9:13:9 | i | provenance | |
7+
| test1.c:8:11:8:14 | call to atoi | test1.c:14:9:14:9 | i | provenance | |
78
| test1.c:9:9:9:9 | i | test1.c:17:16:17:16 | i | provenance | |
89
| test1.c:11:9:11:9 | i | test1.c:33:16:33:16 | i | provenance | |
910
| test1.c:12:9:12:9 | i | test1.c:41:16:41:16 | i | provenance | |
1011
| test1.c:13:9:13:9 | i | test1.c:49:16:49:16 | i | provenance | |
12+
| test1.c:14:9:14:9 | i | test1.c:59:16:59:16 | i | provenance | |
1113
| test1.c:17:16:17:16 | i | test1.c:19:16:19:16 | i | provenance | |
1214
| test1.c:33:16:33:16 | i | test1.c:34:11:34:11 | i | provenance | |
1315
| test1.c:41:16:41:16 | i | test1.c:42:11:42:11 | i | provenance | |
1416
| test1.c:49:16:49:16 | i | test1.c:52:3:52:7 | ... = ... | provenance | |
1517
| test1.c:52:3:52:7 | ... = ... | test1.c:54:15:54:15 | j | provenance | |
18+
| test1.c:59:16:59:16 | i | test1.c:60:21:60:21 | i | provenance | |
19+
| test1.c:60:21:60:21 | i | test1.c:62:11:62:11 | s | provenance | |
1620
nodes
1721
| test1.c:7:26:7:29 | **argv | semmle.label | **argv |
1822
| test1.c:8:11:8:14 | call to atoi | semmle.label | call to atoi |
1923
| test1.c:9:9:9:9 | i | semmle.label | i |
2024
| test1.c:11:9:11:9 | i | semmle.label | i |
2125
| test1.c:12:9:12:9 | i | semmle.label | i |
2226
| test1.c:13:9:13:9 | i | semmle.label | i |
27+
| test1.c:14:9:14:9 | i | semmle.label | i |
2328
| test1.c:17:16:17:16 | i | semmle.label | i |
2429
| test1.c:19:16:19:16 | i | semmle.label | i |
2530
| test1.c:33:16:33:16 | i | semmle.label | i |
@@ -29,9 +34,13 @@ nodes
2934
| test1.c:49:16:49:16 | i | semmle.label | i |
3035
| test1.c:52:3:52:7 | ... = ... | semmle.label | ... = ... |
3136
| test1.c:54:15:54:15 | j | semmle.label | j |
37+
| test1.c:59:16:59:16 | i | semmle.label | i |
38+
| test1.c:60:21:60:21 | i | semmle.label | i |
39+
| test1.c:62:11:62:11 | s | semmle.label | s |
3240
subpaths
3341
#select
3442
| test1.c:19:16:19:16 | i | test1.c:7:26:7:29 | **argv | test1.c:19:16:19: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 |
3543
| test1.c:34:11:34:11 | i | test1.c:7:26:7:29 | **argv | test1.c:34:11:34: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 |
3644
| test1.c:42:11:42:11 | i | test1.c:7:26:7:29 | **argv | test1.c:42:11:42: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 |
3745
| test1.c:54:15:54:15 | j | test1.c:7:26:7:29 | **argv | test1.c:54:15:54: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 |
46+
| test1.c:62:11:62:11 | s | test1.c:7:26:7:29 | **argv | test1.c:62:11:62:11 | s | 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 |

cpp/ql/test/query-tests/Security/CWE/CWE-129/semmle/ImproperArrayIndexValidation/test1.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ void test5(int i) {
5454
j = myArray[j]; // BAD: j has not been validated
5555
}
5656

57+
extern int myTable[256];
58+
5759
void test6(int i) {
60+
unsigned char s = i;
5861

62+
myTable[s] = 0; // GOOD: Input is small [FALSE POSITIVE]
5963
}

0 commit comments

Comments
 (0)