Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitff90ac7

Browse files
committed
C++: Fix queries I forgot after merginggithub/codeql#20485.
1 parent68be4b0 commitff90ac7

File tree

6 files changed

+20
-15
lines changed

6 files changed

+20
-15
lines changed

‎c/cert/src/rules/EXP16-C/DoNotCompareFunctionPointersToConstantValues.ql‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,9 @@ class ExplicitComparison extends EffectivelyComparison, FinalComparisonOperation
5353

5454
classImplicitComparisonextendsEffectivelyComparison,GuardConditioninstanceofExpr{
5555
ImplicitComparison(){
56+
this.valueControlsEdge(_, _, _)and
5657
thisinstanceofFunctionExprand
57-
notgetParent()instanceofComparisonOperation
58+
notsuper.getParent()instanceofComparisonOperation
5859
}
5960

6061
overridestringgetExplanation(){result="$@ undergoes implicit constant comparison."}

‎cpp/autosar/src/rules/A4-7-1/IntegerExpressionLeadToDataLoss.ql‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ from InterestingOverflowingOperation e
2323
where
2424
notisExcluded(e, IntegerConversionPackage::integerExpressionLeadToDataLossQuery())and
2525
// Not within a guard condition
26-
notexists(GuardConditiongc|gc.getAChild*()=e)and
26+
note.getParent*().(GuardCondition).valueControlsEdge(_, _, _)and
2727
// Not guarded by a check, where the check is not an invalid overflow check
2828
note.hasValidPreCheck()and
2929
// Covered by `IntMultToLong.ql` instead

‎cpp/cert/src/rules/MEM52-CPP/DetectAndHandleMemoryAllocationErrors.ql‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,13 @@ class NoThrowAllocExprWrapperFunction extends Function {
6262
NoThrowAllocExprWrapperFunction(){
6363
n.getEnclosingFunction()=thisand
6464
DataFlow::localExprFlow(n,any(ReturnStmtrs).getExpr())and
65-
// Not checked in this wrapper function
66-
notexists(GuardConditiongc| DataFlow::localExprFlow(n,gc.(Expr).getAChild*()))
65+
// Not checked in this wrapper function. That is, the allocation is not a
66+
// guard condition which guards something inside the function.
67+
notexists(BasicBlockbb|
68+
pragma[only_bind_out](bb.getEnclosingFunction())=
69+
pragma[only_bind_out](n.getEnclosingFunction())and
70+
n.(GuardCondition).valueControlsEdge(bb, _, _)
71+
)
6772
}
6873

6974
/** Gets the underlying nothrow allocation ultimately being wrapped. */
@@ -84,7 +89,9 @@ module NoThrowNewErrorCheckConfig implements DataFlow::ConfigSig {
8489
source.asExpr()instanceofNotWrappedNoThrowAllocExpr
8590
}
8691

87-
predicateisSink(DataFlow::Nodesink){sink.asExpr()=any(GuardConditiongc).getAChild*()}
92+
predicateisSink(DataFlow::Nodesink){
93+
sink.asExpr().(GuardCondition).valueControlsEdge(_, _, _)
94+
}
8895
}
8996

9097
module NoThrowNewErrorCheckFlow= DataFlow::Global<NoThrowNewErrorCheckConfig>;
Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
WARNING: module 'DataFlow' has been deprecated and may be removed in future (DetectAndHandleMemoryAllocationErrors.ql:64,5-13)
2-
WARNING: module 'DataFlow' has been deprecated and may be removed in future (DetectAndHandleMemoryAllocationErrors.ql:66,36-44)
3-
WARNING: module 'DataFlow' has been deprecated and may be removed in future (DetectAndHandleMemoryAllocationErrors.ql:82,46-54)
4-
WARNING: module 'DataFlow' has been deprecated and may be removed in future (DetectAndHandleMemoryAllocationErrors.ql:83,22-30)
5-
WARNING: module 'DataFlow' has been deprecated and may be removed in future (DetectAndHandleMemoryAllocationErrors.ql:87,20-28)
6-
WARNING: module 'DataFlow' has been deprecated and may be removed in future (DetectAndHandleMemoryAllocationErrors.ql:90,35-43)
7-
WARNING: module 'DataFlow' has been deprecated and may be removed in future (DetectAndHandleMemoryAllocationErrors.ql:95,38-46)
2+
WARNING: module 'DataFlow' has been deprecated and may be removed in future (DetectAndHandleMemoryAllocationErrors.ql:86,46-54)
3+
WARNING: module 'DataFlow' has been deprecated and may be removed in future (DetectAndHandleMemoryAllocationErrors.ql:87,22-30)
4+
WARNING: module 'DataFlow' has been deprecated and may be removed in future (DetectAndHandleMemoryAllocationErrors.ql:91,20-28)
5+
WARNING: module 'DataFlow' has been deprecated and may be removed in future (DetectAndHandleMemoryAllocationErrors.ql:96,35-43)
6+
WARNING: module 'DataFlow' has been deprecated and may be removed in future (DetectAndHandleMemoryAllocationErrors.ql:101,38-46)
87
| test.cpp:24:7:24:34 | new | nothrow new allocation of $@ returns here without a subsequent check to see whether the pointer is valid. | test.cpp:24:7:24:34 | new | StructA * |
98
| test.cpp:40:17:40:38 | call to allocate_without_check | nothrow new allocation of $@ returns here without a subsequent check to see whether the pointer is valid. | test.cpp:35:17:35:44 | new | StructA * |

‎cpp/common/src/codingstandards/cpp/rules/functionerroneousreturnvaluenottested/FunctionErroneousReturnValueNotTested.qll‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ query predicate problems(FunctionCall fc, string message) {
5555
"vwprintf","vfwprintf","vswprintf","vwprintf_s","vfwprintf_s","vswprintf_s",
5656
"vsnwprintf_s"
5757
])and
58-
notexists(GuardConditiongc|
59-
DataFlow::localFlow(DataFlow::exprNode(fc), DataFlow::exprNode(gc.(Expr).getAChild*()))
60-
)and
58+
notfc.(GuardCondition).valueControlsEdge(_, _, _)and
6159
message="Return value from "+fc.getTarget().getName()+" is not tested for errors."
6260
}

‎cpp/common/src/codingstandards/cpp/rules/unsignedoperationwithconstantoperandswraps/UnsignedOperationWithConstantOperandsWraps.qll‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ query predicate problems(InterestingOverflowingOperation op, string message) {
1818
notisExcluded(op,getQuery())and
1919
op.getType().getUnderlyingType().(IntegralType).isUnsigned()and
2020
// Not within a guard condition
21-
notexists(GuardConditiongc|gc.getAChild*()=op)and
21+
notop.getParent*().(GuardCondition).valueControlsEdge(_, _, _)and
2222
// Not guarded by a check, where the check is not an invalid overflow check
2323
notop.hasValidPreCheck()and
2424
// Is not checked after the operation

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp