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: change-notes/1.21/analysis-cpp.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,6 +18,7 @@
18
18
| Memory is never freed (`cpp/memory-never-freed`) | More correct results | Support added for more Microsoft-specific allocation functions, including `LocalAlloc`, `GlobalAlloc`, `HeapAlloc` and `CoTaskMemAlloc`. |
19
19
| Resource not released in destructor (`cpp/resource-not-released-in-destructor`) | Fewer false positive results | Resource allocation and deallocation functions are now determined more accurately. |
20
20
| Comparison result is always the same | Fewer false positive results | The range analysis library is now more conservative about floating point values being possibly `NaN`|
21
+
| Use of potentially dangerous function | More correct results | Calls to `localtime`, `ctime` and `asctime` are now detected by this query. |
21
22
| Wrong type of arguments to formatting function (`cpp/wrong-type-format-argument`) | More correct results and fewer false positive results | This query now more accurately identifies wide and non-wide string/character format arguments on different platforms. Platform detection has also been made more accurate for the purposes of this query. |
22
23
| Wrong type of arguments to formatting function (`cpp/wrong-type-format-argument`) | Fewer false positive results | Non-standard uses of %L are now understood. |
Copy file name to clipboardExpand all lines: cpp/ql/src/Security/CWE/CWE-676/PotentiallyDangerousFunction.qhelp
+11-4Lines changed: 11 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -5,13 +5,15 @@
5
5
<overview>
6
6
<p>This rule finds calls to functions that are dangerous to
7
7
use. Currently, it checks for calls
8
-
to <code>gets</code> and <code>gmtime</code>. See <strong>Related rules</strong>
9
-
below for rules that identify other dangerous functions.</p>
8
+
to <code>gets</code>, <code>gmtime</code>, <code>localtime</code>,
9
+
<code>ctime</code> and <code>asctime</code>. See <strong>Related
10
+
rules</strong> below for rules that identify other dangerous functions.</p>
10
11
11
12
<p>The <code>gets</code> function is one of the vulnerabilities exploited by the Internet Worm of 1988, one of the first computer worms to spread through the Internet. The <code>gets</code> function provides no way to limit the amount of data that is read and stored, so without prior knowledge of the input it is impossible to use it safely with any size of buffer.</p>
12
13
13
-
<p>The <code>gmtime</code> function fills data into a <code>tm</code>
14
-
struct in shared memory and then returns a pointer to that struct. If
14
+
<p>The time related functions such as <code>gmtime</code>
15
+
fill data into a <code>tm</code> struct or <code>char</code> array in
16
+
shared memory and then returns a pointer to that memory. If
15
17
the function is called from multiple places in the same program, and
16
18
especially if it is called from multiple threads in the same program,
17
19
then the calls will overwrite each other's data.</p>
@@ -26,6 +28,11 @@ With <code>gmtime_r</code>, the application code manages allocation of
26
28
the <code>tm</code> struct. That way, separate calls to the function
27
29
can use their own storage.</p>
28
30
31
+
<p>Similarly replace calls to <code>localtime</code> with
32
+
<code>localtime_r</code>, calls to <code>ctime</code> with
33
+
<code>ctime_r</code> and calls to <code>asctime</code> with
34
+
<code>asctime_r</code>.</p>
35
+
29
36
</recommendation>
30
37
<example>
31
38
<p>The following example checks the local time in two ways:</p>
0 commit comments