Skip to content

Commit ffc61ae

Browse files
committed
C++: Make memset_s a clearer recommendation in the .qhelp for cpp/memset-may-be-deleted.
1 parent a63e70d commit ffc61ae

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

cpp/ql/src/Security/CWE/CWE-014/MemsetMayBeDeleted.qhelp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@ contains sensitive data that could somehow be retrieved by an attacker.</p>
1010
</overview>
1111
<recommendation>
1212

13-
<p>Use alternative platform-supplied functions that will not get optimized away. Examples of such
14-
functions include <code>memset_s</code>, <code>SecureZeroMemory</code>, and <code>bzero_explicit</code>.
15-
Alternatively, passing the <code>-fno-builtin-memset</code> option to the GCC/Clang compiler usually
16-
also prevents the optimization. Finally, you can use the public-domain <code>secure_memzero</code> function
17-
(see references below). This function, however, is not guaranteed to work on all platforms and compilers.</p>
13+
<p>Use <code>memset_s</code> (from C11) instead of <code>memset</code>, as <code>memset_s</code> will not
14+
get optimized away. Alternatively use platform-supplied functions such as <code>SecureZeroMemory</code> or
15+
<code>bzero_explicit</code> that make the same guarantee. Passing the <code>-fno-builtin-memset</code>
16+
option to the GCC/Clang compiler usually also prevents the optimization. Finally, you can use the
17+
public-domain <code>secure_memzero</code> function (see references below). This function, however, is not
18+
guaranteed to work on all platforms and compilers.</p>
1819

1920
</recommendation>
2021
<example>

0 commit comments

Comments
 (0)