You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This should make the documentation more in line with the documentation
for our other queries. The @name of the query is changed to "Use of
string copy function in a condition".
Copy file name to clipboardExpand all lines: cpp/ql/src/Likely Bugs/Likely Typos/UsingStrcpyAsBoolean.qhelp
+11-9Lines changed: 11 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -4,12 +4,14 @@
4
4
<qhelp>
5
5
6
6
<overview>
7
-
<p>This rule finds uses of the string copy function calls that return the <code>destination</code> parameter,
8
-
and that do not have a return value reserved to indicate an error.</p>
7
+
<p>This rule flags calls to string copy functions used in conditions, either
8
+
directly or as part of an equality operator or logical operator. The most
9
+
common string copy functions always return their <code>destination</code>
10
+
parameter and do not have a return value reserved to indicate an error.
11
+
Therefore, such a function call always evaluates to true in a Boolean
12
+
context.</p>
9
13
10
-
<p>The rule flags occurrences using such string copy functions as the conditional of an <code>if</code> statement, either directly, as part of an equality operator or a logical operator.</p>
11
-
12
-
<p>The string copy functions that the rule takes into consideration are: </p>
14
+
<p>The string copy functions that the rule takes into consideration are:</p>
13
15
<ul>
14
16
<li>strcpy</li>
15
17
<li>wcscpy</li>
@@ -21,8 +23,8 @@ and that do not have a return value reserved to indicate an error.</p>
21
23
<li>_mbsncpy</li>
22
24
<li>_mbsncpy_l</li>
23
25
</ul>
24
-
25
-
<p>NOTE: It is highly recommended to consider using a more secure version of string manipulation functions suchas as <code>strcpy_s</code>.</p>
26
+
27
+
<p>NOTE: It is highly recommended to consider using a more secure version of string manipulation functions such as as <code>strcpy_s</code>.</p>
26
28
27
29
</overview>
28
30
<recommendation>
@@ -35,8 +37,8 @@ and that do not have a return value reserved to indicate an error.</p>
35
37
</example>
36
38
37
39
<references>
38
-
<li>Microsoft Books on Line: <ahref="https://docs.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2012/ccf4h9w8(v=vs.110)">C6324</a></li>
39
-
<li>Microsoft Books on Line: <ahref="https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/strcpy-wcscpy-mbscpy?view=vs-2017">strcpy, wcscpy, _mbscpy</a></li>
40
+
<li>Microsoft Code Analysis for C/C++: <ahref="https://docs.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2012/ccf4h9w8(v=vs.110)">C6324</a></li>
41
+
<li>Microsoft C library reference: <ahref="https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/strcpy-wcscpy-mbscpy">strcpy, wcscpy, _mbscpy</a></li>
40
42
<li>US-CERT: <ahref="https://www.us-cert.gov/bsi/articles/knowledge/coding-practices/strcpy_s-and-strcat_s">strncpy_s() and strncat_s()</a></li>
0 commit comments