Skip to content

Commit 33494fe

Browse files
committed
C++: Extend the taint model and accept test changes.
1 parent e468344 commit 33494fe

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ private class Strtol extends AliasFunction, ArrayFunction, TaintFunction, SideEf
2525
input.isParameterDeref(0)
2626
) and
2727
output.isReturnValue()
28+
or
29+
input.isParameter(0) and
30+
output.isParameterDeref(1)
2831
}
2932

3033
override predicate parameterNeverEscapes(int i) {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6636,6 +6636,7 @@ WARNING: Module TaintTracking has been deprecated and may be removed in future (
66366636
| taint.cpp:728:17:728:23 | 0 | taint.cpp:732:8:732:13 | endptr | |
66376637
| taint.cpp:729:11:729:16 | call to strtol | taint.cpp:730:7:730:7 | l | |
66386638
| taint.cpp:729:18:729:23 | source | taint.cpp:729:11:729:16 | call to strtol | TAINT |
6639+
| taint.cpp:729:18:729:23 | source | taint.cpp:729:26:729:32 | ref arg & ... | TAINT |
66396640
| taint.cpp:729:26:729:32 | ref arg & ... | taint.cpp:729:27:729:32 | endptr [inner post update] | |
66406641
| taint.cpp:729:26:729:32 | ref arg & ... | taint.cpp:731:7:731:12 | endptr | |
66416642
| taint.cpp:729:26:729:32 | ref arg & ... | taint.cpp:732:8:732:13 | endptr | |

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -728,6 +728,6 @@ void test_strtol(char *source) {
728728
char* endptr = nullptr;
729729
long l = strtol(source, &endptr, 10);
730730
sink(l); // $ ast,ir
731-
sink(endptr); // $ MISSING: ast,ir
732-
sink(*endptr); // $ MISSING: ast,ir
731+
sink(endptr); // $ ast,ir
732+
sink(*endptr); // $ ast,ir
733733
}

0 commit comments

Comments
 (0)