Skip to content

Commit bac0acc

Browse files
authored
Merge pull request #21 from trailofbits/implicit-conv-finish
Implicit conversions - polished
2 parents 95de2dc + 79ad0ac commit bac0acc

File tree

4 files changed

+762
-158
lines changed

4 files changed

+762
-158
lines changed

cpp/src/security/UnsafeImplicitConversions/UnsafeImplicitConversions.qhelp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,29 @@
66
<p>
77
Integer variables may be implicitly casted to a type of different size and signedness.
88
If the variable is casted to a type of smaller bit-size or different signedness without a proper bound checking,
9-
then the casting may silently truncate the variable's value or make it semantically meaningless.
9+
then the casting may silently change the variable's value or make it semantically meaningless.
1010

11-
This query finds implicit casts that cannot be proven to be safe.
11+
Since implicit casts are introduced by the compiler, developers may be not aware of them and the compiled code
12+
may behave incorrectly aka may have bugs.
13+
14+
This query finds implicit casts that cannot be proven to be safe.
15+
Safe means that the input value is known to fit into destination type aka the value won't change.
1216
</p>
1317

1418
</overview>
1519
<recommendation>
16-
<p>Either change variables types to avoid implicit conversions or verify that converting highlighted variables is always safe.</p>
20+
<p>
21+
Either adjust types of problematic variables to avoid implicit conversions,
22+
make the code validate that converting the variables is safe,
23+
or add explicit conversions that would make the compiler avoid introducing implicit ones.
24+
</p>
1725

1826
</recommendation>
1927
<example>
2028
<sample src="UnsafeImplicitConversions.cpp" />
2129

22-
<p>In this example, the call to <code>malloc_wrapper</code> may silently truncate <code>large</code> variable, and so the allocated buffer will be of smaller size than the <code>test</code> function expects.</p>
30+
<p>In this example, the call to <code>malloc_wrapper</code> may silently truncate <code>large</code> variable
31+
so that the allocated buffer will be of smaller size than the <code>test</code> function expects.</p>
2332
</example>
2433

2534
</qhelp>

0 commit comments

Comments
 (0)