Skip to content

Commit 7aee334

Browse files
committed
CPP: Update the qhelp.
1 parent e8b7bf9 commit 7aee334

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

cpp/ql/src/Security/CWE/CWE-676/PotentiallyDangerousFunction.qhelp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@
55
<overview>
66
<p>This rule finds calls to functions that are dangerous to
77
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>
1011

1112
<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>
1213

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
1517
the function is called from multiple places in the same program, and
1618
especially if it is called from multiple threads in the same program,
1719
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
2628
the <code>tm</code> struct. That way, separate calls to the function
2729
can use their own storage.</p>
2830

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+
2936
</recommendation>
3037
<example>
3138
<p>The following example checks the local time in two ways:</p>

0 commit comments

Comments
 (0)