Skip to content

Commit c4723c8

Browse files
committed
C++: Port toe fhrst part of the negation to the new module.
1 parent f50bce6 commit c4723c8

File tree

1 file changed

+29
-7
lines changed

1 file changed

+29
-7
lines changed

cpp/ql/src/Likely Bugs/Leap Year/UncheckedReturnValueForTimeFunctions.ql

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,31 @@ module ModifiedFieldAccessToTimeConversionConfig implements InputSig {
114114
module ModifiedFieldAccessToTimeConversion =
115115
ControlFlowReachability<ModifiedFieldAccessToTimeConversionConfig>;
116116

117+
module SafeTimeGatheringFunctionCallToTimeConversionFunctionCallConfig implements InputSig {
118+
predicate isSource(ControlFlowNode n) {
119+
n = any(SafeTimeGatheringFunction stgf).getACallToThisFunction()
120+
}
121+
122+
predicate isSink(ControlFlowNode fcall) { ModifiedFieldAccessToTimeConversion::isSink(fcall) }
123+
}
124+
125+
module SafeTimeGatheringFunctionCallToTimeConversionFunctionCall =
126+
ControlFlowReachability<SafeTimeGatheringFunctionCallToTimeConversionFunctionCallConfig>;
127+
128+
module SafeTimeGatheringFunctionCallToModifiedFieldAccessConfig implements InputSig {
129+
predicate isSource(ControlFlowNode n) {
130+
n = any(SafeTimeGatheringFunction stgf).getACallToThisFunction() and
131+
SafeTimeGatheringFunctionCallToTimeConversionFunctionCall::isSource(n)
132+
}
133+
134+
predicate isSink(ControlFlowNode modifiedVarAccess) {
135+
ModifiedFieldAccessToTimeConversion::flowsTo(modifiedVarAccess, _)
136+
}
137+
}
138+
139+
module SafeTimeGatheringFunctionCallToModifiedFieldAccess =
140+
ControlFlowReachability<SafeTimeGatheringFunctionCallToModifiedFieldAccessConfig>;
141+
117142
from FunctionCall fcall, TimeConversionFunction trf, Variable var
118143
where
119144
isUnpackedTimeTypeVar(var, fcall, trf) and
@@ -125,13 +150,10 @@ where
125150
not (
126151
// Remove any instance where the predecessor is a SafeTimeGatheringFunction and no change to the data happened in between
127152
exists(FunctionCall pred |
128-
pred = fcall.getAPredecessor*() and
129-
exists(SafeTimeGatheringFunction stgf | pred = stgf.getACallToThisFunction()) and
130-
not exists(DateStructModifiedFieldAccess dsmfa, VariableAccess modifiedVarAccess |
131-
modifiedVarAccess = var.getAnAccess() and
132-
modifiedVarAccess = dsmfa.getQualifier() and
133-
modifiedVarAccess = fcall.getAPredecessor*() and
134-
modifiedVarAccess = pred.getASuccessor*()
153+
SafeTimeGatheringFunctionCallToTimeConversionFunctionCall::flowsTo(pred, fcall) and
154+
not exists(VariableAccess modifiedVarAccess |
155+
ModifiedFieldAccessToTimeConversion::flowsTo(modifiedVarAccess, fcall) and
156+
SafeTimeGatheringFunctionCallToModifiedFieldAccess::flowsTo(pred, modifiedVarAccess)
135157
)
136158
)
137159
or

0 commit comments

Comments
 (0)