forked from github/codeql
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMissingNegativityTest.qhelp
More file actions
38 lines (25 loc) · 883 Bytes
/
MissingNegativityTest.qhelp
File metadata and controls
38 lines (25 loc) · 883 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<!DOCTYPE qhelp PUBLIC
"-//Semmle//qhelp//EN"
"qhelp.dtd">
<qhelp>
<overview>
<p>
This rule finds pointer arithmetic expressions that use a value returned from a function before the value is checked to be positive.
Most pointer arithmetic and almost all array element accesses use a positive value for offsets. A negative value is more likely than not
a defect in the returning function. Checking pointer offsets (particularly if they derive from user input) is necessary to avoid
buffer overruns.
</p>
<p>
The rules only looks at return values of functions that may return a negative value (not all functions).
</p>
<include src="dataFlowWarning.qhelp" />
</overview>
<recommendation>
<p>
Check the function and see whether it needs to check the value to be positive.
</p>
</recommendation>
<example>
<sample src="MissingNegativityTest.cpp" />
</example>
</qhelp>