Skip to content

Commit c6af799

Browse files
author
Felicity Chapman
committed
Update for feedback
1 parent 2e8f51a commit c6af799

8 files changed

+14
-8
lines changed

cpp/ql/src/Critical/DescriptorMayNotBeClosed.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* @name Open descriptor may not be closed
3-
* @description Failing to close resources in the function that opened them, makes it difficult to avoid and detect resource leaks.
3+
* @description Failing to close resources in the function that opened them makes it difficult to avoid and detect resource leaks.
44
* @kind problem
55
* @id cpp/descriptor-may-not-be-closed
66
* @problem.severity warning

cpp/ql/src/Critical/InitialisationNotRun.qhelp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ optimizations are enabled or the compiler is not compliant with the latest langu
2020
</recommendation>
2121
<example>
2222
<p>In the example below, the code that triggers the initialization of <code>g_storage</code> is not run from <code>main</code>.
23-
Unless the variable is initialized by another method, the call on line 10 may not use the intended value.
23+
Unless the variable is initialized by another method, the call on line 10 may dereference a null pointer.
2424
</p>
2525

2626
<sample src="InitialisationNotRun.cpp" />

cpp/ql/src/Critical/InitialisationNotRun.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* @name Initialization code not run
3-
* @description Using an uninitialized variable may lead to undefined results.
3+
* @description Not running initialization code may lead to unexpected behavior.
44
* @kind problem
55
* @id cpp/initialization-not-run
66
* @problem.severity warning

cpp/ql/src/Critical/LateNegativeTest.qhelp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,19 @@ negative then the negativity test is redundant and can be removed.
2626

2727
<example>
2828
<p>The example below includes two functions that use the value <code>recordIdx</code> to
29-
index an array and a test to verify that the value is positive. The test is made after
30-
<code>printRecord</code> is indexed and before <code>processRecord</code> is indexed.
29+
index an array and a test to verify that the value is positive.
30+
The test is made after <code>records</code> is indexed for <code>printRecord</code> and
31+
before <code>records</code> is indexed for <code>processRecord</code>.
3132
Unless the value of <code>recordIdx</code> cannot be negative, the test should be
32-
updated to run <em>before</em> both arrays are indexed.
33+
updated to run before <em>both</em> times the array is indexed.
34+
If the value cannot be negative, the test should be removed.
3335
</p>
3436

3537
<sample src="LateNegativeTest.cpp" />
3638
</example>
3739

3840
<references>
3941
<li>cplusplus.com: <a href="http://www.cplusplus.com/doc/tutorial/pointers/">Pointers</a>.</li>
42+
<li>SEI CERT C Coding Standard: <a href="https://wiki.sei.cmu.edu/confluence/display/c/ARR30-C.+Do+not+form+or+use+out-of-bounds+pointers+or+array+subscripts">ARR30-C. Do not form or use out-of-bounds pointers or array subscripts</a>.</li>
4043
</references>
4144
</qhelp>

cpp/ql/src/Critical/LateNegativeTest.ql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/**
22
* @name Pointer offset used before it is checked
3-
* @description Setting a pointer offset before checking if the value is positive
3+
* @description Accessing a pointer or array using an offset before
4+
* checking if the value is positive
45
* may result in unexpected behavior.
56
* @kind problem
67
* @id cpp/late-negative-test

cpp/ql/src/Critical/MissingNegativityTest.qhelp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,6 @@ is positive and safe to use as an array offset.
3535

3636
<references>
3737
<li>cplusplus.com: <a href="http://www.cplusplus.com/doc/tutorial/pointers/">Pointers</a>.</li>
38+
<li>SEI CERT C Coding Standard: <a href="https://wiki.sei.cmu.edu/confluence/display/c/ARR30-C.+Do+not+form+or+use+out-of-bounds+pointers+or+array+subscripts">ARR30-C. Do not form or use out-of-bounds pointers or array subscripts</a>.</li>
3839
</references>
3940
</qhelp>

cpp/ql/src/Critical/MissingNegativityTest.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* @name Unchecked return value used as offset
3-
* @description Using a value as a pointer offset without checking that the value is positive
3+
* @description Using a return value as a pointer offset without checking that the value is positive
44
* may lead to buffer overruns.
55
* @kind problem
66
* @id cpp/missing-negativity-test

cpp/ql/src/Critical/ReturnStackAllocatedObject.qhelp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,6 @@ heap-allocated memory.
3232

3333
<references>
3434
<li>cplusplus.com: <a href="http://www.cplusplus.com/doc/tutorial/pointers/">Pointers</a>.</li>
35+
<li>The craft of coding: <a href="https://craftofcoding.wordpress.com/2015/12/07/memory-in-c-the-stack-the-heap-and-static/">Memory in C - the stack, the heap, and static</a>.</li>
3536
</references>
3637
</qhelp>

0 commit comments

Comments
 (0)