Skip to content

Commit e4d2990

Browse files
committed
Formatting and updating tests.
1 parent f0eeaaf commit e4d2990

File tree

3 files changed

+23
-15
lines changed

3 files changed

+23
-15
lines changed

cpp/ql/lib/semmle/code/cpp/security/BufferAccess.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ int getPointedSize(Type t) {
1414
* BufferWrite differ.
1515
*/
1616
abstract class BufferAccess extends Expr {
17-
BufferAccess() {
18-
not this.isUnevaluated() and
17+
BufferAccess() {
18+
not this.isUnevaluated() and
1919
//A buffer access must be reachable (not in dead code)
2020
reachable(this)
2121
}

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:664:32:664:35 | **argv | provenance | |
35-
| main.cpp:10:20:10:23 | *argv | tests.cpp:664:32:664:35 | **argv | provenance | |
36-
| main.cpp:10:20:10:23 | *argv | tests.cpp:664:32:664:35 | *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 | |
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:664:32:664:35 | **argv | tests.cpp:689:9:689:15 | *access to array | provenance | |
50-
| tests.cpp:664:32:664:35 | **argv | tests.cpp:690:9:690:15 | *access to array | provenance | |
51-
| tests.cpp:664:32:664:35 | *argv | tests.cpp:689:9:689:15 | *access to array | provenance | |
52-
| tests.cpp:664:32:664:35 | *argv | tests.cpp:690:9:690:15 | *access to array | provenance | |
53-
| tests.cpp:689:9:689:15 | *access to array | tests.cpp:613:19:613:24 | *source | provenance | |
54-
| tests.cpp:690:9:690:15 | *access to array | tests.cpp:622:19:622:24 | *source | 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 | |
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:664:32:664:35 | **argv | semmle.label | **argv |
89-
| tests.cpp:664:32:664:35 | *argv | semmle.label | *argv |
90-
| tests.cpp:689:9:689:15 | *access to array | semmle.label | *access to array |
91-
| tests.cpp:690:9:690:15 | *access to array | semmle.label | *access to array |
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 |
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: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -657,10 +657,18 @@ void test26(bool cond)
657657
void test27(){
658658
char *src = "";
659659
char *dest = "abcdefgh";
660+
const int size = 100;
661+
int ind = 100;
662+
char buffer[size];
660663

661664
strncpy(dest, src, strlen(dest)); // GOOD, strncpy will not read past null terminator of source
665+
666+
if(ind < size){
667+
buffer[ind] = 0; // GOOD: out of bounds, but inaccessible code
668+
}
662669
}
663670

671+
664672
int tests_main(int argc, char *argv[])
665673
{
666674
long long arr17[19];

0 commit comments

Comments
 (0)