Skip to content

Commit 3006935

Browse files
author
thibaut hansmann
committed
C/C++ : FIx the research for UInt16, 32 and 64 + Fix 2 first line of the query
1 parent c15c216 commit 3006935

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

cpp/ql/src/experimental/Best Practices/WrongUintAccess.ql

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,18 @@
1010
import cpp
1111

1212
from
13-
Variable var, ArrayExpr useExpr, VariableDeclarationEntry def, ArrayType defLine, VariableAccess use
13+
Variable var, ArrayExpr useExpr, VariableDeclarationEntry def, ArrayType defLine,
14+
VariableAccess use
1415
where
15-
def = defLine.getATypeNameUse() and
16-
var = def.getDeclaration() and
16+
var.getUnspecifiedType() = defLine and
1717
use = useExpr.getArrayBase() and
18-
var = use.getTarget() and (
19-
(useExpr.getArrayOffset().getType() instanceof UInt16_t and
20-
defLine.getArraySize() <= 256) or
21-
(useExpr.getArrayOffset().getType() instanceof UInt32_t and
22-
defLine.getArraySize() <= 900) or
23-
(useExpr.getArrayOffset().getType() instanceof UInt64_t and
24-
defLine.getArraySize() <= 1000)
25-
)
26-
select useExpr, "Using a " + useExpr.getArrayOffset().getType() +" to acess the array $@ of size " + defLine.getArraySize() + ".", var,
27-
var.getName()
18+
var = use.getTarget() and
19+
(
20+
useExpr.getArrayOffset().getType() instanceof UInt16_t or
21+
useExpr.getArrayOffset().getType() instanceof UInt32_t or
22+
useExpr.getArrayOffset().getType() instanceof UInt64_t
23+
) and
24+
defLine.getArraySize() <= 256
25+
select useExpr,
26+
"Using a " + useExpr.getArrayOffset().getType() + " to acess the array $@ of size " +
27+
defLine.getArraySize() + ".", var, var.getName()

0 commit comments

Comments
 (0)