C++: Incorporate docs review comments

This commit is contained in:
Jonas Jensen
2019-01-11 14:16:00 +01:00
parent 7ff94e894a
commit ca3554dcc6
3 changed files with 5 additions and 6 deletions

View File

@@ -4,7 +4,7 @@
<qhelp>
<overview>
<p>This rule flags calls to string copy functions used in conditions, either
<p>This query identifies calls to string copy functions used in conditions, either
directly or as part of an equality operator or logical operator. The most
common string copy functions always return their <code>destination</code>
parameter and do not have a return value reserved to indicate an error.
@@ -39,7 +39,7 @@ context.</p>
<references>
<li>Microsoft Code Analysis for C/C++: <a href="https://docs.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2012/ccf4h9w8(v=vs.110)">C6324</a></li>
<li>Microsoft C library reference: <a href="https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/strcpy-wcscpy-mbscpy">strcpy, wcscpy, _mbscpy</a></li>
<li>US-CERT: <a href="https://www.us-cert.gov/bsi/articles/knowledge/coding-practices/strcpy_s-and-strcat_s">strncpy_s() and strncat_s()</a></li>
<li>US-CERT: <a href="https://www.us-cert.gov/bsi/articles/knowledge/coding-practices/strcpy_s-and-strcat_s">strcpy_s() and strcat_s()</a></li>
</references>
</qhelp>

View File

@@ -37,7 +37,7 @@ predicate isStringCopyCastedAsBoolean(FunctionCall func, Expr expr1, string msg)
DataFlow::localFlow(DataFlow::exprNode(func), DataFlow::exprNode(expr1)) and
isBoolean(expr1.getConversion*()) and
isStringComparisonFunction(func.getTarget().getName()) and
msg = "Return value of " + func.getTarget().getName() + " used as Boolean."
msg = "Return value of " + func.getTarget().getName() + " used as a Boolean."
}
predicate isStringCopyUsedInLogicalOperationOrCondition(FunctionCall func, Expr expr1, string msg) {
@@ -60,8 +60,7 @@ predicate isStringCopyUsedInLogicalOperationOrCondition(FunctionCall func, Expr
func = ble.getAnOperand()
)
) and
msg = "Return value of " + func.getTarget().getName() +
" used in a logical operation."
msg = "Return value of " + func.getTarget().getName() + " used in a logical operation."
or
// or the string copy function is used directly as the conditional expression
(