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

Skip to content

Commit 0f88a4b

Browse files
committed
C++: Test ?: support in UsingStrcpyAsBoolean.ql
This test shows that the query only supports the ternary operator in C++, not C.
1 parent 4dd3677 commit 0f88a4b

3 files changed

Lines changed: 3 additions & 2 deletions

File tree

cpp/ql/test/query-tests/Likely Bugs/Likely Typos/UsingStrcpyAsBoolean/UsingStrcpyAsBoolean.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
| test.cpp:127:9:127:37 | ! ... | Return value of strncpy used in a logical operation. |
2525
| test.cpp:131:14:131:20 | call to strncpy | Return value of strncpy used as Boolean. |
2626
| test.cpp:133:19:133:47 | ! ... | Return value of strncpy used in a logical operation. |
27+
| test.cpp:134:14:134:19 | call to strcpy | Return value of strcpy used as Boolean. |
2728
| test.cpp:135:14:135:40 | ... && ... | Return value of strcpy used in a logical operation. |
2829
| test.cpp:137:14:137:40 | ... == ... | Return value of strcpy used in a logical operation. |
2930
| test.cpp:139:14:139:40 | ... != ... | Return value of strcpy used in a logical operation. |

cpp/ql/test/query-tests/Likely Bugs/Likely Typos/UsingStrcpyAsBoolean/test.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ void PositiveCases()
5656
}
5757

5858
result = !strncpy(szbuf1, "test", 100); // Bug
59-
59+
result = strcpy(szbuf1, "test") ? 1 : 0; // Bug [NOT DETECTED]
6060
result = strcpy(szbuf1, "test") && 1; // Bug
6161

6262
result = strcpy(szbuf1, "test") == 0; // Bug

cpp/ql/test/query-tests/Likely Bugs/Likely Typos/UsingStrcpyAsBoolean/test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ void PositiveCases()
131131
bool b = strncpy(szbuf1, "test", 100); // Bug
132132

133133
bool result = !strncpy(szbuf1, "test", 100); // Bug
134-
134+
result = strcpy(szbuf1, "test") ? 1 : 0; // Bug
135135
result = strcpy(szbuf1, "test") && 1; // Bug
136136

137137
result = strcpy(szbuf1, "test") == 0; // Bug

0 commit comments

Comments
 (0)