Skip to content

Commit 19bb8e8

Browse files
committed
Make requested changes
1 parent e075165 commit 19bb8e8

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

cpp/ql/src/experimental/Security/CWE/CWE-787/UnsignedToSignedPointerArith.ql

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @author Jordy Zomer
33
* @name unsiged to signed used in pointer arithmetic
44
* @description finds unsigned to signed conversions used in pointer arithmetic, potentially causing an out-of-bound access
5-
* @id cpp/out-of-bounds
5+
* @id cpp/sign-conversion-pointer-arithmetic
66
* @kind problem
77
* @problem.severity warning
88
* @tags reliability
@@ -14,15 +14,15 @@ import cpp
1414
import semmle.code.cpp.dataflow.DataFlow
1515
import semmle.code.cpp.security.Overflow
1616

17-
from FunctionCall call, Function f, Parameter p, DataFlow::Node sink, PointerArithmeticOperation pao, Operation a, Operation b
17+
from FunctionCall call, Function f, Parameter p, DataFlow::Node sink, PointerArithmeticOperation pao
1818
where
1919
f = call.getTarget() and
2020
p = f.getAParameter() and
21-
p.getType().getUnderlyingType().(IntegralType).isSigned() and
22-
call.getArgument(p.getIndex()).getType().getUnderlyingType().(IntegralType).isUnsigned() and
21+
p.getUnspecifiedType().(IntegralType).isSigned() and
22+
call.getArgument(p.getIndex()).getUnspecifiedType().(IntegralType).isUnsigned() and
2323
pao.getAnOperand() = sink.asExpr() and
24-
not guardedLesser(a, sink.asExpr()) and
25-
not guardedGreater(b, call.getArgument(p.getIndex())) and
24+
not exists(Operation a | guardedLesser(a, sink.asExpr())) and
25+
not exists(Operation b | guardedGreater(b, call.getArgument(p.getIndex()))) and
2626
not call.getArgument(p.getIndex()).isConstant() and
2727
DataFlow::localFlow(DataFlow::parameterNode(p), sink)
2828
select call, "This call: $@ passes an unsigned int to a function that requires a signed int: $@. And then used in pointer arithmetic: $@", call, call.toString(), f, f.toString(), sink, sink.toString()

0 commit comments

Comments
 (0)