Skip to content

Commit d590952

Browse files
committed
C++: Add a test case involving nested function calls.
1 parent 7632c9e commit d590952

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

cpp/ql/test/query-tests/Security/CWE/CWE-327/BrokenCryptoAlgorithm.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
| test2.cpp:49:4:49:24 | call to my_des_implementation | This file makes use of a broken or weak cryptographic algorithm (specified by $@). | test2.cpp:358:24:358:43 | call to getEncryptionNameDES | call to getEncryptionNameDES |
1818
| test2.cpp:49:4:49:24 | call to my_des_implementation | This file makes use of a broken or weak cryptographic algorithm (specified by $@). | test2.cpp:373:10:373:29 | call to getEncryptionNameDES | call to getEncryptionNameDES |
1919
| test2.cpp:49:4:49:24 | call to my_des_implementation | This file makes use of a broken or weak cryptographic algorithm (specified by $@). | test2.cpp:383:42:383:49 | ALGO_DES | invocation of macro ALGO_DES |
20+
| test2.cpp:49:4:49:24 | call to my_des_implementation | This file makes use of a broken or weak cryptographic algorithm (specified by $@). | test2.cpp:399:26:399:45 | call to getEncryptionNameDES | call to getEncryptionNameDES |
2021
| test.cpp:38:2:38:31 | ENCRYPT_WITH_DES(data,amount) | This file makes use of a broken or weak cryptographic algorithm (specified by $@). | test.cpp:38:2:38:31 | ENCRYPT_WITH_DES(data,amount) | invocation of macro ENCRYPT_WITH_DES |
2122
| test.cpp:38:2:38:31 | ENCRYPT_WITH_DES(data,amount) | This file makes use of a broken or weak cryptographic algorithm (specified by $@). | test.cpp:39:2:39:31 | ENCRYPT_WITH_RC2(data,amount) | invocation of macro ENCRYPT_WITH_RC2 |
2223
| test.cpp:38:2:38:31 | ENCRYPT_WITH_DES(data,amount) | This file makes use of a broken or weak cryptographic algorithm (specified by $@). | test.cpp:41:2:41:32 | ENCRYPT_WITH_3DES(data,amount) | invocation of macro ENCRYPT_WITH_3DES |

cpp/ql/test/query-tests/Security/CWE/CWE-327/test2.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,3 +389,13 @@ void test_string_comparisons3(const char *algo_name)
389389
// ...
390390
}
391391
}
392+
393+
// --- function call in a function call ---
394+
395+
void doEncryption(char *data, size_t len, const char *algorithmName);
396+
397+
void test_fn_in_fn(char *data, size_t len)
398+
{
399+
doEncryption(data, len, getEncryptionNameDES()); // BAD
400+
doEncryption(data, len, getEncryptionNameAES()); // GOOD
401+
}

0 commit comments

Comments
 (0)