Skip to content

Commit 03bd7d7

Browse files
committed
C++: Update test results from OverflowStatic
1 parent e0921ac commit 03bd7d7

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

cpp/ql/test/query-tests/Critical/OverflowStatic/OverflowStatic.expected

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,10 @@
55
| test2.c:33:26:33:27 | 46 | Potential buffer-overflow: 'buffer' has size 40 not 46. |
66
| test2.c:34:22:34:23 | 47 | Potential buffer-overflow: 'buffer' has size 40 not 47. |
77
| test2.c:35:23:35:24 | 48 | Potential buffer-overflow: 'buffer' has size 40 not 48. |
8-
| test.c:14:9:14:13 | access to array | Potential buffer-overflow: 'xs' has size 5 but 'xs[5]' is accessed here. |
9-
| test.c:15:9:15:13 | access to array | Potential buffer-overflow: 'xs' has size 5 but 'xs[6]' is accessed here. |
10-
| test.c:20:9:20:18 | access to array | Potential buffer-overflow: 'ys' has size 5 but 'ys[5]' is accessed here. |
11-
| test.c:21:9:21:18 | access to array | Potential buffer-overflow: 'ys' has size 5 but 'ys[6]' is accessed here. |
12-
| test.c:47:3:47:18 | access to array | Potential buffer-overflow: 'ptr' has size 8 but 'ptr[8]' is accessed here. |
13-
| test.c:54:3:54:26 | access to array | Potential buffer-overflow: 'ptr' has size 8 but 'ptr[8]' is accessed here. |
14-
| test.c:61:3:61:18 | access to array | Potential buffer-overflow: 'ptr' has size 8 but 'ptr[8]' is accessed here. |
15-
| test.c:72:3:72:11 | access to array | Potential buffer-overflow: 'buf' has size 1 but 'buf[1]' is accessed here. |
8+
| test.c:14:9:14:13 | access to array | Potential buffer-overflow: 'xs' has size 5 but 'xs[5]' may be accessed here. |
9+
| test.c:15:9:15:13 | access to array | Potential buffer-overflow: 'xs' has size 5 but 'xs[6]' may be accessed here. |
10+
| test.c:20:9:20:18 | access to array | Potential buffer-overflow: 'ys' has size 5 but 'ys[5]' may be accessed here. |
11+
| test.c:21:9:21:18 | access to array | Potential buffer-overflow: 'ys' has size 5 but 'ys[6]' may be accessed here. |
1612
| test.cpp:19:3:19:12 | access to array | Potential buffer-overflow: counter 'i' <= 3 but 'buffer1' has 3 elements. |
1713
| test.cpp:20:3:20:12 | access to array | Potential buffer-overflow: counter 'i' <= 3 but 'buffer2' has 3 elements. |
1814
| test.cpp:24:27:24:27 | 4 | Potential buffer-overflow: 'buffer1' has size 3 not 4. |

cpp/ql/test/query-tests/Critical/OverflowStatic/test.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,21 +44,21 @@ void union_test() {
4444
union u u;
4545
u.ptr[0] = 0; // GOOD
4646
u.ptr[sizeof(u)-1] = 0; // GOOD
47-
u.ptr[sizeof(u)] = 0; // BAD
47+
u.ptr[sizeof(u)] = 0; // BAD [NOT DETECTED]
4848
}
4949

5050
void test_struct_union() {
5151
struct { union u u; } v;
5252
v.u.ptr[0] = 0; // GOOD
5353
v.u.ptr[sizeof(union u)-1] = 0; // GOOD
54-
v.u.ptr[sizeof(union u)] = 0; // BAD
54+
v.u.ptr[sizeof(union u)] = 0; // BAD [NOT DETECTED]
5555
}
5656

5757
void union_test2() {
5858
union { char ptr[1]; unsigned long value; } u;
5959
u.ptr[0] = 0; // GOOD
6060
u.ptr[sizeof(u)-1] = 0; // GOOD
61-
u.ptr[sizeof(u)] = 0; // BAD
61+
u.ptr[sizeof(u)] = 0; // BAD [NOT DETECTED]
6262
}
6363

6464
typedef struct {
@@ -69,5 +69,5 @@ typedef struct {
6969
void test_alloc() {
7070
// Special case of taking sizeof without any addition or multiplications
7171
var_buf *b = malloc(sizeof(var_buf));
72-
b->buf[1] = 0; // BAD
72+
b->buf[1] = 0; // BAD [NOT DETECTED]
7373
}

0 commit comments

Comments
 (0)