Skip to content

Commit ec79094

Browse files
authored
Merge pull request github#5191 from MathiasVP/regression-test-const-member-function
C++: Add test for missing flow due to const specifier
2 parents e1c4406 + 1b148c4 commit ec79094

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

cpp/ql/test/library-tests/dataflow/taint-tests/localTaint.expected

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6042,6 +6042,21 @@
60426042
| taint.cpp:631:6:631:14 | call to _strnextc | taint.cpp:631:2:631:18 | ... = ... | |
60436043
| taint.cpp:631:6:631:14 | call to _strnextc | taint.cpp:632:7:632:7 | c | |
60446044
| taint.cpp:631:16:631:17 | | taint.cpp:631:6:631:14 | call to _strnextc | TAINT |
6045+
| taint.cpp:640:9:640:12 | this | taint.cpp:640:25:640:29 | this | |
6046+
| taint.cpp:643:33:643:38 | source | taint.cpp:645:20:645:25 | source | |
6047+
| taint.cpp:644:30:644:30 | c | taint.cpp:645:10:645:10 | c | |
6048+
| taint.cpp:644:30:644:30 | c | taint.cpp:646:8:646:8 | c | |
6049+
| taint.cpp:645:10:645:10 | ref arg c | taint.cpp:646:8:646:8 | c | |
6050+
| taint.cpp:645:12:645:15 | call to data | taint.cpp:645:3:645:8 | call to memcpy | |
6051+
| taint.cpp:645:20:645:25 | source | taint.cpp:645:3:645:8 | call to memcpy | TAINT |
6052+
| taint.cpp:645:20:645:25 | source | taint.cpp:645:12:645:15 | ref arg call to data | TAINT |
6053+
| taint.cpp:652:9:652:12 | this | taint.cpp:652:31:652:35 | this | |
6054+
| taint.cpp:655:35:655:40 | source | taint.cpp:657:20:657:25 | source | |
6055+
| taint.cpp:656:27:656:27 | c | taint.cpp:657:10:657:10 | c | |
6056+
| taint.cpp:656:27:656:27 | c | taint.cpp:658:8:658:8 | c | |
6057+
| taint.cpp:657:12:657:15 | call to data | taint.cpp:657:3:657:8 | call to memcpy | |
6058+
| taint.cpp:657:20:657:25 | source | taint.cpp:657:3:657:8 | call to memcpy | TAINT |
6059+
| taint.cpp:657:20:657:25 | source | taint.cpp:657:12:657:15 | ref arg call to data | TAINT |
60456060
| vector.cpp:16:43:16:49 | source1 | vector.cpp:17:26:17:32 | source1 | |
60466061
| vector.cpp:16:43:16:49 | source1 | vector.cpp:31:38:31:44 | source1 | |
60476062
| vector.cpp:17:21:17:33 | call to vector | vector.cpp:19:14:19:14 | v | |

cpp/ql/test/library-tests/dataflow/taint-tests/taint.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,4 +630,30 @@ void test__strnextc(const char* source) {
630630
} while(c != '\0');
631631
c = _strnextc("");
632632
sink(c);
633+
}
634+
635+
// --- taint through const specified function ---
636+
637+
class C_no_const_member_function {
638+
char* data_;
639+
public:
640+
char* data() { return data_; }
641+
};
642+
643+
void test_no_const_member(char* source) {
644+
C_no_const_member_function c;
645+
memcpy(c.data(), source, 16);
646+
sink(c.data()); // $ ast MISSING: ir
647+
}
648+
649+
class C_const_member_function {
650+
char* data_;
651+
public:
652+
char* data() const { return data_; }
653+
};
654+
655+
void test_with_const_member(char* source) {
656+
C_const_member_function c;
657+
memcpy(c.data(), source, 16);
658+
sink(c.data()); // $ MISSING: ast, ir
633659
}

0 commit comments

Comments
 (0)