Skip to content

Commit 8be6aed

Browse files
authored
Merge pull request #14769 from MathiasVP/fix-nonterminating-test
C++: Fix nonterminating test
2 parents 359dcf3 + eb263e7 commit 8be6aed

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed
Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
11
edges
2-
subpaths
2+
| main.cpp:6:27:6:30 | argv indirection | main.cpp:10:20:10:23 | argv indirection |
3+
| main.cpp:10:20:10:23 | argv indirection | tests.cpp:618:32:618:35 | argv indirection |
4+
| tests.cpp:613:19:613:24 | source indirection | tests.cpp:615:17:615:22 | source indirection |
5+
| tests.cpp:618:32:618:35 | argv indirection | tests.cpp:643:9:643:15 | access to array indirection |
6+
| tests.cpp:643:9:643:15 | access to array indirection | tests.cpp:613:19:613:24 | source indirection |
37
nodes
8+
| main.cpp:6:27:6:30 | argv indirection | semmle.label | argv indirection |
9+
| main.cpp:10:20:10:23 | argv indirection | semmle.label | argv indirection |
10+
| tests.cpp:613:19:613:24 | source indirection | semmle.label | source indirection |
11+
| tests.cpp:615:17:615:22 | source indirection | semmle.label | source indirection |
12+
| tests.cpp:618:32:618:35 | argv indirection | semmle.label | argv indirection |
13+
| tests.cpp:643:9:643:15 | access to array indirection | semmle.label | access to array indirection |
14+
subpaths
415
#select
16+
| tests.cpp:615:2:615:7 | call to strcpy | main.cpp:6:27:6:30 | argv indirection | tests.cpp:615:17:615:22 | source indirection | This 'call to strcpy' with input from $@ may overflow the destination. | main.cpp:6:27:6:30 | argv indirection | a command-line argument |

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ void test15()
407407
{
408408
if (ptr[5] == ' ') // GOOD
409409
{
410-
// ...
410+
break;
411411
}
412412
}
413413
}
@@ -608,6 +608,13 @@ int test23() {
608608
return sizeof(buffer) / sizeof(buffer[101]); // GOOD
609609
}
610610

611+
char* strcpy(char *, const char *);
612+
613+
void test24(char* source) {
614+
char buffer[100];
615+
strcpy(buffer, source); // BAD
616+
}
617+
611618
int tests_main(int argc, char *argv[])
612619
{
613620
long long arr17[19];
@@ -633,6 +640,7 @@ int tests_main(int argc, char *argv[])
633640
test21(argc == 0);
634641
test22(argc == 0, argv[0]);
635642
test23();
643+
test24(argv[0]);
636644

637645
return 0;
638646
}

0 commit comments

Comments
 (0)