Merge branch 'main' into aeisenberg/pack/cpp

This commit is contained in:
Andrew Eisenberg
2021-08-17 15:28:47 -07:00
273 changed files with 9850 additions and 3110 deletions

View File

@@ -163,4 +163,5 @@ where
or
eots.dangerousCrementChanges()
)
select eots, "This expression may have undefined behavior."
select eots,
"This expression may have undefined behavior, because the order of evaluation is not specified."

View File

@@ -1,3 +1,3 @@
| test.c:13:10:13:21 | call to tmpFunction1 | This expression may have undefined behavior. |
| test.c:13:30:13:41 | call to tmpFunction2 | This expression may have undefined behavior. |
| test.c:16:15:16:20 | ... ++ | This expression may have undefined behavior. |
| test.c:13:10:13:21 | call to tmpFunction1 | This expression may have undefined behavior, because the order of evaluation is not specified. |
| test.c:13:30:13:41 | call to tmpFunction2 | This expression may have undefined behavior, because the order of evaluation is not specified. |
| test.c:16:15:16:20 | ... ++ | This expression may have undefined behavior, because the order of evaluation is not specified. |

View File

@@ -0,0 +1,39 @@
typedef unsigned char uint8_t;
#define SIZE (32)
void test_buffer_overrun_in_for_loop()
{
uint8_t data[SIZE] = {0};
for (int x = 0; x < SIZE * 2; x++) {
data[x] = 0x41; // BAD [NOT DETECTED]
}
}
void test_buffer_overrun_in_while_loop_using_pointer_arithmetic()
{
uint8_t data[SIZE] = {0};
int offset = 0;
while (offset < SIZE * 2) {
*(data + offset) = 0x41; // BAD [NOT DETECTED]
offset++;
}
}
void test_buffer_overrun_in_while_loop_using_array_indexing()
{
uint8_t data[SIZE] = {0};
int offset = 0;
while (offset < SIZE * 2) {
data[offset] = 0x41; // BAD [NOT DETECTED]
offset++;
}
}
int main(int argc, char *argv[])
{
test_buffer_overrun_in_for_loop();
test_buffer_overrun_in_while_loop_using_pointer_arithmetic();
test_buffer_overrun_in_while_loop_using_array_indexing();
return 0;
}

View File

@@ -114,7 +114,7 @@ void test6(bool cond)
c = 100;
buffer[c] = 'x'; // BAD: over-write [NOT DETECTED]
ch = buffer[c]; // BAD: under-read [NOT DETECTED]
ch = buffer[c]; // BAD: over-read [NOT DETECTED]
d = 0;
d = 1000;