Skip to content

Commit 851c113

Browse files
committed
C++: Add 'strlen' back.
1 parent 860d0aa commit 851c113

File tree

3 files changed

+3
-8
lines changed

3 files changed

+3
-8
lines changed

cpp/ql/src/semmle/code/cpp/ir/dataflow/DefaultTaintTracking.qll

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ private predicate predictableInstruction(Instruction instr) {
3030
* Note that the list itself is not very principled; it consists of all the
3131
* functions listed in the old security library's [default] `isPureFunction`
3232
* that have more than one argument, but are not in the old taint tracking
33-
* library's `returnArgument` predicate.
33+
* library's `returnArgument` predicate. In addition, `strlen` is included
34+
* because it's also a special case in flow to return values.
3435
*/
3536
predicate predictableOnlyFlow(string name) {
3637
name = "strcasestr" or
@@ -39,6 +40,7 @@ predicate predictableOnlyFlow(string name) {
3940
name = "strchrnul" or
4041
name = "strcmp" or
4142
name = "strcspn" or
43+
name = "strlen" or // special case
4244
name = "strncmp" or
4345
name = "strndup" or
4446
name = "strnlen" or

cpp/ql/test/library-tests/dataflow/security-taint/tainted.expected

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,6 @@
3636
| test.cpp:60:29:60:34 | call to getenv | test.cpp:60:18:60:25 | userName | |
3737
| test.cpp:60:29:60:34 | call to getenv | test.cpp:60:29:60:34 | call to getenv | |
3838
| test.cpp:60:29:60:34 | call to getenv | test.cpp:60:29:60:47 | (const char *)... | |
39-
| test.cpp:60:29:60:34 | call to getenv | test.cpp:64:10:64:14 | bytes | |
40-
| test.cpp:60:29:60:34 | call to getenv | test.cpp:64:18:64:23 | call to strlen | |
41-
| test.cpp:60:29:60:34 | call to getenv | test.cpp:64:18:64:37 | (int)... | |
42-
| test.cpp:60:29:60:34 | call to getenv | test.cpp:64:18:64:37 | ... + ... | |
4339
| test.cpp:60:29:60:34 | call to getenv | test.cpp:64:25:64:32 | userName | |
4440
| test.cpp:68:28:68:33 | call to getenv | test.cpp:11:20:11:21 | s1 | |
4541
| test.cpp:68:28:68:33 | call to getenv | test.cpp:11:36:11:37 | s2 | |

cpp/ql/test/query-tests/Security/CWE/CWE-190/semmle/tainted/IntegerOverflowTainted.expected

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,3 @@
44
| test5.cpp:10:9:10:15 | call to strtoul | $@ flows to here and is used in an expression which might overflow. | test5.cpp:9:7:9:9 | buf | User-provided value |
55
| test.c:44:7:44:12 | ... -- | $@ flows to here and is used in an expression which might overflow negatively. | test.c:41:17:41:20 | argv | User-provided value |
66
| test.c:54:7:54:12 | ... -- | $@ flows to here and is used in an expression which might overflow negatively. | test.c:51:17:51:20 | argv | User-provided value |
7-
| test.c:74:7:74:12 | ... -- | $@ flows to here and is used in an expression which might overflow negatively. | test.c:71:19:71:22 | argv | User-provided value |
8-
| test.c:84:7:84:12 | ... -- | $@ flows to here and is used in an expression which might overflow negatively. | test.c:81:19:81:22 | argv | User-provided value |
9-
| test.c:94:7:94:12 | ... -- | $@ flows to here and is used in an expression which might overflow negatively. | test.c:91:19:91:22 | argv | User-provided value |

0 commit comments

Comments
 (0)