Skip to content

Commit cc953c8

Browse files
committed
Added test case to demonstrate type error corrected in this branch.
1 parent e4d2990 commit cc953c8

File tree

2 files changed

+29
-13
lines changed

2 files changed

+29
-13
lines changed

cpp/ql/test/query-tests/Security/CWE/CWE-119/semmle/tests/UnboundedWrite.expected

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ edges
3131
| main.cpp:9:29:9:32 | *argv | tests_restrict.c:15:41:15:44 | *argv | provenance | |
3232
| main.cpp:9:29:9:32 | tests_restrict_main output argument | main.cpp:10:20:10:23 | **argv | provenance | |
3333
| main.cpp:9:29:9:32 | tests_restrict_main output argument | main.cpp:10:20:10:23 | *argv | provenance | |
34-
| main.cpp:10:20:10:23 | **argv | tests.cpp:672:32:672:35 | **argv | provenance | |
35-
| main.cpp:10:20:10:23 | *argv | tests.cpp:672:32:672:35 | **argv | provenance | |
36-
| main.cpp:10:20:10:23 | *argv | tests.cpp:672:32:672:35 | *argv | provenance | |
34+
| main.cpp:10:20:10:23 | **argv | tests.cpp:688:32:688:35 | **argv | provenance | |
35+
| main.cpp:10:20:10:23 | *argv | tests.cpp:688:32:688:35 | **argv | provenance | |
36+
| main.cpp:10:20:10:23 | *argv | tests.cpp:688:32:688:35 | *argv | provenance | |
3737
| overflowdestination.cpp:23:45:23:48 | **argv | overflowdestination.cpp:23:45:23:48 | **argv | provenance | |
3838
| overflowdestination.cpp:23:45:23:48 | **argv | overflowdestination.cpp:23:45:23:48 | *argv | provenance | |
3939
| test_buffer_overrun.cpp:32:46:32:49 | **argv | test_buffer_overrun.cpp:32:46:32:49 | **argv | provenance | |
@@ -46,12 +46,12 @@ edges
4646
| tests.cpp:628:14:628:14 | *s [*home] | tests.cpp:628:14:628:19 | *home | provenance | |
4747
| tests.cpp:628:14:628:14 | *s [*home] | tests.cpp:628:16:628:19 | *home | provenance | |
4848
| tests.cpp:628:16:628:19 | *home | tests.cpp:628:14:628:19 | *home | provenance | |
49-
| tests.cpp:672:32:672:35 | **argv | tests.cpp:697:9:697:15 | *access to array | provenance | |
50-
| tests.cpp:672:32:672:35 | **argv | tests.cpp:698:9:698:15 | *access to array | provenance | |
51-
| tests.cpp:672:32:672:35 | *argv | tests.cpp:697:9:697:15 | *access to array | provenance | |
52-
| tests.cpp:672:32:672:35 | *argv | tests.cpp:698:9:698:15 | *access to array | provenance | |
53-
| tests.cpp:697:9:697:15 | *access to array | tests.cpp:613:19:613:24 | *source | provenance | |
54-
| tests.cpp:698:9:698:15 | *access to array | tests.cpp:622:19:622:24 | *source | provenance | |
49+
| tests.cpp:688:32:688:35 | **argv | tests.cpp:713:9:713:15 | *access to array | provenance | |
50+
| tests.cpp:688:32:688:35 | **argv | tests.cpp:714:9:714:15 | *access to array | provenance | |
51+
| tests.cpp:688:32:688:35 | *argv | tests.cpp:713:9:713:15 | *access to array | provenance | |
52+
| tests.cpp:688:32:688:35 | *argv | tests.cpp:714:9:714:15 | *access to array | provenance | |
53+
| tests.cpp:713:9:713:15 | *access to array | tests.cpp:613:19:613:24 | *source | provenance | |
54+
| tests.cpp:714:9:714:15 | *access to array | tests.cpp:622:19:622:24 | *source | provenance | |
5555
| tests_restrict.c:15:41:15:44 | **argv | tests_restrict.c:15:41:15:44 | **argv | provenance | |
5656
| tests_restrict.c:15:41:15:44 | *argv | tests_restrict.c:15:41:15:44 | *argv | provenance | |
5757
nodes
@@ -85,10 +85,10 @@ nodes
8585
| tests.cpp:628:14:628:14 | *s [*home] | semmle.label | *s [*home] |
8686
| tests.cpp:628:14:628:19 | *home | semmle.label | *home |
8787
| tests.cpp:628:16:628:19 | *home | semmle.label | *home |
88-
| tests.cpp:672:32:672:35 | **argv | semmle.label | **argv |
89-
| tests.cpp:672:32:672:35 | *argv | semmle.label | *argv |
90-
| tests.cpp:697:9:697:15 | *access to array | semmle.label | *access to array |
91-
| tests.cpp:698:9:698:15 | *access to array | semmle.label | *access to array |
88+
| tests.cpp:688:32:688:35 | **argv | semmle.label | **argv |
89+
| tests.cpp:688:32:688:35 | *argv | semmle.label | *argv |
90+
| tests.cpp:713:9:713:15 | *access to array | semmle.label | *access to array |
91+
| tests.cpp:714:9:714:15 | *access to array | semmle.label | *access to array |
9292
| tests_restrict.c:15:41:15:44 | **argv | semmle.label | **argv |
9393
| tests_restrict.c:15:41:15:44 | **argv | semmle.label | **argv |
9494
| tests_restrict.c:15:41:15:44 | *argv | semmle.label | *argv |

cpp/ql/test/query-tests/Security/CWE/CWE-119/semmle/tests/tests.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -668,6 +668,22 @@ void test27(){
668668
}
669669
}
670670

671+
typedef struct _MYSTRUCT {
672+
unsigned long a;
673+
unsigned short b;
674+
unsigned char z[ 100 ];
675+
} MYSTRUCT;
676+
677+
678+
const MYSTRUCT _myStruct = { 0 };
679+
typedef const MYSTRUCT& MYSTRUCTREF;
680+
681+
// False positive case due to use of typedefs
682+
int test27(MYSTRUCTREF g)
683+
{
684+
return memcmp(&g, &_myStruct, sizeof(MYSTRUCT)); // GOOD
685+
}
686+
671687

672688
int tests_main(int argc, char *argv[])
673689
{

0 commit comments

Comments
 (0)