Skip to content

Commit 8dcd46f

Browse files
committed
C++: Add a taint test for gets.
1 parent 285be28 commit 8dcd46f

4 files changed

Lines changed: 24 additions & 0 deletions

File tree

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,9 @@
5252
| test.cpp:75:20:75:25 | call to getenv | test.cpp:75:15:75:18 | call to atoi | |
5353
| test.cpp:75:20:75:25 | call to getenv | test.cpp:75:20:75:25 | call to getenv | |
5454
| test.cpp:75:20:75:25 | call to getenv | test.cpp:75:20:75:45 | (const char *)... | |
55+
| test.cpp:87:12:87:15 | call to gets | test.cpp:85:8:85:14 | pointer | |
56+
| test.cpp:87:12:87:15 | call to gets | test.cpp:87:2:87:8 | pointer | |
57+
| test.cpp:87:12:87:15 | call to gets | test.cpp:87:12:87:15 | call to gets | |
58+
| test.cpp:87:17:87:22 | buffer | test.cpp:80:18:80:18 | s | |
59+
| test.cpp:87:17:87:22 | buffer | test.cpp:84:7:84:12 | buffer | |
60+
| test.cpp:87:17:87:22 | buffer | test.cpp:87:17:87:22 | buffer | |

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,6 @@
88
| test.cpp:68:28:68:33 | call to getenv | test.cpp:69:10:69:13 | copy | AST only |
99
| test.cpp:68:28:68:33 | call to getenv | test.cpp:70:12:70:15 | copy | AST only |
1010
| test.cpp:68:28:68:33 | call to getenv | test.cpp:71:12:71:15 | copy | AST only |
11+
| test.cpp:87:12:87:15 | call to gets | test.cpp:87:2:87:8 | pointer | AST only |
12+
| test.cpp:87:17:87:22 | buffer | test.cpp:84:7:84:12 | buffer | AST only |
13+
| test.cpp:87:17:87:22 | buffer | test.cpp:87:17:87:22 | array to pointer conversion | IR only |

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,8 @@
4040
| test.cpp:75:20:75:25 | call to getenv | test.cpp:75:15:75:18 | call to atoi | |
4141
| test.cpp:75:20:75:25 | call to getenv | test.cpp:75:20:75:25 | call to getenv | |
4242
| test.cpp:75:20:75:25 | call to getenv | test.cpp:75:20:75:45 | (const char *)... | |
43+
| test.cpp:87:12:87:15 | call to gets | test.cpp:85:8:85:14 | pointer | |
44+
| test.cpp:87:12:87:15 | call to gets | test.cpp:87:12:87:15 | call to gets | |
45+
| test.cpp:87:17:87:22 | buffer | test.cpp:80:18:80:18 | s | |
46+
| test.cpp:87:17:87:22 | buffer | test.cpp:87:17:87:22 | array to pointer conversion | |
47+
| test.cpp:87:17:87:22 | buffer | test.cpp:87:17:87:22 | buffer | |

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,13 @@ void guard() {
7676
if (len > 1000) return;
7777
char **node = (char **) malloc(len * sizeof(char *));
7878
}
79+
80+
char *gets(char *s);
81+
82+
void test_gets()
83+
{
84+
char buffer[1024];
85+
char *pointer;
86+
87+
pointer = gets(buffer);
88+
}

0 commit comments

Comments
 (0)