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
Copy file name to clipboardExpand all lines: cpp/src/security/UnsafeImplicitConversions/UnsafeImplicitConversions.qhelp
+13-4Lines changed: 13 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -6,20 +6,29 @@
6
6
<p>
7
7
Integer variables may be implicitly casted to a type of different size and signedness.
8
8
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.
10
10
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.
12
16
</p>
13
17
14
18
</overview>
15
19
<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>
17
25
18
26
</recommendation>
19
27
<example>
20
28
<samplesrc="UnsafeImplicitConversions.cpp" />
21
29
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>
Copy file name to clipboardExpand all lines: cpp/src/security/UnsafeImplicitConversions/UnsafeImplicitConversions.ql
+46-51Lines changed: 46 additions & 51 deletions
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
/**
2
2
* @name Find all problematic implicit casts
3
-
* @description Find all implicit casts that may be problematic. That is, may result in unexpected truncation, reinterpretation or widening of values.
3
+
* @description Find all implicit casts that may be problematic. That is, casts that may result in unexpected truncation, reinterpretation or widening of values.
0 commit comments