Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit dd27ef7

Browse files
committed
C++: Add MAD source definitions for the new taint sources and update the (real) test.
1 parent 833165f commit dd27ef7

3 files changed

Lines changed: 33 additions & 15 deletions

File tree

cpp/ql/lib/semmle/code/cpp/models/implementations/Gets.qll

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,3 +110,21 @@ private class GetsFunction extends DataFlowFunction, ArrayFunction, AliasFunctio
110110

111111
override predicate hasArrayOutput(int bufParam) { bufParam = 0 }
112112
}
113+
114+
/**
115+
* A model for `getc` and similar functions that are flow sources.
116+
*/
117+
private class GetcSource extends SourceModelCsv {
118+
override predicate row(string row) {
119+
row =
120+
[
121+
";;false;getc;;;ReturnValue;remote", ";;false;getwc;;;ReturnValue;remote",
122+
";;false;_getc_nolock;;;ReturnValue;remote", ";;false;_getwc_nolock;;;ReturnValue;remote",
123+
";;false;getch;;;ReturnValue;local", ";;false;_getch;;;ReturnValue;local",
124+
";;false;_getwch;;;ReturnValue;local", ";;false;_getch_nolock;;;ReturnValue;local",
125+
";;false;_getwch_nolock;;;ReturnValue;local", ";;false;getchar;;;ReturnValue;local",
126+
";;false;getwchar;;;ReturnValue;local", ";;false;_getchar_nolock;;;ReturnValue;local",
127+
";;false;_getwchar_nolock;;;ReturnValue;local",
128+
]
129+
}
130+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
failures
21
testFailures
2+
failures

cpp/ql/test/library-tests/dataflow/source-sink-tests/sources-and-sinks.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -70,18 +70,18 @@ int _getchar_nolock(void);
7070
wint_t _getwchar_nolock(void);
7171

7272
void test_getchar(FILE *stream) {
73-
int a = getc(stream); // $ MISSING: remote_source
74-
wint_t b = getwc(stream); // $ MISSING: remote_source
75-
int c = _getc_nolock(stream); // $ MISSING: remote_source
76-
wint_t d = _getwc_nolock(stream); // $ MISSING: remote_source
77-
78-
int e = getch(); // $ MISSING: local_source
79-
int f = _getch(); // $ MISSING: local_source
80-
wint_t g = _getwch(); // $ MISSING: local_source
81-
int h = _getch_nolock(); // $ MISSING: local_source
82-
wint_t i = _getwch_nolock(); // $ MISSING: local_source
83-
int j = getchar(); // $ MISSING: local_source
84-
wint_t k = getwchar(); // $ MISSING: local_source
85-
int l = _getchar_nolock(); // $ MISSING: local_source
86-
wint_t m = _getwchar_nolock(); // $ MISSING: local_source
73+
int a = getc(stream); // $ remote_source
74+
wint_t b = getwc(stream); // $ remote_source
75+
int c = _getc_nolock(stream); // $ remote_source
76+
wint_t d = _getwc_nolock(stream); // $ remote_source
77+
78+
int e = getch(); // $ local_source
79+
int f = _getch(); // $ local_source
80+
wint_t g = _getwch(); // $ local_source
81+
int h = _getch_nolock(); // $ local_source
82+
wint_t i = _getwch_nolock(); // $ local_source
83+
int j = getchar(); // $ local_source
84+
wint_t k = getwchar(); // $ local_source
85+
int l = _getchar_nolock(); // $ local_source
86+
wint_t m = _getwchar_nolock(); // $ local_source
8787
}

0 commit comments

Comments
 (0)